type-plus 4.8.2 → 4.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +19 -18
- package/cjs/ComposableTypes.d.ts +1 -0
- package/cjs/ComposableTypes.d.ts.map +1 -0
- package/cjs/JSONTypes.d.ts +1 -0
- package/cjs/JSONTypes.d.ts.map +1 -0
- package/cjs/JSONTypes.js.map +1 -1
- package/cjs/PrimitiveTypes.d.ts +1 -0
- package/cjs/PrimitiveTypes.d.ts.map +1 -0
- package/cjs/UnionKeys.d.ts +1 -0
- package/cjs/UnionKeys.d.ts.map +1 -0
- package/cjs/array/CommonPropKeys.d.ts +2 -1
- package/cjs/array/CommonPropKeys.d.ts.map +1 -0
- package/cjs/array/Concat.d.ts +1 -0
- package/cjs/array/Concat.d.ts.map +1 -0
- package/cjs/array/CreateTuple.d.ts +2 -1
- package/cjs/array/CreateTuple.d.ts.map +1 -0
- package/cjs/array/Filter.d.ts +1 -0
- package/cjs/array/Filter.d.ts.map +1 -0
- package/cjs/array/FindFirst.d.ts +1 -0
- package/cjs/array/FindFirst.d.ts.map +1 -0
- package/cjs/array/FindLast.d.ts +1 -0
- package/cjs/array/FindLast.d.ts.map +1 -0
- package/cjs/array/Head.d.ts +1 -0
- package/cjs/array/Head.d.ts.map +1 -0
- package/cjs/array/IntersectOfProps.d.ts +3 -2
- package/cjs/array/IntersectOfProps.d.ts.map +1 -0
- package/cjs/array/IsArray.d.ts +1 -0
- package/cjs/array/IsArray.d.ts.map +1 -0
- package/cjs/array/Last.d.ts +1 -0
- package/cjs/array/Last.d.ts.map +1 -0
- package/cjs/array/PadLeft.d.ts +4 -3
- package/cjs/array/PadLeft.d.ts.map +1 -0
- package/cjs/array/Reverse.d.ts +1 -0
- package/cjs/array/Reverse.d.ts.map +1 -0
- package/cjs/array/Some.d.ts +4 -3
- package/cjs/array/Some.d.ts.map +1 -0
- package/cjs/array/Tail.d.ts +2 -1
- package/cjs/array/Tail.d.ts.map +1 -0
- package/cjs/array/UnionOfProps.d.ts +3 -2
- package/cjs/array/UnionOfProps.d.ts.map +1 -0
- package/cjs/array/UnionOfValues.d.ts +1 -0
- package/cjs/array/UnionOfValues.d.ts.map +1 -0
- package/cjs/array/drop.d.ts +3 -2
- package/cjs/array/drop.d.ts.map +1 -0
- package/cjs/array/drop.js.map +1 -1
- package/cjs/array/index.d.ts +20 -19
- package/cjs/array/index.d.ts.map +1 -0
- package/cjs/array/index.js +3 -3
- package/cjs/array/index.js.map +1 -1
- package/cjs/array/literalArray.d.ts +2 -1
- package/cjs/array/literalArray.d.ts.map +1 -0
- package/cjs/array/reduceWhile.d.ts +1 -0
- package/cjs/array/reduceWhile.d.ts.map +1 -0
- package/cjs/assertion/assertType.d.ts +3 -2
- package/cjs/assertion/assertType.d.ts.map +1 -0
- package/cjs/assertion/assertType.js +3 -3
- package/cjs/assertion/assertType.js.map +1 -1
- package/cjs/assertion/index.d.ts +2 -1
- package/cjs/assertion/index.d.ts.map +1 -0
- package/cjs/assertion/index.js +1 -1
- package/cjs/assertion/index.js.map +1 -1
- package/cjs/class/AnyConstructor.d.ts +1 -0
- package/cjs/class/AnyConstructor.d.ts.map +1 -0
- package/cjs/class/index.d.ts +3 -2
- package/cjs/class/index.d.ts.map +1 -0
- package/cjs/class/index.js +1 -1
- package/cjs/class/index.js.map +1 -1
- package/cjs/class/isConstructor.d.ts +2 -1
- package/cjs/class/isConstructor.d.ts.map +1 -0
- package/cjs/function/AnyFunction.d.ts +1 -0
- package/cjs/function/AnyFunction.d.ts.map +1 -0
- package/cjs/function/index.d.ts +2 -1
- package/cjs/function/index.d.ts.map +1 -0
- package/cjs/functional/ChainFn.d.ts +1 -0
- package/cjs/functional/ChainFn.d.ts.map +1 -0
- package/cjs/functional/compose.d.ts +3 -2
- package/cjs/functional/compose.d.ts.map +1 -0
- package/cjs/functional/compose.js.map +1 -1
- package/cjs/functional/index.d.ts +3 -2
- package/cjs/functional/index.d.ts.map +1 -0
- package/cjs/functional/index.js +1 -1
- package/cjs/functional/index.js.map +1 -1
- package/cjs/index.d.ts +18 -17
- package/cjs/index.d.ts.map +1 -0
- package/cjs/index.js +14 -14
- package/cjs/index.js.map +1 -1
- package/cjs/math/Abs.d.ts +2 -1
- package/cjs/math/Abs.d.ts.map +1 -0
- package/cjs/math/Add.d.ts +7 -6
- package/cjs/math/Add.d.ts.map +1 -0
- package/cjs/math/Digit.d.ts +7 -4
- package/cjs/math/Digit.d.ts.map +1 -0
- package/cjs/math/GreaterThan.d.ts +10 -9
- package/cjs/math/GreaterThan.d.ts.map +1 -0
- package/cjs/math/IsPositive.d.ts +1 -0
- package/cjs/math/IsPositive.d.ts.map +1 -0
- package/cjs/math/IsWhole.d.ts +1 -0
- package/cjs/math/IsWhole.d.ts.map +1 -0
- package/cjs/math/Max.d.ts +4 -10
- package/cjs/math/Max.d.ts.map +1 -0
- package/cjs/math/Subtract.d.ts +7 -6
- package/cjs/math/Subtract.d.ts.map +1 -0
- package/cjs/math/index.d.ts +9 -8
- package/cjs/math/index.d.ts.map +1 -0
- package/cjs/nodejs/index.d.ts +2 -1
- package/cjs/nodejs/index.d.ts.map +1 -0
- package/cjs/nodejs/index.js +1 -1
- package/cjs/nodejs/index.js.map +1 -1
- package/cjs/nodejs/isNodeError.d.ts +1 -0
- package/cjs/nodejs/isNodeError.d.ts.map +1 -0
- package/cjs/nominal-types/Brand.d.ts +3 -2
- package/cjs/nominal-types/Brand.d.ts.map +1 -0
- package/cjs/nominal-types/Brand.js +2 -2
- package/cjs/nominal-types/Brand.js.map +1 -1
- package/cjs/nominal-types/Flavor.d.ts +3 -2
- package/cjs/nominal-types/Flavor.d.ts.map +1 -0
- package/cjs/nominal-types/Flavor.js +2 -2
- package/cjs/nominal-types/Flavor.js.map +1 -1
- package/cjs/nominal-types/index.d.ts +4 -3
- package/cjs/nominal-types/index.d.ts.map +1 -0
- package/cjs/nominal-types/index.js +3 -3
- package/cjs/nominal-types/index.js.map +1 -1
- package/cjs/nominal-types/nominalMatch.d.ts +3 -2
- package/cjs/nominal-types/nominalMatch.d.ts.map +1 -0
- package/cjs/nominal-types/nominalMatch.js +2 -2
- package/cjs/nominal-types/nominalMatch.js.map +1 -1
- package/cjs/nominal-types/types.d.ts +1 -0
- package/cjs/nominal-types/types.d.ts.map +1 -0
- package/cjs/object/ANotB.d.ts +5 -4
- package/cjs/object/ANotB.d.ts.map +1 -0
- package/cjs/object/AnyRecord.d.ts +1 -0
- package/cjs/object/AnyRecord.d.ts.map +1 -0
- package/cjs/object/ExcludePropType.d.ts +1 -0
- package/cjs/object/ExcludePropType.d.ts.map +1 -0
- package/cjs/object/IsDisjoint.d.ts +4 -3
- package/cjs/object/IsDisjoint.d.ts.map +1 -0
- package/cjs/object/IsRecord.d.ts +1 -0
- package/cjs/object/IsRecord.d.ts.map +1 -0
- package/cjs/object/KeyTypes.d.ts +1 -0
- package/cjs/object/KeyTypes.d.ts.map +1 -0
- package/cjs/object/KeyofOptional.d.ts +1 -0
- package/cjs/object/KeyofOptional.d.ts.map +1 -0
- package/cjs/object/KeysWithDiffType.d.ts +4 -3
- package/cjs/object/KeysWithDiffType.d.ts.map +1 -0
- package/cjs/object/KnownKeys.d.ts +2 -1
- package/cjs/object/KnownKeys.d.ts.map +1 -0
- package/cjs/object/OptionalKeys.d.ts +2 -1
- package/cjs/object/OptionalKeys.d.ts.map +1 -0
- package/cjs/object/Partial.d.ts +4 -3
- package/cjs/object/Partial.d.ts.map +1 -0
- package/cjs/object/RecursiveIntersect.d.ts +2 -1
- package/cjs/object/RecursiveIntersect.d.ts.map +1 -0
- package/cjs/object/RecursivePartial.d.ts +2 -1
- package/cjs/object/RecursivePartial.d.ts.map +1 -0
- package/cjs/object/RecursiveRequired.d.ts +2 -1
- package/cjs/object/RecursiveRequired.d.ts.map +1 -0
- package/cjs/object/Required.d.ts +1 -0
- package/cjs/object/Required.d.ts.map +1 -0
- package/cjs/object/RequiredKeys.d.ts +3 -2
- package/cjs/object/RequiredKeys.d.ts.map +1 -0
- package/cjs/object/SpreadRecord.d.ts +2 -1
- package/cjs/object/SpreadRecord.d.ts.map +1 -0
- package/cjs/object/ValueOf.d.ts +1 -0
- package/cjs/object/ValueOf.d.ts.map +1 -0
- package/cjs/object/everyKey.d.ts +2 -1
- package/cjs/object/everyKey.d.ts.map +1 -0
- package/cjs/object/facade.d.ts +2 -1
- package/cjs/object/facade.d.ts.map +1 -0
- package/cjs/object/filterKey.d.ts +2 -1
- package/cjs/object/filterKey.d.ts.map +1 -0
- package/cjs/object/findKey.d.ts +2 -1
- package/cjs/object/findKey.d.ts.map +1 -0
- package/cjs/object/forEachKey.d.ts +2 -1
- package/cjs/object/forEachKey.d.ts.map +1 -0
- package/cjs/object/getField.d.ts +2 -1
- package/cjs/object/getField.d.ts.map +1 -0
- package/cjs/object/hasKey.d.ts +2 -1
- package/cjs/object/hasKey.d.ts.map +1 -0
- package/cjs/object/hasProperty.d.ts +2 -1
- package/cjs/object/hasProperty.d.ts.map +1 -0
- package/cjs/object/index.d.ts +37 -36
- package/cjs/object/index.d.ts.map +1 -0
- package/cjs/object/index.js +18 -18
- package/cjs/object/index.js.map +1 -1
- package/cjs/object/mapKey.d.ts +2 -1
- package/cjs/object/mapKey.d.ts.map +1 -0
- package/cjs/object/mapProperties.d.ts +3 -2
- package/cjs/object/mapProperties.d.ts.map +1 -0
- package/cjs/object/mapProperties.js +2 -2
- package/cjs/object/mapProperties.js.map +1 -1
- package/cjs/object/omit.d.ts +4 -3
- package/cjs/object/omit.d.ts.map +1 -0
- package/cjs/object/omit.js +2 -2
- package/cjs/object/omit.js.map +1 -1
- package/cjs/object/pick.d.ts +3 -2
- package/cjs/object/pick.d.ts.map +1 -0
- package/cjs/object/pick.js +2 -2
- package/cjs/object/pick.js.map +1 -1
- package/cjs/object/record.d.ts +3 -2
- package/cjs/object/record.d.ts.map +1 -0
- package/cjs/object/record.js +1 -1
- package/cjs/object/record.js.map +1 -1
- package/cjs/object/reduceKey.d.ts +2 -1
- package/cjs/object/reduceKey.d.ts.map +1 -0
- package/cjs/object/replaceProperty.d.ts +2 -1
- package/cjs/object/replaceProperty.d.ts.map +1 -0
- package/cjs/object/someKey.d.ts +2 -1
- package/cjs/object/someKey.d.ts.map +1 -0
- package/cjs/object/split.d.ts +3 -2
- package/cjs/object/split.d.ts.map +1 -0
- package/cjs/object/split.js +3 -3
- package/cjs/object/split.js.map +1 -1
- package/cjs/object/typeOverrideIncompatible.d.ts +2 -1
- package/cjs/object/typeOverrideIncompatible.d.ts.map +1 -0
- package/cjs/predicates/CanAssign.d.ts +3 -2
- package/cjs/predicates/CanAssign.d.ts.map +1 -0
- package/cjs/predicates/Equal.d.ts +1 -0
- package/cjs/predicates/Equal.d.ts.map +1 -0
- package/cjs/predicates/Extends.d.ts +1 -0
- package/cjs/predicates/Extends.d.ts.map +1 -0
- package/cjs/predicates/If.d.ts +1 -0
- package/cjs/predicates/If.d.ts.map +1 -0
- package/cjs/predicates/IsEmptyObject.d.ts +1 -0
- package/cjs/predicates/IsEmptyObject.d.ts.map +1 -0
- package/cjs/predicates/index.d.ts +9 -8
- package/cjs/predicates/index.d.ts.map +1 -0
- package/cjs/predicates/index.js +2 -2
- package/cjs/predicates/index.js.map +1 -1
- package/cjs/predicates/isType.d.ts +3 -2
- package/cjs/predicates/isType.d.ts.map +1 -0
- package/cjs/predicates/isType.js +2 -2
- package/cjs/predicates/isType.js.map +1 -1
- package/cjs/predicates/logical.d.ts +1 -0
- package/cjs/predicates/logical.d.ts.map +1 -0
- package/cjs/promise/PromiseValue.d.ts +1 -0
- package/cjs/promise/PromiseValue.d.ts.map +1 -0
- package/cjs/promise/PromiseValueMerge.d.ts +2 -1
- package/cjs/promise/PromiseValueMerge.d.ts.map +1 -0
- package/cjs/promise/index.d.ts +5 -4
- package/cjs/promise/index.d.ts.map +1 -0
- package/cjs/promise/index.js +2 -2
- package/cjs/promise/index.js.map +1 -1
- package/cjs/promise/isPromise.d.ts +1 -0
- package/cjs/promise/isPromise.d.ts.map +1 -0
- package/cjs/promise/mapSeries.d.ts +1 -0
- package/cjs/promise/mapSeries.d.ts.map +1 -0
- package/cjs/testing/index.d.ts +2 -1
- package/cjs/testing/index.d.ts.map +1 -0
- package/cjs/testing/index.js +1 -1
- package/cjs/testing/index.js.map +1 -1
- package/cjs/testing/stub.d.ts +3 -2
- package/cjs/testing/stub.d.ts.map +1 -0
- package/cjs/utils/NonNull.d.ts +1 -0
- package/cjs/utils/NonNull.d.ts.map +1 -0
- package/cjs/utils/NonUndefined.d.ts +1 -0
- package/cjs/utils/NonUndefined.d.ts.map +1 -0
- package/cjs/utils/Widen.d.ts +1 -0
- package/cjs/utils/Widen.d.ts.map +1 -0
- package/cjs/utils/as.d.ts +1 -0
- package/cjs/utils/as.d.ts.map +1 -0
- package/cjs/utils/index.d.ts +5 -4
- package/cjs/utils/index.d.ts.map +1 -0
- package/cjs/utils/index.js +1 -1
- package/cjs/utils/index.js.map +1 -1
- package/esm/ComposableTypes.d.ts +3 -0
- package/esm/ComposableTypes.d.ts.map +1 -0
- package/esm/JSONTypes.d.ts +12 -0
- package/esm/JSONTypes.d.ts.map +1 -0
- package/esm/JSONTypes.js.map +1 -1
- package/esm/PrimitiveTypes.d.ts +2 -0
- package/esm/PrimitiveTypes.d.ts.map +1 -0
- package/esm/UnionKeys.d.ts +2 -0
- package/esm/UnionKeys.d.ts.map +1 -0
- package/esm/array/CommonPropKeys.d.ts +4 -0
- package/esm/array/CommonPropKeys.d.ts.map +1 -0
- package/esm/array/Concat.d.ts +2 -0
- package/esm/array/Concat.d.ts.map +1 -0
- package/esm/array/CreateTuple.d.ts +3 -0
- package/esm/array/CreateTuple.d.ts.map +1 -0
- package/esm/array/Filter.d.ts +3 -0
- package/esm/array/Filter.d.ts.map +1 -0
- package/esm/array/FindFirst.d.ts +3 -0
- package/esm/array/FindFirst.d.ts.map +1 -0
- package/esm/array/FindLast.d.ts +2 -0
- package/esm/array/FindLast.d.ts.map +1 -0
- package/esm/array/Head.d.ts +2 -0
- package/esm/array/Head.d.ts.map +1 -0
- package/esm/array/IntersectOfProps.d.ts +5 -0
- package/esm/array/IntersectOfProps.d.ts.map +1 -0
- package/esm/array/IsArray.d.ts +2 -0
- package/esm/array/IsArray.d.ts.map +1 -0
- package/esm/array/Last.d.ts +2 -0
- package/esm/array/Last.d.ts.map +1 -0
- package/esm/array/PadLeft.d.ts +5 -0
- package/esm/array/PadLeft.d.ts.map +1 -0
- package/esm/array/Reverse.d.ts +2 -0
- package/esm/array/Reverse.d.ts.map +1 -0
- package/esm/array/Some.d.ts +8 -0
- package/esm/array/Some.d.ts.map +1 -0
- package/esm/array/Tail.d.ts +3 -0
- package/esm/array/Tail.d.ts.map +1 -0
- package/esm/array/UnionOfProps.d.ts +5 -0
- package/esm/array/UnionOfProps.d.ts.map +1 -0
- package/esm/array/UnionOfValues.d.ts +3 -0
- package/esm/array/UnionOfValues.d.ts.map +1 -0
- package/esm/array/drop.d.ts +13 -0
- package/esm/array/drop.d.ts.map +1 -0
- package/esm/array/drop.js.map +1 -1
- package/esm/array/index.d.ts +20 -0
- package/esm/array/index.d.ts.map +1 -0
- package/esm/array/index.js +3 -3
- package/esm/array/index.js.map +1 -1
- package/esm/array/literalArray.d.ts +3 -0
- package/esm/array/literalArray.d.ts.map +1 -0
- package/esm/array/reduceWhile.d.ts +2 -0
- package/esm/array/reduceWhile.d.ts.map +1 -0
- package/esm/assertion/assertType.d.ts +29 -0
- package/esm/assertion/assertType.d.ts.map +1 -0
- package/esm/assertion/assertType.js +1 -1
- package/esm/assertion/assertType.js.map +1 -1
- package/esm/assertion/index.d.ts +2 -0
- package/esm/assertion/index.d.ts.map +1 -0
- package/esm/assertion/index.js +1 -1
- package/esm/assertion/index.js.map +1 -1
- package/esm/class/AnyConstructor.d.ts +2 -0
- package/esm/class/AnyConstructor.d.ts.map +1 -0
- package/esm/class/index.d.ts +3 -0
- package/esm/class/index.d.ts.map +1 -0
- package/esm/class/index.js +1 -1
- package/esm/class/index.js.map +1 -1
- package/esm/class/isConstructor.d.ts +3 -0
- package/esm/class/isConstructor.d.ts.map +1 -0
- package/esm/function/AnyFunction.d.ts +2 -0
- package/esm/function/AnyFunction.d.ts.map +1 -0
- package/esm/function/index.d.ts +2 -0
- package/esm/function/index.d.ts.map +1 -0
- package/esm/functional/ChainFn.d.ts +3 -0
- package/esm/functional/ChainFn.d.ts.map +1 -0
- package/esm/functional/compose.d.ts +4 -0
- package/esm/functional/compose.d.ts.map +1 -0
- package/esm/functional/compose.js.map +1 -1
- package/esm/functional/index.d.ts +3 -0
- package/esm/functional/index.d.ts.map +1 -0
- package/esm/functional/index.js +1 -1
- package/esm/functional/index.js.map +1 -1
- package/esm/index.d.ts +19 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +14 -14
- package/esm/index.js.map +1 -1
- package/esm/math/Abs.d.ts +3 -0
- package/esm/math/Abs.d.ts.map +1 -0
- package/esm/math/Add.d.ts +16 -0
- package/esm/math/Add.d.ts.map +1 -0
- package/esm/math/Digit.d.ts +97 -0
- package/esm/math/Digit.d.ts.map +1 -0
- package/esm/math/GreaterThan.d.ts +12 -0
- package/esm/math/GreaterThan.d.ts.map +1 -0
- package/esm/math/IsPositive.d.ts +2 -0
- package/esm/math/IsPositive.d.ts.map +1 -0
- package/esm/math/IsWhole.d.ts +2 -0
- package/esm/math/IsWhole.d.ts.map +1 -0
- package/esm/math/Max.d.ts +4 -0
- package/esm/math/Max.d.ts.map +1 -0
- package/esm/math/Subtract.d.ts +13 -0
- package/esm/math/Subtract.d.ts.map +1 -0
- package/esm/math/index.d.ts +9 -0
- package/esm/math/index.d.ts.map +1 -0
- package/esm/nodejs/index.d.ts +2 -0
- package/esm/nodejs/index.d.ts.map +1 -0
- package/esm/nodejs/index.js +1 -1
- package/esm/nodejs/index.js.map +1 -1
- package/esm/nodejs/isNodeError.d.ts +26 -0
- package/esm/nodejs/isNodeError.d.ts.map +1 -0
- package/esm/nominal-types/Brand.d.ts +11 -0
- package/esm/nominal-types/Brand.d.ts.map +1 -0
- package/esm/nominal-types/Brand.js +1 -1
- package/esm/nominal-types/Brand.js.map +1 -1
- package/esm/nominal-types/Flavor.d.ts +8 -0
- package/esm/nominal-types/Flavor.d.ts.map +1 -0
- package/esm/nominal-types/Flavor.js +1 -1
- package/esm/nominal-types/Flavor.js.map +1 -1
- package/esm/nominal-types/index.d.ts +4 -0
- package/esm/nominal-types/index.d.ts.map +1 -0
- package/esm/nominal-types/index.js +3 -3
- package/esm/nominal-types/index.js.map +1 -1
- package/esm/nominal-types/nominalMatch.d.ts +5 -0
- package/esm/nominal-types/nominalMatch.d.ts.map +1 -0
- package/esm/nominal-types/nominalMatch.js +1 -1
- package/esm/nominal-types/nominalMatch.js.map +1 -1
- package/esm/nominal-types/types.d.ts +3 -0
- package/esm/nominal-types/types.d.ts.map +1 -0
- package/esm/object/ANotB.d.ts +14 -0
- package/esm/object/ANotB.d.ts.map +1 -0
- package/esm/object/AnyRecord.d.ts +2 -0
- package/esm/object/AnyRecord.d.ts.map +1 -0
- package/esm/object/ExcludePropType.d.ts +4 -0
- package/esm/object/ExcludePropType.d.ts.map +1 -0
- package/esm/object/IsDisjoint.d.ts +5 -0
- package/esm/object/IsDisjoint.d.ts.map +1 -0
- package/esm/object/IsRecord.d.ts +2 -0
- package/esm/object/IsRecord.d.ts.map +1 -0
- package/esm/object/KeyTypes.d.ts +2 -0
- package/esm/object/KeyTypes.d.ts.map +1 -0
- package/esm/object/KeyofOptional.d.ts +3 -0
- package/esm/object/KeyofOptional.d.ts.map +1 -0
- package/esm/object/KeysWithDiffType.d.ts +7 -0
- package/esm/object/KeysWithDiffType.d.ts.map +1 -0
- package/esm/object/KnownKeys.d.ts +7 -0
- package/esm/object/KnownKeys.d.ts.map +1 -0
- package/esm/object/OptionalKeys.d.ts +8 -0
- package/esm/object/OptionalKeys.d.ts.map +1 -0
- package/esm/object/Partial.d.ts +7 -0
- package/esm/object/Partial.d.ts.map +1 -0
- package/esm/object/RecursiveIntersect.d.ts +5 -0
- package/esm/object/RecursiveIntersect.d.ts.map +1 -0
- package/esm/object/RecursivePartial.d.ts +5 -0
- package/esm/object/RecursivePartial.d.ts.map +1 -0
- package/esm/object/RecursiveRequired.d.ts +5 -0
- package/esm/object/RecursiveRequired.d.ts.map +1 -0
- package/esm/object/Required.d.ts +3 -0
- package/esm/object/Required.d.ts.map +1 -0
- package/esm/object/RequiredKeys.d.ts +7 -0
- package/esm/object/RequiredKeys.d.ts.map +1 -0
- package/esm/object/SpreadRecord.d.ts +3 -0
- package/esm/object/SpreadRecord.d.ts.map +1 -0
- package/esm/object/ValueOf.d.ts +2 -0
- package/esm/object/ValueOf.d.ts.map +1 -0
- package/esm/object/everyKey.d.ts +3 -0
- package/esm/object/everyKey.d.ts.map +1 -0
- package/esm/object/facade.d.ts +14 -0
- package/esm/object/facade.d.ts.map +1 -0
- package/esm/object/filterKey.d.ts +3 -0
- package/esm/object/filterKey.d.ts.map +1 -0
- package/esm/object/findKey.d.ts +3 -0
- package/esm/object/findKey.d.ts.map +1 -0
- package/esm/object/forEachKey.d.ts +3 -0
- package/esm/object/forEachKey.d.ts.map +1 -0
- package/esm/object/getField.d.ts +4 -0
- package/esm/object/getField.d.ts.map +1 -0
- package/esm/object/hasKey.d.ts +4 -0
- package/esm/object/hasKey.d.ts.map +1 -0
- package/esm/object/hasProperty.d.ts +3 -0
- package/esm/object/hasProperty.d.ts.map +1 -0
- package/esm/object/index.d.ts +37 -0
- package/esm/object/index.d.ts.map +1 -0
- package/esm/object/index.js +18 -18
- package/esm/object/index.js.map +1 -1
- package/esm/object/mapKey.d.ts +3 -0
- package/esm/object/mapKey.d.ts.map +1 -0
- package/esm/object/mapProperties.d.ts +6 -0
- package/esm/object/mapProperties.d.ts.map +1 -0
- package/esm/object/mapProperties.js +1 -1
- package/esm/object/mapProperties.js.map +1 -1
- package/esm/object/omit.d.ts +18 -0
- package/esm/object/omit.d.ts.map +1 -0
- package/esm/object/omit.js +1 -1
- package/esm/object/omit.js.map +1 -1
- package/esm/object/pick.d.ts +21 -0
- package/esm/object/pick.d.ts.map +1 -0
- package/esm/object/pick.js +1 -1
- package/esm/object/pick.js.map +1 -1
- package/esm/object/record.d.ts +4 -0
- package/esm/object/record.d.ts.map +1 -0
- package/esm/object/record.js +1 -1
- package/esm/object/record.js.map +1 -1
- package/esm/object/reduceKey.d.ts +4 -0
- package/esm/object/reduceKey.d.ts.map +1 -0
- package/esm/object/replaceProperty.d.ts +6 -0
- package/esm/object/replaceProperty.d.ts.map +1 -0
- package/esm/object/someKey.d.ts +3 -0
- package/esm/object/someKey.d.ts.map +1 -0
- package/esm/object/split.d.ts +82 -0
- package/esm/object/split.d.ts.map +1 -0
- package/esm/object/split.js +1 -1
- package/esm/object/split.js.map +1 -1
- package/esm/object/typeOverrideIncompatible.d.ts +3 -0
- package/esm/object/typeOverrideIncompatible.d.ts.map +1 -0
- package/esm/predicates/CanAssign.d.ts +7 -0
- package/esm/predicates/CanAssign.d.ts.map +1 -0
- package/esm/predicates/Equal.d.ts +5 -0
- package/esm/predicates/Equal.d.ts.map +1 -0
- package/esm/predicates/Extends.d.ts +5 -0
- package/esm/predicates/Extends.d.ts.map +1 -0
- package/esm/predicates/If.d.ts +2 -0
- package/esm/predicates/If.d.ts.map +1 -0
- package/esm/predicates/IsEmptyObject.d.ts +2 -0
- package/esm/predicates/IsEmptyObject.d.ts.map +1 -0
- package/esm/predicates/index.d.ts +12 -0
- package/esm/predicates/index.d.ts.map +1 -0
- package/esm/predicates/index.js +2 -2
- package/esm/predicates/index.js.map +1 -1
- package/esm/predicates/isType.d.ts +11 -0
- package/esm/predicates/isType.d.ts.map +1 -0
- package/esm/predicates/isType.js +1 -1
- package/esm/predicates/isType.js.map +1 -1
- package/esm/predicates/logical.d.ts +5 -0
- package/esm/predicates/logical.d.ts.map +1 -0
- package/esm/promise/PromiseValue.d.ts +2 -0
- package/esm/promise/PromiseValue.d.ts.map +1 -0
- package/esm/promise/PromiseValueMerge.d.ts +3 -0
- package/esm/promise/PromiseValueMerge.d.ts.map +1 -0
- package/esm/promise/index.d.ts +5 -0
- package/esm/promise/index.d.ts.map +1 -0
- package/esm/promise/index.js +2 -2
- package/esm/promise/index.js.map +1 -1
- package/esm/promise/isPromise.d.ts +2 -0
- package/esm/promise/isPromise.d.ts.map +1 -0
- package/esm/promise/mapSeries.d.ts +2 -0
- package/esm/promise/mapSeries.d.ts.map +1 -0
- package/esm/testing/index.d.ts +2 -0
- package/esm/testing/index.d.ts.map +1 -0
- package/esm/testing/index.js +1 -1
- package/esm/testing/index.js.map +1 -1
- package/esm/testing/stub.d.ts +10 -0
- package/esm/testing/stub.d.ts.map +1 -0
- package/esm/utils/NonNull.d.ts +2 -0
- package/esm/utils/NonNull.d.ts.map +1 -0
- package/esm/utils/NonUndefined.d.ts +2 -0
- package/esm/utils/NonUndefined.d.ts.map +1 -0
- package/esm/utils/Widen.d.ts +2 -0
- package/esm/utils/Widen.d.ts.map +1 -0
- package/esm/utils/as.d.ts +7 -0
- package/esm/utils/as.d.ts.map +1 -0
- package/esm/utils/index.d.ts +5 -0
- package/esm/utils/index.d.ts.map +1 -0
- package/esm/utils/index.js +1 -1
- package/esm/utils/index.js.map +1 -1
- package/package.json +47 -42
- package/ts/JSONTypes.ts +17 -18
- package/ts/array/CommonPropKeys.ts +18 -18
- package/ts/array/CreateTuple.ts +1 -1
- package/ts/array/IntersectOfProps.ts +20 -20
- package/ts/array/PadLeft.ts +3 -3
- package/ts/array/Some.ts +3 -3
- package/ts/array/Tail.ts +1 -1
- package/ts/array/UnionOfProps.ts +18 -18
- package/ts/array/drop.ts +3 -3
- package/ts/array/index.ts +19 -19
- package/ts/array/literalArray.ts +1 -1
- package/ts/assertion/assertType.ts +105 -105
- package/ts/assertion/index.ts +1 -1
- package/ts/binary/_binary.ts +1 -1
- package/ts/binary/index.ts +2 -2
- package/ts/class/index.ts +2 -2
- package/ts/class/isConstructor.ts +1 -1
- package/ts/function/index.ts +1 -1
- package/ts/functional/Maybe.ts +19 -19
- package/ts/functional/compose.ts +4 -3
- package/ts/functional/index.ts +3 -3
- package/ts/index.ts +19 -19
- package/ts/math/Abs.ts +1 -1
- package/ts/math/Add.ts +6 -6
- package/ts/math/Digit.ts +6 -4
- package/ts/math/GreaterThan.ts +16 -17
- package/ts/math/Max.ts +6 -30
- package/ts/math/Subtract.ts +6 -6
- package/ts/math/index.ts +8 -8
- package/ts/nodejs/index.ts +1 -1
- package/ts/nominal-types/Brand.ts +2 -2
- package/ts/nominal-types/Flavor.ts +32 -32
- package/ts/nominal-types/index.ts +3 -3
- package/ts/nominal-types/nominalMatch.ts +3 -3
- package/ts/object/ANotB.ts +21 -21
- package/ts/object/IsDisjoint.ts +12 -12
- package/ts/object/KeysWithDiffType.ts +3 -3
- package/ts/object/KnownKeys.ts +1 -1
- package/ts/object/OptionalKeys.ts +1 -1
- package/ts/object/Partial.ts +3 -3
- package/ts/object/RecursiveIntersect.ts +1 -1
- package/ts/object/RecursivePartial.ts +1 -1
- package/ts/object/RecursiveRequired.ts +1 -1
- package/ts/object/RequiredKeys.ts +2 -2
- package/ts/object/SpreadRecord.ts +6 -6
- package/ts/object/everyKey.ts +1 -1
- package/ts/object/facade.ts +39 -39
- package/ts/object/filterKey.ts +1 -1
- package/ts/object/findKey.ts +1 -1
- package/ts/object/forEachKey.ts +1 -1
- package/ts/object/getField.ts +1 -1
- package/ts/object/hasKey.ts +7 -7
- package/ts/object/hasProperty.ts +1 -1
- package/ts/object/index.ts +36 -36
- package/ts/object/mapKey.ts +1 -1
- package/ts/object/mapProperties.ts +3 -3
- package/ts/object/omit.ts +36 -36
- package/ts/object/pick.ts +35 -35
- package/ts/object/record.ts +5 -4
- package/ts/object/reduceKey.ts +1 -1
- package/ts/object/replaceProperty.ts +1 -1
- package/ts/object/someKey.ts +1 -1
- package/ts/object/split.ts +5 -4
- package/ts/object/typeOverrideIncompatible.ts +10 -10
- package/ts/predicates/CanAssign.ts +2 -2
- package/ts/predicates/index.ts +8 -8
- package/ts/predicates/isType.ts +30 -30
- package/ts/promise/PromiseValueMerge.ts +1 -1
- package/ts/promise/index.ts +4 -4
- package/ts/testing/index.ts +1 -1
- package/ts/testing/stub.ts +2 -2
- package/ts/utils/index.ts +4 -4
- package/ts/ComposableTypes.spec.ts +0 -29
- package/ts/JSONTypes.spec.ts +0 -43
- package/ts/array/CommonPropKeys.spec.ts +0 -20
- package/ts/array/Concat.spec.ts +0 -21
- package/ts/array/CreateTuple.spec.ts +0 -46
- package/ts/array/DropFirst.spec.ts +0 -21
- package/ts/array/DropLast.spec.ts +0 -21
- package/ts/array/DropMatch.spec.ts +0 -234
- package/ts/array/Filter.spec.ts +0 -107
- package/ts/array/FindFirst.spec.ts +0 -27
- package/ts/array/FindLast.spec.ts +0 -27
- package/ts/array/Head.spec.ts +0 -21
- package/ts/array/IntersectOfProps.spec.ts +0 -14
- package/ts/array/Last.spec.ts +0 -32
- package/ts/array/PadLeft.spec.ts +0 -26
- package/ts/array/Reverse.spec.ts +0 -17
- package/ts/array/Some.spec.ts +0 -79
- package/ts/array/Tail.spec.ts +0 -32
- package/ts/array/UnionOfProps.spec.ts +0 -14
- package/ts/array/UnionOfValues.spec.ts +0 -11
- package/ts/array/literalArray.spec.ts +0 -7
- package/ts/array/reduceWhile.spec.ts +0 -27
- package/ts/assertion/assertType.spec.ts +0 -507
- package/ts/binary/index.spec.ts +0 -28
- package/ts/class/AnyConstructor.spec.ts +0 -13
- package/ts/class/isConstructor.spec.ts +0 -35
- package/ts/function/AnyFunction.spec.ts +0 -21
- package/ts/functional/ChainFn.spec.ts +0 -7
- package/ts/functional/Maybe.spec.ts +0 -42
- package/ts/functional/compose.spec.ts +0 -32
- package/ts/index.spec.ts +0 -7
- package/ts/math/Abs.spec.ts +0 -14
- package/ts/math/Add.spec.ts +0 -82
- package/ts/math/Digit.spec.ts +0 -184
- package/ts/math/GreaterThan.spec.ts +0 -43
- package/ts/math/IsPositive.spec.ts +0 -15
- package/ts/math/IsWhole.spec.ts +0 -19
- package/ts/math/Max.spec.ts +0 -35
- package/ts/math/Subtract.spec.ts +0 -40
- package/ts/nodejs/isNodeError.spec.ts +0 -11
- package/ts/nominal-types/Brand.spec.ts +0 -43
- package/ts/nominal-types/Flavor.spec.ts +0 -51
- package/ts/nominal-types/nominalMatch.spec.ts +0 -54
- package/ts/object/ANotB.spec.ts +0 -78
- package/ts/object/ExcludePropType.spec.ts +0 -13
- package/ts/object/IsDisjoint.spec.ts +0 -25
- package/ts/object/IsRecord.spec.ts +0 -22
- package/ts/object/KeyTypes.spec.ts +0 -9
- package/ts/object/KeyofOptional.spec.ts +0 -8
- package/ts/object/KeysWithDiffType.spec.ts +0 -21
- package/ts/object/KnownKeys.spec.ts +0 -39
- package/ts/object/OptionalKeys.spec.ts +0 -23
- package/ts/object/Partial.spec.ts +0 -49
- package/ts/object/RecursiveIntersect.spec.ts +0 -39
- package/ts/object/RecursiveRequired.spec.ts +0 -57
- package/ts/object/Required.spec.ts +0 -29
- package/ts/object/RequiredKeys.spec.ts +0 -24
- package/ts/object/SpreadRecord.spec.ts +0 -14
- package/ts/object/ValueOf.spec.ts +0 -36
- package/ts/object/everyKey.spec.ts +0 -11
- package/ts/object/facade.spec.ts +0 -22
- package/ts/object/filterKey.spec.ts +0 -8
- package/ts/object/findKey.spec.ts +0 -8
- package/ts/object/forEachKey.spec.ts +0 -9
- package/ts/object/getField.spec.ts +0 -21
- package/ts/object/hasKey.spec.ts +0 -29
- package/ts/object/hasProperty.spec.ts +0 -15
- package/ts/object/mapKey.spec.ts +0 -8
- package/ts/object/mapProperties.spec.ts +0 -27
- package/ts/object/omit.spec.ts +0 -104
- package/ts/object/pick.spec.ts +0 -66
- package/ts/object/record.spec.ts +0 -54
- package/ts/object/reduceKey.spec.ts +0 -18
- package/ts/object/replaceProperty.spec.ts +0 -16
- package/ts/object/run.ts +0 -0
- package/ts/object/someKey.spec.ts +0 -6
- package/ts/object/split.spec.ts +0 -119
- package/ts/object/typeOverrideIncompatible.spec.ts +0 -24
- package/ts/predicates/CanAssign.spec.ts +0 -57
- package/ts/predicates/Equal.spec.ts +0 -71
- package/ts/predicates/If.spec.ts +0 -14
- package/ts/predicates/IsEmptyObject.spec.ts +0 -15
- package/ts/predicates/index.spec.ts +0 -73
- package/ts/predicates/isType.spec.ts +0 -106
- package/ts/predicates/logical.spec.ts +0 -59
- package/ts/promise/PromiseValue.spec.ts +0 -6
- package/ts/promise/PromiseValueMerge.spec.ts +0 -7
- package/ts/promise/isPromise.spec.ts +0 -26
- package/ts/promise/mapSeries.spec.ts +0 -12
- package/ts/testing/stub.spec.ts +0 -58
- package/ts/type-checker/.eslintrc.json +0 -5
- package/ts/type-checker/AnyType.ts +0 -13
- package/ts/type-checker/Boolean.ts +0 -34
- package/ts/type-checker/Tuple.spec.ts +0 -15
- package/ts/type-checker/Tuple.ts +0 -14
- package/ts/type-checker/buildTypes.spec.ts +0 -28
- package/ts/type-checker/index.ts +0 -0
- package/ts/type-checker/typeChecker.spec.ts +0 -14
- package/ts/type-checker/typeChecker.ts +0 -52
- package/ts/type-checker/types.ts +0 -19
- package/ts/types/.eslintrc.json +0 -5
- package/ts/types/AllType.ts +0 -31
- package/ts/types/Any.ts +0 -7
- package/ts/types/Array.ts +0 -43
- package/ts/types/BigInt.ts +0 -36
- package/ts/types/Boolean.ts +0 -36
- package/ts/types/Generate.ts +0 -48
- package/ts/types/Null.ts +0 -14
- package/ts/types/Number.ts +0 -56
- package/ts/types/Object.ts +0 -53
- package/ts/types/Record.ts +0 -25
- package/ts/types/String.ts +0 -56
- package/ts/types/Symbol.ts +0 -19
- package/ts/types/Tuple.ts +0 -50
- package/ts/types/Undefined.ts +0 -8
- package/ts/types/Union.ts +0 -46
- package/ts/types/Unknown.ts +0 -9
- package/ts/types/analyze.spec.ts +0 -979
- package/ts/types/analyze.ts +0 -170
- package/ts/types/check.spec.ts +0 -12
- package/ts/types/check.ts +0 -26
- package/ts/types/conform.spec.ts +0 -7
- package/ts/types/conform.ts +0 -27
- package/ts/types/getPlainAnalysisReport.spec.ts +0 -354
- package/ts/types/getPlainAnalysisReport.ts +0 -115
- package/ts/types/index.ts +0 -28
- package/ts/types/optional.ts +0 -30
- package/ts/types/required.ts +0 -30
- package/ts/types/satisfy.accept.ts +0 -39
- package/ts/types/satisfy.spec.ts +0 -600
- package/ts/types/satisfy.ts +0 -27
- package/ts/types/types.ts +0 -10
- package/ts/utils/as.spec.ts +0 -45
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { assertType, Equal, isType } from '..'
|
|
2
|
-
|
|
3
|
-
describe('isType()', () => {
|
|
4
|
-
describe('without validator', () => {
|
|
5
|
-
test('subject type is checked at compile time', () => {
|
|
6
|
-
const subject = { a: 1, b: 2 } as const
|
|
7
|
-
if (isType<{ a: 1 }>(subject)) {
|
|
8
|
-
assertType<{ a: 1 }>(subject)
|
|
9
|
-
}
|
|
10
|
-
})
|
|
11
|
-
test('work with falsy value such as empty string', () => {
|
|
12
|
-
const s = ''
|
|
13
|
-
if (isType<''>(s)) {
|
|
14
|
-
assertType<''>(s)
|
|
15
|
-
}
|
|
16
|
-
})
|
|
17
|
-
})
|
|
18
|
-
describe('with validator function', () => {
|
|
19
|
-
test('Specify T in the validate function', () => {
|
|
20
|
-
const s: unknown = false
|
|
21
|
-
if (isType(s, (s: boolean) => typeof s === 'boolean'))
|
|
22
|
-
assertType<boolean>(s)
|
|
23
|
-
})
|
|
24
|
-
test('Specify T at type declaration', () => {
|
|
25
|
-
const s: unknown = false
|
|
26
|
-
if (isType<boolean>(s, s => typeof s === 'boolean'))
|
|
27
|
-
assertType<boolean>(s)
|
|
28
|
-
})
|
|
29
|
-
test('exclude type if type guard fails', () => {
|
|
30
|
-
const s: string | number = 1
|
|
31
|
-
if (isType<string>(s, s => typeof s === 'string')) {
|
|
32
|
-
assertType<string>(s)
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
assertType<number>(s)
|
|
36
|
-
}
|
|
37
|
-
})
|
|
38
|
-
})
|
|
39
|
-
describe('with class', () => {
|
|
40
|
-
test('Class as validator', () => {
|
|
41
|
-
const s: unknown = new Error()
|
|
42
|
-
if (isType(s, Error))
|
|
43
|
-
assertType<Error>(s)
|
|
44
|
-
})
|
|
45
|
-
test('Class as validator fails', () => {
|
|
46
|
-
class Foo { a() { } }
|
|
47
|
-
const s: Foo | number = 1
|
|
48
|
-
if (isType(s, Foo)) {
|
|
49
|
-
assertType<Foo>(s)
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
assertType<number>(s)
|
|
53
|
-
}
|
|
54
|
-
})
|
|
55
|
-
test('subject can be type any', () => {
|
|
56
|
-
const s: any = false
|
|
57
|
-
if (isType<boolean>(s, s => typeof s === 'boolean'))
|
|
58
|
-
assertType<boolean>(s)
|
|
59
|
-
})
|
|
60
|
-
})
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
describe('isType.t()', () => {
|
|
64
|
-
test('accept true type but not false or boolean', () => {
|
|
65
|
-
expect(isType.t<true>()).toBe(true)
|
|
66
|
-
expect(isType.t<Equal<1, 1>>()).toBe(true)
|
|
67
|
-
|
|
68
|
-
// these fails
|
|
69
|
-
// isType.t<false>()
|
|
70
|
-
// isType.t<boolean>()
|
|
71
|
-
})
|
|
72
|
-
test('accept value with type true but not false or boolean', () => {
|
|
73
|
-
expect(isType.t(true)).toBe(true)
|
|
74
|
-
|
|
75
|
-
// these fails
|
|
76
|
-
// isType.t(false)
|
|
77
|
-
// isType.t(1 === 1)
|
|
78
|
-
})
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
describe('isType.f()', () => {
|
|
82
|
-
test('accept false type but not true or boolean', () => {
|
|
83
|
-
expect(isType.f<false>()).toBe(true)
|
|
84
|
-
expect(isType.f<Equal<1, 2>>()).toBe(true)
|
|
85
|
-
|
|
86
|
-
// these fails
|
|
87
|
-
// isType.f<true>()
|
|
88
|
-
// isType.f<boolean>()
|
|
89
|
-
})
|
|
90
|
-
test('accept value with type true but not false or boolean', () => {
|
|
91
|
-
expect(isType.f(false)).toBe(true)
|
|
92
|
-
|
|
93
|
-
// these fails
|
|
94
|
-
// isType.f(true)
|
|
95
|
-
// isType.f(1 !== 1)
|
|
96
|
-
})
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
describe('isType.equal()', () => {
|
|
100
|
-
test('true case', () => {
|
|
101
|
-
isType.equal<true, 1, 1>()
|
|
102
|
-
})
|
|
103
|
-
test('false case', () => {
|
|
104
|
-
isType.equal<false, '1', 1>()
|
|
105
|
-
})
|
|
106
|
-
})
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { And, assertType, Equal, Not, Or, Xor } from '..'
|
|
2
|
-
|
|
3
|
-
describe('And<A,B>', () => {
|
|
4
|
-
test('basic', () => {
|
|
5
|
-
assertType.isTrue(true as And<true, true>)
|
|
6
|
-
assertType.isFalse(false as And<true, false>)
|
|
7
|
-
assertType.isFalse(false as And<false, true>)
|
|
8
|
-
assertType.isFalse(false as And<false, false>)
|
|
9
|
-
})
|
|
10
|
-
test('boolean special handling', () => {
|
|
11
|
-
assertType.isTrue(true as Equal<And<boolean, true>, boolean>)
|
|
12
|
-
assertType.isFalse(false as And<boolean, false>)
|
|
13
|
-
assertType.isTrue(true as Equal<And<true, boolean>, boolean>)
|
|
14
|
-
assertType.isFalse(false as And<false, boolean>)
|
|
15
|
-
assertType.isTrue(true as Equal<And<boolean, boolean>, boolean>)
|
|
16
|
-
})
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
describe('Or<A,B>', () => {
|
|
20
|
-
test('basic', () => {
|
|
21
|
-
assertType.isTrue(true as Or<true, true>)
|
|
22
|
-
assertType.isTrue(true as Or<true, false>)
|
|
23
|
-
assertType.isTrue(true as Or<false, true>)
|
|
24
|
-
assertType.isFalse(false as Or<false, false>)
|
|
25
|
-
})
|
|
26
|
-
test('boolean special handling', () => {
|
|
27
|
-
assertType.isTrue(true as Or<boolean, true>)
|
|
28
|
-
assertType.isTrue(true as Equal<Or<boolean, false>, boolean>)
|
|
29
|
-
assertType.isTrue(true as Or<true, boolean>)
|
|
30
|
-
assertType.isTrue(true as Equal<Or<false, boolean>, boolean>)
|
|
31
|
-
assertType.isTrue(true as Equal<Or<boolean, boolean>, boolean>)
|
|
32
|
-
})
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
describe('Xor<A,B>', () => {
|
|
36
|
-
test('basic', () => {
|
|
37
|
-
assertType.isFalse(false as Xor<true, true>)
|
|
38
|
-
assertType.isTrue(true as Xor<true, false>)
|
|
39
|
-
assertType.isTrue(true as Xor<false, true>)
|
|
40
|
-
assertType.isFalse(false as Xor<false, false>)
|
|
41
|
-
})
|
|
42
|
-
test('boolean special handling', () => {
|
|
43
|
-
assertType.isTrue(true as Equal<Xor<boolean, true>, boolean>)
|
|
44
|
-
assertType.isTrue(true as Equal<Xor<boolean, false>, boolean>)
|
|
45
|
-
assertType.isTrue(true as Equal<Xor<true, boolean>, boolean>)
|
|
46
|
-
assertType.isTrue(true as Equal<Xor<false, boolean>, boolean>)
|
|
47
|
-
assertType.isTrue(true as Equal<Xor<boolean, boolean>, boolean>)
|
|
48
|
-
})
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
describe('Not<X>', () => {
|
|
52
|
-
test('basic', () => {
|
|
53
|
-
assertType.isTrue(true as Not<false>)
|
|
54
|
-
assertType.isFalse(false as Not<true>)
|
|
55
|
-
})
|
|
56
|
-
test('boolean special handling', () => {
|
|
57
|
-
assertType.isTrue(true as Equal<Not<boolean>, boolean>)
|
|
58
|
-
})
|
|
59
|
-
})
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import t from 'assert'
|
|
2
|
-
import { isPromise } from '..'
|
|
3
|
-
|
|
4
|
-
test('false if subject is falsy value or non-object', () => {
|
|
5
|
-
t.strictEqual(isPromise(undefined), false)
|
|
6
|
-
t.strictEqual(isPromise(null), false)
|
|
7
|
-
t.strictEqual(isPromise(0), false)
|
|
8
|
-
t.strictEqual(isPromise(true), false)
|
|
9
|
-
t.strictEqual(isPromise('a'), false)
|
|
10
|
-
t.strictEqual(isPromise([]), false)
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
test('false if subject does not have a then function', () => {
|
|
14
|
-
t.strictEqual(isPromise({}), false)
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
test('false if subject.then is not a function', () => {
|
|
18
|
-
t.strictEqual(isPromise({ then: true }), false)
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
test('type guard as promise', () => {
|
|
22
|
-
const subject = { then() { return true } }
|
|
23
|
-
if (isPromise(subject)) {
|
|
24
|
-
t.strictEqual(subject.then(), true)
|
|
25
|
-
}
|
|
26
|
-
})
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { mapSeries } from '..'
|
|
2
|
-
|
|
3
|
-
test('map over values', () => {
|
|
4
|
-
const values = [3, 2, 1]
|
|
5
|
-
let actual = ''
|
|
6
|
-
|
|
7
|
-
return mapSeries(values, v => new Promise<string>(a => setTimeout(() => a(actual += v), v * 10)))
|
|
8
|
-
.then(result => {
|
|
9
|
-
expect(actual).toBe('321')
|
|
10
|
-
expect(result).toEqual(['3', '32', '321'])
|
|
11
|
-
})
|
|
12
|
-
})
|
package/ts/testing/stub.spec.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { isType, stub } from '..'
|
|
2
|
-
|
|
3
|
-
describe('stub()', () => {
|
|
4
|
-
test('stub is a partial of the actual object', () => {
|
|
5
|
-
const real = { a: 1, b: { c: 2 }, d: 3 }
|
|
6
|
-
|
|
7
|
-
const a = stub<typeof real>({ a: 2 })
|
|
8
|
-
expect(a.a).toBe(2)
|
|
9
|
-
isType.equal<true, typeof a, typeof real>()
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
test('stub function retains param types', () => {
|
|
13
|
-
function real(a: string, b: number): boolean { return a === String(b) }
|
|
14
|
-
|
|
15
|
-
const a = stub<typeof real>((_a, _b) => {
|
|
16
|
-
isType.equal<true, string, typeof _a>()
|
|
17
|
-
isType.equal<true, number, typeof _b>()
|
|
18
|
-
return false
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
expect(a('1', 1)).toBe(false)
|
|
22
|
-
isType.equal<true, typeof a, typeof real>()
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
test('stub function params can be omitted', () => {
|
|
26
|
-
function real(a: string, b: number): boolean { return a === String(b) }
|
|
27
|
-
|
|
28
|
-
const a = stub<typeof real>(() => false)
|
|
29
|
-
|
|
30
|
-
expect(a('1', 1)).toBe(false)
|
|
31
|
-
isType.equal<true, typeof a, typeof real>()
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
test('stub input can be omitted', () => {
|
|
35
|
-
const real = { a: 1, b: { c: 2 }, d: 3 }
|
|
36
|
-
|
|
37
|
-
const a = stub<typeof real>()
|
|
38
|
-
isType.equal<true, typeof a, typeof real>()
|
|
39
|
-
})
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
describe('stub.build()', () => {
|
|
43
|
-
test('build a stub function', () => {
|
|
44
|
-
const real = { a: 1, b: { c: 2 }, d: 3 }
|
|
45
|
-
|
|
46
|
-
const s = stub.build<typeof real>()
|
|
47
|
-
const a = s({ a: 2 })
|
|
48
|
-
expect(a.a).toBe(2)
|
|
49
|
-
isType.equal<true, typeof a, typeof real>()
|
|
50
|
-
})
|
|
51
|
-
test('can define init value', () => {
|
|
52
|
-
type S = { a: number, b: string }
|
|
53
|
-
const s = stub.build<S>({ b: 'b' })
|
|
54
|
-
const a = s({ a: 1 })
|
|
55
|
-
expect(a).toEqual({ a: 1, b: 'b' })
|
|
56
|
-
isType.equal<true, S, typeof a>()
|
|
57
|
-
})
|
|
58
|
-
})
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { TypeAnalysis, Type, TypeSpec } from './types'
|
|
2
|
-
|
|
3
|
-
export type Any = Type<'any', undefined>
|
|
4
|
-
export namespace Any {
|
|
5
|
-
export type Analysis = TypeAnalysis<'any'>
|
|
6
|
-
}
|
|
7
|
-
export const any: Any = { type: 'any', value: undefined }
|
|
8
|
-
|
|
9
|
-
export const anySpec: TypeSpec<Any> = {
|
|
10
|
-
type: any,
|
|
11
|
-
toAnalysis: (options, value, _subject) => ({ type: 'any', value }),
|
|
12
|
-
toNative: (value) => value
|
|
13
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Type, TypeSpec } from './types'
|
|
2
|
-
|
|
3
|
-
export type Boolean<Value extends boolean = boolean> = Type<'boolean', Value>
|
|
4
|
-
export namespace Boolean {
|
|
5
|
-
export type Analysis = { type: 'boolean', value?: boolean, fail?: true }
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export type True = Boolean<true>
|
|
9
|
-
export type False = Boolean<false>
|
|
10
|
-
|
|
11
|
-
function create<Value extends boolean>(value: Value): Boolean<Value> {
|
|
12
|
-
return { type: 'boolean', value }
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const any = create(undefined as unknown as boolean)
|
|
16
|
-
|
|
17
|
-
// export const booleanSpec: TypeSpec<'boolean', boolean, boolean> = {
|
|
18
|
-
// type: any,
|
|
19
|
-
// toAnalysis: <Type extends Boolean>({ type, value }: Type) => ({ type, value }),
|
|
20
|
-
// toNative: <Value extends boolean>(value: Value) => value
|
|
21
|
-
// }
|
|
22
|
-
|
|
23
|
-
export const BooleanSpec: TypeSpec<Type<'boolean', boolean>> = {
|
|
24
|
-
type: any,
|
|
25
|
-
toAnalysis(_options, value, actual) {
|
|
26
|
-
if (value === undefined) {
|
|
27
|
-
return typeof actual === 'boolean' ? { type: 'boolean', value } : { type: 'boolean', value, fail: true }
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
return value === actual ? { type: 'boolean', value } : { type: 'boolean', value, fail: true }
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
toNative(value: any): true { return value as any }
|
|
34
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { assertType } from '../assertion'
|
|
2
|
-
import { Tuple } from './Tuple'
|
|
3
|
-
|
|
4
|
-
describe('Find<T,S>', () => {
|
|
5
|
-
test('[] returns never', () => {
|
|
6
|
-
assertType<Tuple.FindByProp<[], 'key', string>>(0 as never)
|
|
7
|
-
})
|
|
8
|
-
test('[num], num returns num', () => {
|
|
9
|
-
assertType<Tuple.FindByProp<[{ key: number }], 'key', number>>({ key: 1 })
|
|
10
|
-
})
|
|
11
|
-
test('[num,str] str returns str', () => {
|
|
12
|
-
type Values = [{ type: 'a' }, { type: 'b' }, { type: 'c' }]
|
|
13
|
-
assertType<Tuple.FindByProp<Values, 'type', 'c'>>({ type: 'c' })
|
|
14
|
-
})
|
|
15
|
-
})
|
package/ts/type-checker/Tuple.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
export namespace Tuple {
|
|
3
|
-
export type Head<T extends any[]> = T['length'] extends 0 ? never : T[0]
|
|
4
|
-
export type Tail<T extends any[]> = T['length'] extends 0 ? never :
|
|
5
|
-
T extends [any, ...infer Tail] ? Tail : T
|
|
6
|
-
|
|
7
|
-
export type FindByProp<Tuple extends Array<{ [K in Key]: any }>, Key extends string, Value> = FindByProp._FindByProp<Tuple, Key, Value>['result']
|
|
8
|
-
|
|
9
|
-
export namespace FindByProp {
|
|
10
|
-
export type _FindByProp<Tuple extends Array<{ [K in Key]: any }>, Key extends string, Value> = Tuple['length'] extends 0
|
|
11
|
-
? { result: never }
|
|
12
|
-
: { result: Value extends Tuple[0][Key] ? Tuple[0] : _FindByProp<Tail<Tuple>, Key, Value>['result'] }
|
|
13
|
-
}
|
|
14
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// import { MapToProp } from '../array'
|
|
2
|
-
// import { assertType } from '../assertion'
|
|
3
|
-
// import * as T from '../types'
|
|
4
|
-
// import { Checker } from './types'
|
|
5
|
-
|
|
6
|
-
// export function buildTypes<Checkers extends Checker[]>(...checkers: Checkers) {
|
|
7
|
-
// const types = checkers.map(c => c.type).reduce((p, t) => ({ ...p, ...t }), {})
|
|
8
|
-
// types.satisfy = (type: any, subject: unknown) => true
|
|
9
|
-
// return types as unknown as MapToProp<Checkers, 'type'> & {
|
|
10
|
-
// satisfy<T extends MapToProp<Checkers, 'type'>>(type: T, subject: unknown): subject is T
|
|
11
|
-
// }
|
|
12
|
-
// }
|
|
13
|
-
|
|
14
|
-
// const any = { type: { any: { type: 'any', value: undefined } } }
|
|
15
|
-
// const unknown = { type: { unknown: { type: 'unknown', value: undefined } } }
|
|
16
|
-
|
|
17
|
-
// describe('checker: any', () => {
|
|
18
|
-
// test('cast to any', () => {
|
|
19
|
-
// const t = buildTypes(any, unknown)
|
|
20
|
-
|
|
21
|
-
// const s: unknown = 1
|
|
22
|
-
// if (t.satisfy(T.number, s)) {
|
|
23
|
-
// assertType.isNumber(s)
|
|
24
|
-
// }
|
|
25
|
-
// })
|
|
26
|
-
// })
|
|
27
|
-
|
|
28
|
-
test.todo('not ready')
|
package/ts/type-checker/index.ts
DELETED
|
File without changes
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { assertType } from '..'
|
|
2
|
-
import * as T from '../types'
|
|
3
|
-
import { createTypeChecker } from './typeChecker'
|
|
4
|
-
|
|
5
|
-
describe('check()', () => {
|
|
6
|
-
test('bool', () => {
|
|
7
|
-
const checker = createTypeChecker()
|
|
8
|
-
|
|
9
|
-
const s: unknown = false
|
|
10
|
-
if (checker.check({ strict: false, debug: false }, T.boolean.true, s)) {
|
|
11
|
-
assertType<true>(s)
|
|
12
|
-
}
|
|
13
|
-
})
|
|
14
|
-
})
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { AllType } from '../types'
|
|
2
|
-
import { analyze } from '../types/analyze'
|
|
3
|
-
import { satisfy } from '../types/satisfy'
|
|
4
|
-
import { BooleanSpec } from './Boolean'
|
|
5
|
-
import { Tuple } from './Tuple'
|
|
6
|
-
import { Type, TypeSpec } from './types'
|
|
7
|
-
|
|
8
|
-
// export type TypeChecker<Types extends Type<string, any>[]> = {
|
|
9
|
-
|
|
10
|
-
// }
|
|
11
|
-
|
|
12
|
-
export namespace TypeChecker {
|
|
13
|
-
export type CheckOptions = {
|
|
14
|
-
/**
|
|
15
|
-
* Check in strict mode.
|
|
16
|
-
* true = `conform()`.
|
|
17
|
-
* false = `satisfy()`.
|
|
18
|
-
*/
|
|
19
|
-
strict: boolean,
|
|
20
|
-
/**
|
|
21
|
-
* Turn on debug logging.
|
|
22
|
-
*/
|
|
23
|
-
debug: boolean
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export type Generate<Specs extends Array<any>, T> = Specs extends Array<TypeSpec<AllType>>
|
|
27
|
-
? Generate._<Specs, T>['result'] : never
|
|
28
|
-
|
|
29
|
-
export namespace Generate {
|
|
30
|
-
export type _<Specs extends Array<TypeSpec<AllType>>, T> = T extends AllType
|
|
31
|
-
? {
|
|
32
|
-
result: Generate<Specs, _ToNative<Tuple.FindByProp<Specs, 'type', T>, T>>
|
|
33
|
-
}
|
|
34
|
-
: { result: T }
|
|
35
|
-
|
|
36
|
-
export type _ToNative<R, T> = R extends TypeSpec<any> ? ReturnType<R['toNative']> : T
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function createTypeChecker<
|
|
41
|
-
Specs extends Type<string, any>[]
|
|
42
|
-
>(..._typeSpec: Specs) {
|
|
43
|
-
return {
|
|
44
|
-
check<T extends AllType>(
|
|
45
|
-
_options: TypeChecker.CheckOptions,
|
|
46
|
-
type: T,
|
|
47
|
-
subject: unknown): subject is TypeChecker.Generate<[typeof BooleanSpec], T> {
|
|
48
|
-
const result = satisfy.result = analyze({ strict: false }, type, subject)
|
|
49
|
-
return !result.analysis.fail
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
package/ts/type-checker/types.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export type Checker = {
|
|
2
|
-
type: Record<string, any>
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export type TypeSpec<T extends Type<string, any> = Type<string, any>, R = any> = {
|
|
6
|
-
type: T,
|
|
7
|
-
toAnalysis(options: AnalysisOptions, value: T['value'], subject: unknown): TypeAnalysis<T['type'], T['value']>,
|
|
8
|
-
toNative(value: T['value']): R
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export type AnalysisOptions = { strict: boolean, debug: boolean }
|
|
12
|
-
|
|
13
|
-
export type Type<T extends string, V> = {
|
|
14
|
-
type: T,
|
|
15
|
-
value: V
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export type TypeAnalysis<T extends string, V = never> = { type: T, value?: V, fail?: true }
|
|
19
|
-
|
package/ts/types/.eslintrc.json
DELETED
package/ts/types/AllType.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Any } from './Any'
|
|
2
|
-
import { Array } from './Array'
|
|
3
|
-
// import { BigInt } from './BigInt'
|
|
4
|
-
import { Boolean } from './Boolean'
|
|
5
|
-
import { Null } from './Null'
|
|
6
|
-
import { Number } from './Number'
|
|
7
|
-
import { ObjectType } from './Object'
|
|
8
|
-
import { Record } from './Record'
|
|
9
|
-
import { String } from './String'
|
|
10
|
-
import { Symbol } from './Symbol'
|
|
11
|
-
import { Tuple } from './Tuple'
|
|
12
|
-
import { Undefined } from './Undefined'
|
|
13
|
-
import { Union } from './Union'
|
|
14
|
-
import { Unknown } from './Unknown'
|
|
15
|
-
|
|
16
|
-
export type AllType = Undefined | Null | Boolean | Number | String
|
|
17
|
-
| ObjectType | Record
|
|
18
|
-
| Array | Tuple
|
|
19
|
-
// <https://www.rapidtables.com/math/symbols/Set_Symbols.html>
|
|
20
|
-
| Union // | Intersection | SubSet | SuperSet | Complement | Diff
|
|
21
|
-
| Unknown | Any
|
|
22
|
-
| Symbol // | BigInt
|
|
23
|
-
|
|
24
|
-
export namespace AllType {
|
|
25
|
-
export type PrimitiveValues = boolean | number | string // | bigint
|
|
26
|
-
export type Analysis = Any.Analysis | Unknown.Analysis |
|
|
27
|
-
Undefined.Analysis | Null.Analysis | Boolean.Analysis | Number.Analysis | String.Analysis |
|
|
28
|
-
Symbol.Analysis |
|
|
29
|
-
ObjectType.Analysis | Record.Analysis | Array.Analysis | Tuple.Analysis |
|
|
30
|
-
Union.Analysis
|
|
31
|
-
}
|
package/ts/types/Any.ts
DELETED
package/ts/types/Array.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// import { BigInt } from './BigInt'
|
|
2
|
-
import { AllType } from './AllType'
|
|
3
|
-
import { Type } from './types'
|
|
4
|
-
import { undef, Undefined } from './Undefined'
|
|
5
|
-
import { union, Union } from './Union'
|
|
6
|
-
import { unknown } from './Unknown'
|
|
7
|
-
|
|
8
|
-
export type Array<Value extends AllType = any> = Type<'array', Value>
|
|
9
|
-
export namespace Array {
|
|
10
|
-
export type Analysis<
|
|
11
|
-
Value extends AllType.PrimitiveValues | AllType.Analysis = any
|
|
12
|
-
> = {
|
|
13
|
-
type: 'array',
|
|
14
|
-
value?: Value,
|
|
15
|
-
fail?: true
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Creates an array type.
|
|
21
|
-
*/
|
|
22
|
-
function create<Value extends AllType>(value: Value): Array<Value> {
|
|
23
|
-
return {
|
|
24
|
-
type: 'array',
|
|
25
|
-
value
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const any = create(undefined as unknown as any)
|
|
30
|
-
|
|
31
|
-
export const array = Object.assign({}, any, {
|
|
32
|
-
any,
|
|
33
|
-
create,
|
|
34
|
-
optional: Object.assign(union.create(any, undef), {
|
|
35
|
-
/**
|
|
36
|
-
* Creates an optional array type.
|
|
37
|
-
*/
|
|
38
|
-
create<Value extends AllType>(value: Value): Union<[Array<Value>, Undefined]> {
|
|
39
|
-
return union.create(create(value), undef)
|
|
40
|
-
}
|
|
41
|
-
}),
|
|
42
|
-
unknown: create(unknown)
|
|
43
|
-
})
|
package/ts/types/BigInt.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// istanbul ignore file
|
|
2
|
-
// import { undef, Undefined } from './Undefined'
|
|
3
|
-
// import { Union, union } from './Union'
|
|
4
|
-
|
|
5
|
-
import { TypeAnalysis, Type } from './types'
|
|
6
|
-
|
|
7
|
-
export type BigInt<Value extends bigint = bigint> = Type<'bigint', Value>
|
|
8
|
-
|
|
9
|
-
export namespace BigInt {
|
|
10
|
-
export type Analysis = TypeAnalysis<'bigint', bigint>
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Creates a single value type.
|
|
15
|
-
*/
|
|
16
|
-
function create<Value extends bigint>(value: Value): BigInt<Value> {
|
|
17
|
-
// Cannot name this function as `const` because it is a reserved keyword.
|
|
18
|
-
return { type: 'bigint', value }
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const any = create(undefined as unknown as bigint)
|
|
22
|
-
|
|
23
|
-
export const bigint = Object.assign(any, {
|
|
24
|
-
any,
|
|
25
|
-
create,
|
|
26
|
-
// Note: adding this requires Union type to include BigInt
|
|
27
|
-
// optional: {
|
|
28
|
-
// ...union.create(any, undef),
|
|
29
|
-
// /**
|
|
30
|
-
// * Creates an optional bigint constant type.
|
|
31
|
-
// */
|
|
32
|
-
// create<Value extends bigint>(value: Value): Union<[BigInt<Value>, Undefined]> {
|
|
33
|
-
// return union.create(create(value), undef)
|
|
34
|
-
// }
|
|
35
|
-
// }
|
|
36
|
-
})
|
package/ts/types/Boolean.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Type } from './types'
|
|
2
|
-
import { undef, Undefined } from './Undefined'
|
|
3
|
-
import { Union, union } from './Union'
|
|
4
|
-
|
|
5
|
-
export type Boolean<Value extends boolean = boolean> = Type<'boolean', Value>
|
|
6
|
-
export namespace Boolean {
|
|
7
|
-
export type Analysis = { type: 'boolean', value?: boolean, fail?: true }
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export type True = Boolean<true>
|
|
11
|
-
export type False = Boolean<false>
|
|
12
|
-
|
|
13
|
-
function create<Value extends boolean>(value: Value): Boolean<Value> {
|
|
14
|
-
return { type: 'boolean', value }
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const any = create(undefined as unknown as boolean)
|
|
18
|
-
const t = create(true)
|
|
19
|
-
const f = create(false)
|
|
20
|
-
|
|
21
|
-
export const boolean = Object.assign(any, {
|
|
22
|
-
any,
|
|
23
|
-
true: t,
|
|
24
|
-
false: f,
|
|
25
|
-
create,
|
|
26
|
-
optional: Object.assign(union.create(any, undef), {
|
|
27
|
-
/**
|
|
28
|
-
* Creates an optional boolean type.
|
|
29
|
-
*/
|
|
30
|
-
create<Value extends boolean>(value: Value): Union<[Boolean<Value>, Undefined]> {
|
|
31
|
-
return union.create(create(value), undef)
|
|
32
|
-
},
|
|
33
|
-
true: union.create(t, undef),
|
|
34
|
-
false: union.create(f, undef),
|
|
35
|
-
})
|
|
36
|
-
})
|