Skip to content

Commit

Permalink
Merge pull request #59 from lambdalisue/fix-readonly
Browse files Browse the repository at this point in the history
📝 Note that `isReadonlyOf` and related are **unstable**
  • Loading branch information
lambdalisue authored Feb 13, 2024
2 parents 5b4795c + 8f1b11a commit bd9a951
Show file tree
Hide file tree
Showing 9 changed files with 356 additions and 151 deletions.
5 changes: 4 additions & 1 deletion is.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import _deprecated from "./is/_deprecated.ts";
import annotation from "./is/annotation.ts";
import core from "./is/core.ts";
import factory from "./is/factory.ts";
import utility from "./is/utility.ts";

export type * from "./is/type.ts";
export * from "./is/_deprecated.ts";
export * from "./is/annotation.ts";
export * from "./is/core.ts";
export * from "./is/factory.ts";
export * from "./is/utility.ts";
export type * from "./is/type.ts";

export default {
..._deprecated,
...annotation,
...core,
...factory,
Expand Down
16 changes: 16 additions & 0 deletions is/__snapshots__/_deprecated_test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export const snapshot = {};

snapshot[`isAllOf<T> > returns properly named function 1`] = `
"isObjectOf({
a: isNumber,
b: isString
})"
`;
snapshot[`isOneOf<T> > returns properly named function 1`] = `
"isUnionOf([
isNumber,
isString,
isBoolean
])"
`;
12 changes: 6 additions & 6 deletions is/__snapshots__/annotation_test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
export const snapshot = {};

snapshot[`isOptionalOf<T> > returns properly named function 1`] = `"isOptionalOf(isNumber)"`;
snapshot[`isOptionalOf<T> > returns properly named function 2`] = `"isOptionalOf(isNumber)"`;
snapshot[`isUnwrapOptionalOf<T> > returns properly named function 1`] = `"isNumber"`;
snapshot[`isUnwrapOptionalOf<T> > returns properly named function 2`] = `"isNumber"`;
snapshot[`isUnwrapOptionalOf<T> > returns properly named function 3`] = `"isNumber"`;
snapshot[`isOptionalOf<T> > returns properly named function 1`] = `"isOptionalOf(isNumber)"`;
snapshot[`isUnwrapReadonlyOf<T> > returns properly named function 1`] = `"isNumber"`;
snapshot[`isOptionalOf<T> > returns properly named function 2`] = `"isOptionalOf(isNumber)"`;
snapshot[`isUnwrapReadonlyOf<T> > returns properly named function 2`] = `"isReadonlyOf(isNumber)"`;
snapshot[`isReadonlyOf<T> > returns properly named function 1`] = `"isReadonlyOf(isNumber)"`;
snapshot[`isReadonlyOf<T> > returns properly named function 2`] = `"isReadonlyOf(isReadonlyOf(isNumber))"`;
snapshot[`isUnwrapReadonlyOf<T> > returns properly named function 1`] = `"isNumber"`;
snapshot[`isUnwrapReadonlyOf<T> > returns properly named function 2`] = `"isReadonlyOf(isNumber)"`;
174 changes: 87 additions & 87 deletions is/__snapshots__/factory_test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
export const snapshot = {};

snapshot[`isMapOf<T> > returns properly named function 1`] = `"isMapOf(isNumber, undefined)"`;
snapshot[`isMapOf<T> > returns properly named function 2`] = `"isMapOf((anonymous), undefined)"`;
snapshot[`isObjectOf<T> > returns properly named function 1`] = `
"isObjectOf({
a: isNumber,
Expand All @@ -22,6 +18,36 @@ snapshot[`isObjectOf<T> > returns properly named function 3`] = `
})"
`;
snapshot[`isArrayOf<T> > returns properly named function 1`] = `"isArrayOf(isNumber)"`;
snapshot[`isArrayOf<T> > returns properly named function 2`] = `"isArrayOf((anonymous))"`;
snapshot[`isReadonlyTupleOf<T> > returns properly named function 1`] = `
"isReadonlyOf(isTupleOf([
isNumber,
isString,
isBoolean
]))"
`;
snapshot[`isReadonlyTupleOf<T> > returns properly named function 2`] = `"isReadonlyOf(isTupleOf([(anonymous)]))"`;
snapshot[`isReadonlyTupleOf<T> > returns properly named function 3`] = `
"isReadonlyOf(isTupleOf([
isReadonlyOf(isTupleOf([
isReadonlyOf(isTupleOf([
isNumber,
isString,
isBoolean
]))
]))
]))"
`;
snapshot[`isSetOf<T> > returns properly named function 1`] = `"isSetOf(isNumber)"`;
snapshot[`isSetOf<T> > returns properly named function 2`] = `"isSetOf((anonymous))"`;
snapshot[`isTupleOf<T> > returns properly named function 1`] = `
"isTupleOf([
isNumber,
Expand All @@ -48,38 +74,6 @@ snapshot[`isRecordOf<T> > returns properly named function 1`] = `"isRecordOf(isN
snapshot[`isRecordOf<T> > returns properly named function 2`] = `"isRecordOf((anonymous), undefined)"`;
snapshot[`isLiteralOf<T> > returns properly named function 1`] = `'isLiteralOf("hello")'`;
snapshot[`isLiteralOf<T> > returns properly named function 2`] = `"isLiteralOf(100)"`;
snapshot[`isLiteralOf<T> > returns properly named function 3`] = `"isLiteralOf(100n)"`;
snapshot[`isLiteralOf<T> > returns properly named function 4`] = `"isLiteralOf(true)"`;
snapshot[`isLiteralOf<T> > returns properly named function 5`] = `"isLiteralOf(null)"`;
snapshot[`isLiteralOf<T> > returns properly named function 6`] = `"isLiteralOf(undefined)"`;
snapshot[`isLiteralOf<T> > returns properly named function 7`] = `"isLiteralOf(Symbol(asdf))"`;
snapshot[`isStrictOf<T> > returns properly named function 1`] = `
"isStrictOf(isObjectOf({
a: isNumber,
b: isString,
c: isBoolean
}))"
`;
snapshot[`isStrictOf<T> > returns properly named function 2`] = `"isStrictOf(isObjectOf({a: a}))"`;
snapshot[`isStrictOf<T> > returns properly named function 3`] = `
"isStrictOf(isObjectOf({
a: isStrictOf(isObjectOf({
b: isStrictOf(isObjectOf({c: isBoolean}))
}))
}))"
`;
snapshot[`isReadonlyTupleOf<T, E> > returns properly named function 1`] = `
"isReadonlyOf(isTupleOf([
isNumber,
Expand All @@ -102,80 +96,86 @@ snapshot[`isReadonlyTupleOf<T, E> > returns properly named function 3`] = `
], isArray))"
`;
snapshot[`isMapOf<T, K> > returns properly named function 1`] = `"isMapOf(isNumber, isString)"`;
snapshot[`isTupleOf<T, E> > returns properly named function 1`] = `
"isTupleOf([
isNumber,
isString,
isBoolean
], isArray)"
`;
snapshot[`isMapOf<T, K> > returns properly named function 2`] = `"isMapOf((anonymous), isString)"`;
snapshot[`isTupleOf<T, E> > returns properly named function 2`] = `"isTupleOf([(anonymous)], isArrayOf(isString))"`;
snapshot[`isTupleOf<T, E> > returns properly named function 3`] = `
"isTupleOf([
isTupleOf([
isTupleOf([
isNumber,
isString,
isBoolean
], isArray)
], isArray)
])"
`;
snapshot[`isInstanceOf<T> > returns properly named function 1`] = `"isInstanceOf(Date)"`;
snapshot[`isInstanceOf<T> > returns properly named function 2`] = `"isInstanceOf((anonymous))"`;
snapshot[`isLiteralOneOf<T> > returns properly named function 1`] = `'isLiteralOneOf(["hello", "world"])'`;
snapshot[`isMapOf<T> > returns properly named function 1`] = `"isMapOf(isNumber, undefined)"`;
snapshot[`isMapOf<T> > returns properly named function 2`] = `"isMapOf((anonymous), undefined)"`;
snapshot[`isStrictOf<T> > returns properly named function 1`] = `
"isStrictOf(isObjectOf({
a: isNumber,
b: isString,
c: isBoolean
}))"
`;
snapshot[`isStrictOf<T> > returns properly named function 2`] = `"isStrictOf(isObjectOf({a: a}))"`;
snapshot[`isStrictOf<T> > returns properly named function 3`] = `
"isStrictOf(isObjectOf({
a: isStrictOf(isObjectOf({
b: isStrictOf(isObjectOf({c: isBoolean}))
}))
}))"
`;
snapshot[`isRecordOf<T, K> > returns properly named function 1`] = `"isRecordOf(isNumber, isString)"`;
snapshot[`isRecordOf<T, K> > returns properly named function 2`] = `"isRecordOf((anonymous), isString)"`;
snapshot[`isArrayOf<T> > returns properly named function 1`] = `"isArrayOf(isNumber)"`;
snapshot[`isLiteralOf<T> > returns properly named function 1`] = `'isLiteralOf("hello")'`;
snapshot[`isArrayOf<T> > returns properly named function 2`] = `"isArrayOf((anonymous))"`;
snapshot[`isLiteralOf<T> > returns properly named function 2`] = `"isLiteralOf(100)"`;
snapshot[`isInstanceOf<T> > returns properly named function 1`] = `"isInstanceOf(Date)"`;
snapshot[`isLiteralOf<T> > returns properly named function 3`] = `"isLiteralOf(100n)"`;
snapshot[`isInstanceOf<T> > returns properly named function 2`] = `"isInstanceOf((anonymous))"`;
snapshot[`isLiteralOf<T> > returns properly named function 4`] = `"isLiteralOf(true)"`;
snapshot[`isReadonlyTupleOf<T> > returns properly named function 1`] = `
"isReadonlyOf(isTupleOf([
isNumber,
isString,
isBoolean
]))"
`;
snapshot[`isLiteralOf<T> > returns properly named function 5`] = `"isLiteralOf(null)"`;
snapshot[`isReadonlyTupleOf<T> > returns properly named function 2`] = `"isReadonlyOf(isTupleOf([(anonymous)]))"`;
snapshot[`isLiteralOf<T> > returns properly named function 6`] = `"isLiteralOf(undefined)"`;
snapshot[`isReadonlyTupleOf<T> > returns properly named function 3`] = `
"isReadonlyOf(isTupleOf([
isReadonlyOf(isTupleOf([
isReadonlyOf(isTupleOf([
isNumber,
isString,
isBoolean
]))
]))
]))"
`;
snapshot[`isLiteralOf<T> > returns properly named function 7`] = `"isLiteralOf(Symbol(asdf))"`;
snapshot[`isMapOf<T, K> > returns properly named function 1`] = `"isMapOf(isNumber, isString)"`;
snapshot[`isMapOf<T, K> > returns properly named function 2`] = `"isMapOf((anonymous), isString)"`;
snapshot[`isUniformTupleOf<T> > returns properly named function 1`] = `"isUniformTupleOf(3, isAny)"`;
snapshot[`isUniformTupleOf<T> > returns properly named function 2`] = `"isUniformTupleOf(3, isNumber)"`;
snapshot[`isUniformTupleOf<T> > returns properly named function 3`] = `"isUniformTupleOf(3, (anonymous))"`;
snapshot[`isSetOf<T> > returns properly named function 1`] = `"isSetOf(isNumber)"`;
snapshot[`isSetOf<T> > returns properly named function 2`] = `"isSetOf((anonymous))"`;
snapshot[`isReadonlyUniformTupleOf<T> > returns properly named function 1`] = `"isReadonlyOf(isUniformTupleOf(3, isAny))"`;
snapshot[`isReadonlyUniformTupleOf<T> > returns properly named function 2`] = `"isReadonlyOf(isUniformTupleOf(3, isNumber))"`;
snapshot[`isReadonlyUniformTupleOf<T> > returns properly named function 3`] = `"isReadonlyOf(isUniformTupleOf(3, (anonymous)))"`;
snapshot[`isTupleOf<T, E> > returns properly named function 1`] = `
"isTupleOf([
isNumber,
isString,
isBoolean
], isArray)"
`;
snapshot[`isTupleOf<T, E> > returns properly named function 2`] = `"isTupleOf([(anonymous)], isArrayOf(isString))"`;
snapshot[`isTupleOf<T, E> > returns properly named function 3`] = `
"isTupleOf([
isTupleOf([
isTupleOf([
isNumber,
isString,
isBoolean
], isArray)
], isArray)
])"
`;
52 changes: 26 additions & 26 deletions is/__snapshots__/utility_test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,27 +1,5 @@
export const snapshot = {};

snapshot[`isRequiredOf<T> > returns properly named function 1`] = `
"isObjectOf({
a: isNumber,
b: isUnionOf([
isString,
isUndefined
]),
c: isBoolean
})"
`;
snapshot[`isRequiredOf<T> > returns properly named function 2`] = `
"isObjectOf({
a: isNumber,
b: isUnionOf([
isString,
isUndefined
]),
c: isBoolean
})"
`;
snapshot[`isUnionOf<T> > returns properly named function 1`] = `
"isUnionOf([
isNumber,
Expand Down Expand Up @@ -61,18 +39,40 @@ snapshot[`isPartialOf<T> > returns properly named function 2`] = `
})"
`;
snapshot[`isIntersectionOf<T> > returns properly named function 1`] = `
snapshot[`isPickOf<T, K> > returns properly named function 1`] = `
"isObjectOf({
a: isNumber,
b: isString
c: isBoolean
})"
`;
snapshot[`isPickOf<T, K> > returns properly named function 1`] = `
snapshot[`isPickOf<T, K> > returns properly named function 2`] = `"isObjectOf({a: isNumber})"`;
snapshot[`isRequiredOf<T> > returns properly named function 1`] = `
"isObjectOf({
a: isNumber,
b: isUnionOf([
isString,
isUndefined
]),
c: isBoolean
})"
`;
snapshot[`isPickOf<T, K> > returns properly named function 2`] = `"isObjectOf({a: isNumber})"`;
snapshot[`isRequiredOf<T> > returns properly named function 2`] = `
"isObjectOf({
a: isNumber,
b: isUnionOf([
isString,
isUndefined
]),
c: isBoolean
})"
`;
snapshot[`isIntersectionOf<T> > returns properly named function 1`] = `
"isObjectOf({
a: isNumber,
b: isString
})"
`;
Loading

0 comments on commit bd9a951

Please sign in to comment.