-
Notifications
You must be signed in to change notification settings - Fork 141
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
85891e3
commit a5a6737
Showing
113 changed files
with
3,348 additions
and
206 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
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,52 +1,3 @@ | ||
import './any' | ||
import './array' | ||
import './async-iterator' | ||
import './awaited' | ||
import './bigint' | ||
import './boolean' | ||
import './capitalize' | ||
import './composite' | ||
import './const' | ||
import './constructor' | ||
import './date' | ||
import './deref' | ||
import './enum' | ||
import './exclude' | ||
import './extract' | ||
import './function' | ||
import './indexed' | ||
import './integer' | ||
import './intersect' | ||
import './iterator' | ||
import './keyof' | ||
import './kind' | ||
import './literal' | ||
import './lowercase' | ||
import './mapped' | ||
import './not' | ||
import './null' | ||
import './number' | ||
import './object' | ||
import './omit' | ||
import './partial' | ||
import './pick' | ||
import './promise' | ||
import './record' | ||
import './recursive' | ||
import './ref' | ||
import './regexp' | ||
import './required' | ||
import './rest' | ||
import './string' | ||
import './symbol' | ||
import './template-literal' | ||
import './this' | ||
import './tuple' | ||
import './uint8array' | ||
import './uncapitalize' | ||
import './undefined' | ||
import './union' | ||
import './unknown' | ||
import './unsafe' | ||
import './uppercase' | ||
import './void' | ||
import './type/index' | ||
import './kind/index' | ||
import './value/index' |
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,14 @@ | ||
import { KindGuard } from '@sinclair/typebox' | ||
import { Type } from '@sinclair/typebox' | ||
import { Assert } from '../../../assert/index' | ||
|
||
describe('guard/kind/TAny', () => { | ||
it('Should guard for TAny', () => { | ||
const R = KindGuard.IsAny(Type.Any()) | ||
Assert.IsTrue(R) | ||
}) | ||
it('Should not guard for TAny', () => { | ||
const R = KindGuard.IsAny(null) | ||
Assert.IsFalse(R) | ||
}) | ||
}) |
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,14 @@ | ||
import { KindGuard } from '@sinclair/typebox' | ||
import { Type } from '@sinclair/typebox' | ||
import { Assert } from '../../../assert/index' | ||
|
||
describe('guard/kind/TArray', () => { | ||
it('Should guard for TArray', () => { | ||
const R = KindGuard.IsArray(Type.Array(Type.Number())) | ||
Assert.IsTrue(R) | ||
}) | ||
it('Should not guard for TArray', () => { | ||
const R = KindGuard.IsArray(null) | ||
Assert.IsFalse(R) | ||
}) | ||
}) |
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,16 @@ | ||
import { KindGuard } from '@sinclair/typebox' | ||
import { Type } from '@sinclair/typebox' | ||
import { Assert } from '../../../assert/index' | ||
|
||
describe('guard/kind/TAsyncIterator', () => { | ||
it('Should guard for TAsyncIterator', () => { | ||
const T = Type.AsyncIterator(Type.Any()) | ||
const R = KindGuard.IsAsyncIterator(T) | ||
Assert.IsTrue(R) | ||
}) | ||
it('Should not guard for TAsyncIterator', () => { | ||
const T = null | ||
const R = KindGuard.IsAsyncIterator(T) | ||
Assert.IsFalse(R) | ||
}) | ||
}) |
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,41 @@ | ||
import { KindGuard } from '@sinclair/typebox' | ||
import { Type } from '@sinclair/typebox' | ||
import { Assert } from '../../../assert/index' | ||
|
||
describe('guard/kind/Awaited', () => { | ||
it('Should guard for Awaited 1', () => { | ||
const T = Type.Awaited(Type.String()) | ||
const R = KindGuard.IsString(T) | ||
Assert.IsTrue(R) | ||
}) | ||
it('Should guard for Awaited 2', () => { | ||
const T = Type.Awaited(Type.Promise(Type.String())) | ||
const R = KindGuard.IsString(T) | ||
Assert.IsTrue(R) | ||
}) | ||
it('Should guard for Awaited 3', () => { | ||
const T = Type.Awaited(Type.Awaited(Type.Promise(Type.String()))) | ||
const R = KindGuard.IsString(T) | ||
Assert.IsTrue(R) | ||
}) | ||
it('Should guard for Awaited 4', () => { | ||
const T = Type.Awaited(Type.Union([Type.Promise(Type.Promise(Type.String()))])) | ||
Assert.IsTrue(KindGuard.IsString(T)) | ||
}) | ||
it('Should guard for Awaited 5', () => { | ||
const T = Type.Awaited(Type.Union([Type.Promise(Type.Promise(Type.String())), Type.Number()])) | ||
Assert.IsTrue(KindGuard.IsUnion(T)) | ||
Assert.IsTrue(KindGuard.IsString(T.anyOf[0])) | ||
Assert.IsTrue(KindGuard.IsNumber(T.anyOf[1])) | ||
}) | ||
it('Should guard for Awaited 6', () => { | ||
const T = Type.Awaited(Type.Intersect([Type.Promise(Type.Promise(Type.String()))])) | ||
Assert.IsTrue(KindGuard.IsString(T)) | ||
}) | ||
it('Should guard for Awaited 7', () => { | ||
const T = Type.Awaited(Type.Intersect([Type.Promise(Type.Promise(Type.String())), Type.Number()])) | ||
Assert.IsTrue(KindGuard.IsIntersect(T)) | ||
Assert.IsTrue(KindGuard.IsString(T.allOf[0])) | ||
Assert.IsTrue(KindGuard.IsNumber(T.allOf[1])) | ||
}) | ||
}) |
Oops, something went wrong.