-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0fe404c
commit bedfb9b
Showing
5 changed files
with
61 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { isObject, isString } from '../utils/type' | ||
import { BrowserFileInfo, NodeFileInfo } from './utils' | ||
|
||
/** | ||
* Checks that browser file info is correct | ||
*/ | ||
export function isBrowserFileInfo(value: unknown): value is BrowserFileInfo { | ||
const data = value as BrowserFileInfo | ||
|
||
// check that `browserFile` is object, but not `File` to be able to check in node.js where `File` is available | ||
return isObject(data.browserFile) && isString(data.relativePathWithBase) && isString(data.relativePath) | ||
} | ||
|
||
/** | ||
* Asserts that node.js file info is correct | ||
*/ | ||
export function assertNodeFileInfo(value: unknown): asserts value is NodeFileInfo { | ||
const data = value as NodeFileInfo | ||
|
||
if (!(isString(data.fullPath) && isString(data.relativePathWithBase) && isString(data.relativePath))) { | ||
throw new Error('Incorrect node file info') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters