-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip to continue working on another machine
- Loading branch information
Showing
28 changed files
with
326 additions
and
256 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
import { Runtype, internalRuntype } from './runtype' | ||
import { Runtype, setupInternalRuntype } from './runtype' | ||
|
||
/** | ||
* A value to check later. | ||
*/ | ||
export function any(): Runtype<any> { | ||
return internalRuntype((v) => { | ||
return v as any | ||
}, true) | ||
return setupInternalRuntype( | ||
(v) => { | ||
return v as any | ||
}, | ||
{ isPure: true }, | ||
) | ||
} |
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
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 |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import { createFail, internalRuntype, Runtype } from './runtype' | ||
import { createFail, setupInternalRuntype, Runtype } from './runtype' | ||
|
||
/** | ||
* A runtype based on a type guard | ||
*/ | ||
export function guardedBy<F>(typeGuard: (v: unknown) => v is F): Runtype<F> { | ||
return internalRuntype((v, failOrThrow) => { | ||
return setupInternalRuntype((v, failOrThrow) => { | ||
if (!typeGuard(v)) { | ||
return createFail(failOrThrow, 'expected typeguard to return true', v) | ||
} | ||
|
||
return v | ||
}, true) | ||
}) | ||
} |
Oops, something went wrong.