type-plus 3.13.0 → 4.0.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/README.md +32 -88
- package/cjs/ComposableTypes.d.ts +8 -0
- package/cjs/ComposableTypes.js +3 -0
- package/cjs/ComposableTypes.js.map +1 -0
- package/{lib → cjs}/JSONTypes.d.ts +0 -0
- package/cjs/JSONTypes.js +27 -0
- package/cjs/JSONTypes.js.map +1 -0
- package/{lib → cjs}/PrimitiveTypes.d.ts +0 -0
- package/{lib → cjs}/PrimitiveTypes.js +0 -0
- package/cjs/PrimitiveTypes.js.map +1 -0
- package/{lib → cjs}/UnionKeys.d.ts +0 -0
- package/{lib → cjs}/UnionKeys.js +0 -0
- package/cjs/UnionKeys.js.map +1 -0
- package/{lib → cjs}/array/CommonPropKeys.d.ts +0 -0
- package/{lib → cjs}/array/CommonPropKeys.js +0 -0
- package/cjs/array/CommonPropKeys.js.map +1 -0
- package/{lib → cjs}/array/Concat.d.ts +0 -0
- package/{lib → cjs}/array/Concat.js +0 -0
- package/cjs/array/Concat.js.map +1 -0
- package/{lib → cjs}/array/CreateTuple.d.ts +0 -0
- package/{lib → cjs}/array/CreateTuple.js +0 -0
- package/cjs/array/CreateTuple.js.map +1 -0
- package/{lib → cjs}/array/DropFirst.d.ts +0 -0
- package/{lib → cjs}/array/DropFirst.js +0 -0
- package/cjs/array/DropFirst.js.map +1 -0
- package/{lib → cjs}/array/DropLast.d.ts +0 -0
- package/{lib → cjs}/array/DropLast.js +0 -0
- package/cjs/array/DropLast.js.map +1 -0
- package/{lib → cjs}/array/Filter.d.ts +0 -0
- package/{lib → cjs}/array/Filter.js +0 -0
- package/cjs/array/Filter.js.map +1 -0
- package/{lib → cjs}/array/FindFirst.d.ts +0 -0
- package/{lib → cjs}/array/FindFirst.js +0 -0
- package/cjs/array/FindFirst.js.map +1 -0
- package/{lib → cjs}/array/FindLast.d.ts +0 -0
- package/{lib → cjs}/array/FindLast.js +0 -0
- package/cjs/array/FindLast.js.map +1 -0
- package/{lib → cjs}/array/Head.d.ts +0 -0
- package/{lib → cjs}/array/Head.js +0 -0
- package/cjs/array/Head.js.map +1 -0
- package/{lib → cjs}/array/IntersectOfProps.d.ts +0 -0
- package/{lib → cjs}/array/IntersectOfProps.js +0 -0
- package/cjs/array/IntersectOfProps.js.map +1 -0
- package/{lib → cjs}/array/IsArray.d.ts +0 -0
- package/{lib → cjs}/array/IsArray.js +0 -0
- package/cjs/array/IsArray.js.map +1 -0
- package/{lib → cjs}/array/PadLeft.d.ts +0 -0
- package/{lib → cjs}/array/PadLeft.js +0 -0
- package/cjs/array/PadLeft.js.map +1 -0
- package/{lib → cjs}/array/Reverse.d.ts +0 -0
- package/{lib → cjs}/array/Reverse.js +0 -0
- package/cjs/array/Reverse.js.map +1 -0
- package/{lib → cjs}/array/Some.d.ts +0 -0
- package/{lib → cjs}/array/Some.js +0 -0
- package/cjs/array/Some.js.map +1 -0
- package/{lib → cjs}/array/Tail.d.ts +0 -0
- package/{lib → cjs}/array/Tail.js +0 -0
- package/cjs/array/Tail.js.map +1 -0
- package/{lib → cjs}/array/UnionOfProps.d.ts +0 -0
- package/{lib → cjs}/array/UnionOfProps.js +0 -0
- package/cjs/array/UnionOfProps.js.map +1 -0
- package/{lib → cjs}/array/UnionOfValues.d.ts +0 -0
- package/{lib → cjs}/array/UnionOfValues.js +0 -0
- package/cjs/array/UnionOfValues.js.map +1 -0
- package/{lib → cjs}/array/index.d.ts +0 -0
- package/{lib → cjs}/array/index.js +0 -0
- package/cjs/array/index.js.map +1 -0
- package/{lib → cjs}/array/literalArray.d.ts +0 -0
- package/{lib → cjs}/array/literalArray.js +0 -0
- package/cjs/array/literalArray.js.map +1 -0
- package/{lib → cjs}/array/reduceWhile.d.ts +0 -0
- package/{lib → cjs}/array/reduceWhile.js +0 -0
- package/cjs/array/reduceWhile.js.map +1 -0
- package/cjs/assertion/assertType.d.ts +32 -0
- package/cjs/assertion/assertType.js +107 -0
- package/cjs/assertion/assertType.js.map +1 -0
- package/{lib → cjs}/assertion/index.d.ts +0 -0
- package/{lib → cjs}/assertion/index.js +0 -0
- package/cjs/assertion/index.js.map +1 -0
- package/{lib → cjs}/class/AnyConstructor.d.ts +0 -0
- package/{lib → cjs}/class/AnyConstructor.js +0 -0
- package/cjs/class/AnyConstructor.js.map +1 -0
- package/{lib → cjs}/class/index.d.ts +0 -0
- package/{lib → cjs}/class/index.js +0 -0
- package/cjs/class/index.js.map +1 -0
- package/{lib → cjs}/class/isConstructor.d.ts +0 -0
- package/cjs/class/isConstructor.js +17 -0
- package/cjs/class/isConstructor.js.map +1 -0
- package/{lib → cjs}/function/AnyFunction.d.ts +0 -0
- package/{lib → cjs}/function/AnyFunction.js +0 -0
- package/cjs/function/AnyFunction.js.map +1 -0
- package/{lib → cjs}/function/index.d.ts +0 -0
- package/{lib → cjs}/function/index.js +0 -0
- package/cjs/function/index.js.map +1 -0
- package/{lib → cjs}/functional/ChainFn.d.ts +0 -0
- package/{lib → cjs}/functional/ChainFn.js +0 -0
- package/cjs/functional/ChainFn.js.map +1 -0
- package/{lib → cjs}/functional/index.d.ts +0 -0
- package/{lib → cjs}/functional/index.js +0 -0
- package/cjs/functional/index.js.map +1 -0
- package/cjs/index.d.ts +17 -0
- package/cjs/index.js +37 -0
- package/cjs/index.js.map +1 -0
- package/{lib → cjs}/math/Abs.d.ts +0 -0
- package/{lib → cjs}/math/Abs.js +0 -0
- package/cjs/math/Abs.js.map +1 -0
- package/{lib → cjs}/math/Add.d.ts +0 -0
- package/{lib → cjs}/math/Add.js +0 -0
- package/cjs/math/Add.js.map +1 -0
- package/{lib → cjs}/math/Digit.d.ts +0 -0
- package/{lib → cjs}/math/Digit.js +0 -0
- package/cjs/math/Digit.js.map +1 -0
- package/{lib → cjs}/math/GreaterThan.d.ts +0 -0
- package/{lib → cjs}/math/GreaterThan.js +0 -0
- package/cjs/math/GreaterThan.js.map +1 -0
- package/{lib → cjs}/math/IsPositive.d.ts +0 -0
- package/{lib → cjs}/math/IsPositive.js +0 -0
- package/cjs/math/IsPositive.js.map +1 -0
- package/{lib → cjs}/math/IsWhole.d.ts +0 -0
- package/{lib → cjs}/math/IsWhole.js +0 -0
- package/cjs/math/IsWhole.js.map +1 -0
- package/{lib → cjs}/math/Max.d.ts +0 -0
- package/{lib → cjs}/math/Max.js +0 -0
- package/cjs/math/Max.js.map +1 -0
- package/{lib → cjs}/math/Subtract.d.ts +0 -0
- package/{lib → cjs}/math/Subtract.js +0 -0
- package/cjs/math/Subtract.js.map +1 -0
- package/{lib → cjs}/math/index.d.ts +0 -0
- package/{lib → cjs}/math/index.js +0 -0
- package/cjs/math/index.js.map +1 -0
- package/cjs/nodejs/index.d.ts +1 -0
- package/cjs/nodejs/index.js +14 -0
- package/cjs/nodejs/index.js.map +1 -0
- package/cjs/nodejs/isNodeError.d.ts +31 -0
- package/cjs/nodejs/isNodeError.js +13 -0
- package/cjs/nodejs/isNodeError.js.map +1 -0
- package/{lib → cjs}/nominal-types/Brand.d.ts +0 -0
- package/{lib → cjs}/nominal-types/Brand.js +0 -0
- package/cjs/nominal-types/Brand.js.map +1 -0
- package/{lib → cjs}/nominal-types/Flavor.d.ts +0 -0
- package/{lib → cjs}/nominal-types/Flavor.js +0 -0
- package/cjs/nominal-types/Flavor.js.map +1 -0
- package/{lib → cjs}/nominal-types/index.d.ts +0 -0
- package/{lib → cjs}/nominal-types/index.js +0 -0
- package/cjs/nominal-types/index.js.map +1 -0
- package/{lib → cjs}/nominal-types/nominalMatch.d.ts +0 -0
- package/{lib → cjs}/nominal-types/nominalMatch.js +0 -0
- package/cjs/nominal-types/nominalMatch.js.map +1 -0
- package/{lib → cjs}/nominal-types/types.d.ts +0 -0
- package/{lib → cjs}/nominal-types/types.js +0 -0
- package/cjs/nominal-types/types.js.map +1 -0
- package/{lib → cjs}/object/ANotB.d.ts +0 -0
- package/{lib → cjs}/object/ANotB.js +0 -0
- package/cjs/object/ANotB.js.map +1 -0
- package/{lib → cjs}/object/AnyRecord.d.ts +0 -0
- package/{lib → cjs}/object/AnyRecord.js +0 -0
- package/cjs/object/AnyRecord.js.map +1 -0
- package/{lib → cjs}/object/ExcludePropType.d.ts +0 -0
- package/{lib → cjs}/object/ExcludePropType.js +0 -0
- package/cjs/object/ExcludePropType.js.map +1 -0
- package/{lib → cjs}/object/IsDisjoint.d.ts +0 -0
- package/{lib → cjs}/object/IsDisjoint.js +0 -0
- package/cjs/object/IsDisjoint.js.map +1 -0
- package/{lib → cjs}/object/IsRecord.d.ts +0 -0
- package/{lib → cjs}/object/IsRecord.js +0 -0
- package/cjs/object/IsRecord.js.map +1 -0
- package/{lib → cjs}/object/KeyTypes.d.ts +0 -0
- package/{lib → cjs}/object/KeyTypes.js +0 -0
- package/cjs/object/KeyTypes.js.map +1 -0
- package/{lib → cjs}/object/KeyofOptional.d.ts +0 -0
- package/{lib → cjs}/object/KeyofOptional.js +0 -0
- package/cjs/object/KeyofOptional.js.map +1 -0
- package/{lib → cjs}/object/KeysWithDiffType.d.ts +0 -0
- package/{lib → cjs}/object/KeysWithDiffType.js +0 -0
- package/cjs/object/KeysWithDiffType.js.map +1 -0
- package/{lib → cjs}/object/KnownKeys.d.ts +0 -0
- package/{lib → cjs}/object/KnownKeys.js +0 -0
- package/cjs/object/KnownKeys.js.map +1 -0
- package/{lib → cjs}/object/OptionalKeys.d.ts +0 -0
- package/{lib → cjs}/object/OptionalKeys.js +0 -0
- package/cjs/object/OptionalKeys.js.map +1 -0
- package/{lib → cjs}/object/Partial.d.ts +0 -0
- package/{lib → cjs}/object/Partial.js +0 -0
- package/cjs/object/Partial.js.map +1 -0
- package/{lib → cjs}/object/RecursiveIntersect.d.ts +0 -0
- package/{lib → cjs}/object/RecursiveIntersect.js +0 -0
- package/cjs/object/RecursiveIntersect.js.map +1 -0
- package/{lib → cjs}/object/RecursivePartial.d.ts +0 -0
- package/{lib → cjs}/object/RecursivePartial.js +0 -0
- package/cjs/object/RecursivePartial.js.map +1 -0
- package/{lib → cjs}/object/RecursiveRequired.d.ts +0 -0
- package/{lib → cjs}/object/RecursiveRequired.js +0 -0
- package/cjs/object/RecursiveRequired.js.map +1 -0
- package/{lib → cjs}/object/Required.d.ts +0 -0
- package/{lib → cjs}/object/Required.js +0 -0
- package/cjs/object/Required.js.map +1 -0
- package/{lib → cjs}/object/RequiredKeys.d.ts +0 -0
- package/{lib → cjs}/object/RequiredKeys.js +0 -0
- package/cjs/object/RequiredKeys.js.map +1 -0
- package/{lib → cjs}/object/SpreadRecord.d.ts +0 -0
- package/{lib → cjs}/object/SpreadRecord.js +0 -0
- package/cjs/object/SpreadRecord.js.map +1 -0
- package/{lib → cjs}/object/ValueOf.d.ts +0 -0
- package/{lib → cjs}/object/ValueOf.js +0 -0
- package/cjs/object/ValueOf.js.map +1 -0
- package/{lib → cjs}/object/everyKey.d.ts +0 -0
- package/{lib → cjs}/object/everyKey.js +0 -0
- package/cjs/object/everyKey.js.map +1 -0
- package/{lib → cjs}/object/facade.d.ts +0 -0
- package/{lib → cjs}/object/facade.js +0 -0
- package/cjs/object/facade.js.map +1 -0
- package/{lib → cjs}/object/filterKey.d.ts +0 -0
- package/{lib → cjs}/object/filterKey.js +0 -0
- package/cjs/object/filterKey.js.map +1 -0
- package/{lib → cjs}/object/findKey.d.ts +0 -0
- package/{lib → cjs}/object/findKey.js +0 -0
- package/cjs/object/findKey.js.map +1 -0
- package/{lib → cjs}/object/forEachKey.d.ts +0 -0
- package/{lib → cjs}/object/forEachKey.js +0 -0
- package/cjs/object/forEachKey.js.map +1 -0
- package/{lib → cjs}/object/getField.d.ts +0 -0
- package/{lib → cjs}/object/getField.js +0 -0
- package/cjs/object/getField.js.map +1 -0
- package/{lib → cjs}/object/hasKey.d.ts +0 -0
- package/{lib → cjs}/object/hasKey.js +0 -0
- package/cjs/object/hasKey.js.map +1 -0
- package/{lib → cjs}/object/hasProperty.d.ts +0 -0
- package/{lib → cjs}/object/hasProperty.js +0 -0
- package/cjs/object/hasProperty.js.map +1 -0
- package/{lib → cjs}/object/index.d.ts +0 -0
- package/{lib → cjs}/object/index.js +0 -0
- package/cjs/object/index.js.map +1 -0
- package/{lib → cjs}/object/mapKey.d.ts +0 -0
- package/{lib → cjs}/object/mapKey.js +0 -0
- package/cjs/object/mapKey.js.map +1 -0
- package/{lib → cjs}/object/mapProperties.d.ts +0 -0
- package/cjs/object/mapProperties.js +18 -0
- package/cjs/object/mapProperties.js.map +1 -0
- package/{lib → cjs}/object/omit.d.ts +0 -0
- package/cjs/object/omit.js +17 -0
- package/cjs/object/omit.js.map +1 -0
- package/{lib → cjs}/object/pick.d.ts +0 -0
- package/cjs/object/pick.js +17 -0
- package/cjs/object/pick.js.map +1 -0
- package/{lib → cjs}/object/reduceKey.d.ts +0 -0
- package/{lib → cjs}/object/reduceKey.js +0 -0
- package/cjs/object/reduceKey.js.map +1 -0
- package/{lib → cjs}/object/replaceProperty.d.ts +0 -0
- package/{lib → cjs}/object/replaceProperty.js +0 -0
- package/cjs/object/replaceProperty.js.map +1 -0
- package/{lib → cjs}/object/someKey.d.ts +0 -0
- package/{lib → cjs}/object/someKey.js +0 -0
- package/cjs/object/someKey.js.map +1 -0
- package/{lib → cjs}/object/typeOverrideIncompatible.d.ts +0 -0
- package/{lib → cjs}/object/typeOverrideIncompatible.js +0 -0
- package/cjs/object/typeOverrideIncompatible.js.map +1 -0
- package/{lib → cjs}/predicates/CanAssign.d.ts +0 -0
- package/{lib → cjs}/predicates/CanAssign.js +0 -0
- package/cjs/predicates/CanAssign.js.map +1 -0
- package/{lib → cjs}/predicates/Equal.d.ts +0 -0
- package/{lib → cjs}/predicates/Equal.js +0 -0
- package/cjs/predicates/Equal.js.map +1 -0
- package/{lib → cjs}/predicates/Extends.d.ts +0 -0
- package/{lib → cjs}/predicates/Extends.js +0 -0
- package/cjs/predicates/Extends.js.map +1 -0
- package/{lib → cjs}/predicates/If.d.ts +0 -0
- package/{lib → cjs}/predicates/If.js +0 -0
- package/cjs/predicates/If.js.map +1 -0
- package/{lib → cjs}/predicates/index.d.ts +0 -0
- package/{lib → cjs}/predicates/index.js +0 -0
- package/cjs/predicates/index.js.map +1 -0
- package/{lib → cjs}/predicates/isEmptyObject.d.ts +0 -0
- package/{lib → cjs}/predicates/isEmptyObject.js +0 -0
- package/cjs/predicates/isEmptyObject.js.map +1 -0
- package/cjs/predicates/isType.d.ts +10 -0
- package/cjs/predicates/isType.js +28 -0
- package/cjs/predicates/isType.js.map +1 -0
- package/{lib → cjs}/predicates/logical.d.ts +0 -0
- package/{lib → cjs}/predicates/logical.js +0 -0
- package/cjs/predicates/logical.js.map +1 -0
- package/{lib → cjs}/promise/PromiseValue.d.ts +0 -0
- package/{lib → cjs}/promise/PromiseValue.js +0 -0
- package/cjs/promise/PromiseValue.js.map +1 -0
- package/{lib → cjs}/promise/PromiseValueMerge.d.ts +0 -0
- package/{lib → cjs}/promise/PromiseValueMerge.js +0 -0
- package/cjs/promise/PromiseValueMerge.js.map +1 -0
- package/{lib → cjs}/promise/index.d.ts +0 -0
- package/{lib → cjs}/promise/index.js +0 -0
- package/cjs/promise/index.js.map +1 -0
- package/{lib → cjs}/promise/isPromise.d.ts +0 -0
- package/{lib → cjs}/promise/isPromise.js +0 -0
- package/cjs/promise/isPromise.js.map +1 -0
- package/{lib → cjs}/promise/mapSeries.d.ts +0 -0
- package/{lib → cjs}/promise/mapSeries.js +0 -0
- package/cjs/promise/mapSeries.js.map +1 -0
- package/{lib → cjs}/utils/Widen.d.ts +0 -0
- package/{lib → cjs}/utils/Widen.js +0 -0
- package/cjs/utils/Widen.js.map +1 -0
- package/{lib → cjs}/utils/as.d.ts +0 -0
- package/{lib → cjs}/utils/as.js +0 -0
- package/cjs/utils/as.js.map +1 -0
- package/{lib → cjs}/utils/index.d.ts +0 -0
- package/{lib → cjs}/utils/index.js +0 -0
- package/cjs/utils/index.js.map +1 -0
- package/esm/ComposableTypes.js +2 -0
- package/esm/ComposableTypes.js.map +1 -0
- package/{libm → esm}/JSONTypes.js +0 -0
- package/esm/JSONTypes.js.map +1 -0
- package/{libm → esm}/PrimitiveTypes.js +0 -0
- package/esm/PrimitiveTypes.js.map +1 -0
- package/{libm → esm}/UnionKeys.js +0 -0
- package/esm/UnionKeys.js.map +1 -0
- package/{libm → esm}/array/CommonPropKeys.js +0 -0
- package/esm/array/CommonPropKeys.js.map +1 -0
- package/{libm → esm}/array/Concat.js +0 -0
- package/esm/array/Concat.js.map +1 -0
- package/{libm → esm}/array/CreateTuple.js +0 -0
- package/esm/array/CreateTuple.js.map +1 -0
- package/{libm → esm}/array/DropFirst.js +0 -0
- package/esm/array/DropFirst.js.map +1 -0
- package/{libm → esm}/array/DropLast.js +0 -0
- package/esm/array/DropLast.js.map +1 -0
- package/{libm → esm}/array/Filter.js +0 -0
- package/esm/array/Filter.js.map +1 -0
- package/{libm → esm}/array/FindFirst.js +0 -0
- package/esm/array/FindFirst.js.map +1 -0
- package/{libm → esm}/array/FindLast.js +0 -0
- package/esm/array/FindLast.js.map +1 -0
- package/{libm → esm}/array/Head.js +0 -0
- package/esm/array/Head.js.map +1 -0
- package/{libm → esm}/array/IntersectOfProps.js +0 -0
- package/esm/array/IntersectOfProps.js.map +1 -0
- package/{libm → esm}/array/IsArray.js +0 -0
- package/esm/array/IsArray.js.map +1 -0
- package/{libm → esm}/array/PadLeft.js +0 -0
- package/esm/array/PadLeft.js.map +1 -0
- package/{libm → esm}/array/Reverse.js +0 -0
- package/esm/array/Reverse.js.map +1 -0
- package/{libm → esm}/array/Some.js +0 -0
- package/esm/array/Some.js.map +1 -0
- package/{libm → esm}/array/Tail.js +0 -0
- package/esm/array/Tail.js.map +1 -0
- package/{libm → esm}/array/UnionOfProps.js +0 -0
- package/esm/array/UnionOfProps.js.map +1 -0
- package/{libm → esm}/array/UnionOfValues.js +0 -0
- package/esm/array/UnionOfValues.js.map +1 -0
- package/{libm → esm}/array/index.js +0 -0
- package/esm/array/index.js.map +1 -0
- package/{libm → esm}/array/literalArray.js +0 -0
- package/esm/array/literalArray.js.map +1 -0
- package/{libm → esm}/array/reduceWhile.js +0 -0
- package/esm/array/reduceWhile.js.map +1 -0
- package/{libm → esm}/assertion/assertType.js +0 -0
- package/esm/assertion/assertType.js.map +1 -0
- package/{libm → esm}/assertion/index.js +0 -0
- package/esm/assertion/index.js.map +1 -0
- package/{libm → esm}/class/AnyConstructor.js +0 -0
- package/esm/class/AnyConstructor.js.map +1 -0
- package/{libm → esm}/class/index.js +0 -0
- package/esm/class/index.js.map +1 -0
- package/esm/class/isConstructor.js +13 -0
- package/esm/class/isConstructor.js.map +1 -0
- package/{libm → esm}/function/AnyFunction.js +0 -0
- package/esm/function/AnyFunction.js.map +1 -0
- package/{libm → esm}/function/index.js +0 -0
- package/esm/function/index.js.map +1 -0
- package/{libm → esm}/functional/ChainFn.js +0 -0
- package/esm/functional/ChainFn.js.map +1 -0
- package/{libm → esm}/functional/index.js +0 -0
- package/esm/functional/index.js.map +1 -0
- package/esm/index.js +22 -0
- package/esm/index.js.map +1 -0
- package/{libm → esm}/math/Abs.js +0 -0
- package/esm/math/Abs.js.map +1 -0
- package/{libm → esm}/math/Add.js +0 -0
- package/esm/math/Add.js.map +1 -0
- package/{libm → esm}/math/Digit.js +0 -0
- package/esm/math/Digit.js.map +1 -0
- package/{libm → esm}/math/GreaterThan.js +0 -0
- package/esm/math/GreaterThan.js.map +1 -0
- package/{libm → esm}/math/IsPositive.js +0 -0
- package/esm/math/IsPositive.js.map +1 -0
- package/{libm → esm}/math/IsWhole.js +0 -0
- package/esm/math/IsWhole.js.map +1 -0
- package/{libm → esm}/math/Max.js +0 -0
- package/esm/math/Max.js.map +1 -0
- package/{libm → esm}/math/Subtract.js +0 -0
- package/esm/math/Subtract.js.map +1 -0
- package/{libm → esm}/math/index.js +0 -0
- package/esm/math/index.js.map +1 -0
- package/esm/nodejs/index.js +2 -0
- package/esm/nodejs/index.js.map +1 -0
- package/esm/nodejs/isNodeError.js +9 -0
- package/esm/nodejs/isNodeError.js.map +1 -0
- package/{libm → esm}/nominal-types/Brand.js +0 -0
- package/esm/nominal-types/Brand.js.map +1 -0
- package/{libm → esm}/nominal-types/Flavor.js +0 -0
- package/esm/nominal-types/Flavor.js.map +1 -0
- package/{libm → esm}/nominal-types/index.js +0 -0
- package/esm/nominal-types/index.js.map +1 -0
- package/{libm → esm}/nominal-types/nominalMatch.js +0 -0
- package/esm/nominal-types/nominalMatch.js.map +1 -0
- package/{libm → esm}/nominal-types/types.js +0 -0
- package/esm/nominal-types/types.js.map +1 -0
- package/{libm → esm}/object/ANotB.js +0 -0
- package/esm/object/ANotB.js.map +1 -0
- package/{libm → esm}/object/AnyRecord.js +0 -0
- package/esm/object/AnyRecord.js.map +1 -0
- package/{libm → esm}/object/ExcludePropType.js +0 -0
- package/esm/object/ExcludePropType.js.map +1 -0
- package/{libm → esm}/object/IsDisjoint.js +0 -0
- package/esm/object/IsDisjoint.js.map +1 -0
- package/{libm → esm}/object/IsRecord.js +0 -0
- package/esm/object/IsRecord.js.map +1 -0
- package/{libm → esm}/object/KeyTypes.js +0 -0
- package/esm/object/KeyTypes.js.map +1 -0
- package/{libm → esm}/object/KeyofOptional.js +0 -0
- package/esm/object/KeyofOptional.js.map +1 -0
- package/{libm → esm}/object/KeysWithDiffType.js +0 -0
- package/esm/object/KeysWithDiffType.js.map +1 -0
- package/{libm → esm}/object/KnownKeys.js +0 -0
- package/esm/object/KnownKeys.js.map +1 -0
- package/{libm → esm}/object/OptionalKeys.js +0 -0
- package/esm/object/OptionalKeys.js.map +1 -0
- package/{libm → esm}/object/Partial.js +0 -0
- package/esm/object/Partial.js.map +1 -0
- package/{libm → esm}/object/RecursiveIntersect.js +0 -0
- package/esm/object/RecursiveIntersect.js.map +1 -0
- package/{libm → esm}/object/RecursivePartial.js +0 -0
- package/esm/object/RecursivePartial.js.map +1 -0
- package/{libm → esm}/object/RecursiveRequired.js +0 -0
- package/esm/object/RecursiveRequired.js.map +1 -0
- package/{libm → esm}/object/Required.js +0 -0
- package/esm/object/Required.js.map +1 -0
- package/{libm → esm}/object/RequiredKeys.js +0 -0
- package/esm/object/RequiredKeys.js.map +1 -0
- package/{libm → esm}/object/SpreadRecord.js +0 -0
- package/esm/object/SpreadRecord.js.map +1 -0
- package/{libm → esm}/object/ValueOf.js +0 -0
- package/esm/object/ValueOf.js.map +1 -0
- package/{libm → esm}/object/everyKey.js +0 -0
- package/esm/object/everyKey.js.map +1 -0
- package/{libm → esm}/object/facade.js +0 -0
- package/esm/object/facade.js.map +1 -0
- package/{libm → esm}/object/filterKey.js +0 -0
- package/esm/object/filterKey.js.map +1 -0
- package/{libm → esm}/object/findKey.js +0 -0
- package/esm/object/findKey.js.map +1 -0
- package/{libm → esm}/object/forEachKey.js +0 -0
- package/esm/object/forEachKey.js.map +1 -0
- package/{libm → esm}/object/getField.js +0 -0
- package/esm/object/getField.js.map +1 -0
- package/{libm → esm}/object/hasKey.js +0 -0
- package/esm/object/hasKey.js.map +1 -0
- package/{libm → esm}/object/hasProperty.js +0 -0
- package/esm/object/hasProperty.js.map +1 -0
- package/{libm → esm}/object/index.js +0 -0
- package/esm/object/index.js.map +1 -0
- package/{libm → esm}/object/mapKey.js +0 -0
- package/esm/object/mapKey.js.map +1 -0
- package/{libm → esm}/object/mapProperties.js +0 -0
- package/esm/object/mapProperties.js.map +1 -0
- package/{libm → esm}/object/omit.js +0 -0
- package/esm/object/omit.js.map +1 -0
- package/{libm → esm}/object/pick.js +0 -0
- package/esm/object/pick.js.map +1 -0
- package/{libm → esm}/object/reduceKey.js +0 -0
- package/esm/object/reduceKey.js.map +1 -0
- package/{libm → esm}/object/replaceProperty.js +0 -0
- package/esm/object/replaceProperty.js.map +1 -0
- package/{libm → esm}/object/someKey.js +0 -0
- package/esm/object/someKey.js.map +1 -0
- package/{libm → esm}/object/typeOverrideIncompatible.js +0 -0
- package/esm/object/typeOverrideIncompatible.js.map +1 -0
- package/{libm → esm}/predicates/CanAssign.js +0 -0
- package/esm/predicates/CanAssign.js.map +1 -0
- package/{libm → esm}/predicates/Equal.js +0 -0
- package/esm/predicates/Equal.js.map +1 -0
- package/{libm → esm}/predicates/Extends.js +0 -0
- package/esm/predicates/Extends.js.map +1 -0
- package/{libm → esm}/predicates/If.js +0 -0
- package/esm/predicates/If.js.map +1 -0
- package/{libm → esm}/predicates/index.js +0 -0
- package/esm/predicates/index.js.map +1 -0
- package/{libm → esm}/predicates/isEmptyObject.js +0 -0
- package/esm/predicates/isEmptyObject.js.map +1 -0
- package/{libm → esm}/predicates/isType.js +0 -0
- package/esm/predicates/isType.js.map +1 -0
- package/{libm → esm}/predicates/logical.js +0 -0
- package/esm/predicates/logical.js.map +1 -0
- package/{libm → esm}/promise/PromiseValue.js +0 -0
- package/esm/promise/PromiseValue.js.map +1 -0
- package/{libm → esm}/promise/PromiseValueMerge.js +0 -0
- package/esm/promise/PromiseValueMerge.js.map +1 -0
- package/{libm → esm}/promise/index.js +0 -0
- package/esm/promise/index.js.map +1 -0
- package/{libm → esm}/promise/isPromise.js +0 -0
- package/esm/promise/isPromise.js.map +1 -0
- package/{libm → esm}/promise/mapSeries.js +0 -0
- package/esm/promise/mapSeries.js.map +1 -0
- package/{libm → esm}/utils/Widen.js +0 -0
- package/esm/utils/Widen.js.map +1 -0
- package/{libm → esm}/utils/as.js +0 -0
- package/esm/utils/as.js.map +1 -0
- package/{libm → esm}/utils/index.js +0 -0
- package/esm/utils/index.js.map +1 -0
- package/package.json +47 -51
- package/ts/ComposableTypes.spec.ts +29 -0
- package/ts/ComposableTypes.ts +10 -0
- package/ts/JSONTypes.spec.ts +43 -0
- package/ts/JSONTypes.ts +18 -0
- package/ts/PrimitiveTypes.ts +2 -0
- package/{src → ts}/UnionKeys.ts +0 -0
- package/ts/UnionToIntersection.ts +7 -0
- package/ts/array/CommonPropKeys.spec.ts +20 -0
- package/ts/array/CommonPropKeys.ts +18 -0
- package/ts/array/Concat.spec.ts +21 -0
- package/ts/array/Concat.ts +1 -0
- package/ts/array/CreateTuple.spec.ts +21 -0
- package/ts/array/CreateTuple.ts +7 -0
- package/ts/array/DropFirst.spec.ts +21 -0
- package/ts/array/DropFirst.ts +9 -0
- package/ts/array/DropLast.spec.ts +21 -0
- package/ts/array/DropLast.ts +9 -0
- package/ts/array/Filter.spec.ts +21 -0
- package/ts/array/Filter.ts +12 -0
- package/ts/array/FindFirst.spec.ts +27 -0
- package/ts/array/FindFirst.ts +13 -0
- package/ts/array/FindLast.spec.ts +27 -0
- package/ts/array/FindLast.ts +8 -0
- package/ts/array/Head.spec.ts +21 -0
- package/ts/array/Head.ts +1 -0
- package/ts/array/IntersectOfProps.spec.ts +14 -0
- package/ts/array/IntersectOfProps.ts +20 -0
- package/ts/array/IsArray.ts +1 -0
- package/ts/array/PadLeft.spec.ts +26 -0
- package/ts/array/PadLeft.ts +16 -0
- package/ts/array/Reverse.spec.ts +17 -0
- package/ts/array/Reverse.ts +10 -0
- package/ts/array/Some.spec.ts +79 -0
- package/ts/array/Some.ts +24 -0
- package/ts/array/Tail.spec.ts +32 -0
- package/ts/array/Tail.ts +7 -0
- package/ts/array/UnionOfProps.spec.ts +14 -0
- package/ts/array/UnionOfProps.ts +18 -0
- package/ts/array/UnionOfValues.spec.ts +11 -0
- package/ts/array/UnionOfValues.ts +10 -0
- package/ts/array/index.ts +19 -0
- package/{src → ts}/array/literalArray.spec.ts +0 -0
- package/{src → ts}/array/literalArray.ts +0 -0
- package/{src → ts}/array/reduceWhile.spec.ts +0 -0
- package/{src → ts}/array/reduceWhile.ts +0 -0
- package/ts/assertion/assertType.spec.ts +507 -0
- package/ts/assertion/assertType.ts +105 -0
- package/ts/assertion/index.ts +1 -0
- package/{src → ts}/binary/Bit.ts +0 -0
- package/{src → ts}/binary/_binary.ts +0 -0
- package/{src → ts}/binary/index.spec.ts +0 -0
- package/{src → ts}/binary/index.ts +0 -0
- package/ts/class/AnyConstructor.spec.ts +13 -0
- package/{src → ts}/class/AnyConstructor.ts +0 -0
- package/{src → ts}/class/index.ts +0 -0
- package/ts/class/isConstructor.spec.ts +35 -0
- package/ts/class/isConstructor.ts +14 -0
- package/ts/function/AnyFunction.spec.ts +21 -0
- package/{src → ts}/function/AnyFunction.ts +0 -0
- package/{src → ts}/function/index.ts +0 -0
- package/ts/functional/ChainFn.spec.ts +7 -0
- package/ts/functional/ChainFn.ts +6 -0
- package/ts/functional/Maybe.spec.ts +42 -0
- package/ts/functional/Maybe.ts +19 -0
- package/ts/functional/index.ts +2 -0
- package/{src → ts}/index.spec.ts +0 -0
- package/ts/index.ts +21 -0
- package/ts/math/Abs.spec.ts +14 -0
- package/ts/math/Abs.ts +4 -0
- package/ts/math/Add.spec.ts +82 -0
- package/ts/math/Add.ts +49 -0
- package/ts/math/Digit.spec.ts +185 -0
- package/ts/math/Digit.ts +115 -0
- package/ts/math/GreaterThan.spec.ts +40 -0
- package/ts/math/GreaterThan.ts +36 -0
- package/{src → ts}/math/IsPositive.spec.ts +0 -0
- package/ts/math/IsPositive.ts +9 -0
- package/ts/math/IsWhole.spec.ts +19 -0
- package/ts/math/IsWhole.ts +9 -0
- package/ts/math/Max.spec.ts +35 -0
- package/ts/math/Max.ts +31 -0
- package/ts/math/README.md +7 -0
- package/ts/math/Subtract.spec.ts +40 -0
- package/ts/math/Subtract.ts +40 -0
- package/ts/math/index.ts +7 -0
- package/ts/nodejs/index.ts +1 -0
- package/ts/nodejs/isNodeError.spec.ts +11 -0
- package/ts/nodejs/isNodeError.ts +28 -0
- package/ts/nominal-types/Brand.spec.ts +43 -0
- package/ts/nominal-types/Brand.ts +32 -0
- package/ts/nominal-types/Flavor.spec.ts +51 -0
- package/ts/nominal-types/Flavor.ts +32 -0
- package/{src → ts}/nominal-types/index.ts +0 -0
- package/{src → ts}/nominal-types/nominalMatch.spec.ts +0 -0
- package/{src → ts}/nominal-types/nominalMatch.ts +0 -0
- package/{src → ts}/nominal-types/types.ts +0 -0
- package/{src → ts}/object/ANotB.spec.ts +0 -0
- package/ts/object/ANotB.ts +21 -0
- package/{src → ts}/object/AnyRecord.ts +0 -0
- package/ts/object/ExcludePropType.spec.ts +13 -0
- package/{src → ts}/object/ExcludePropType.ts +0 -0
- package/ts/object/IsDisjoint.spec.ts +25 -0
- package/ts/object/IsDisjoint.ts +12 -0
- package/ts/object/IsRecord.spec.ts +22 -0
- package/ts/object/IsRecord.ts +4 -0
- package/{src → ts}/object/KeyTypes.spec.ts +0 -0
- package/{src → ts}/object/KeyTypes.ts +0 -0
- package/ts/object/KeyofOptional.spec.ts +8 -0
- package/{src → ts}/object/KeyofOptional.ts +0 -0
- package/ts/object/KeysWithDiffType.spec.ts +21 -0
- package/{src → ts}/object/KeysWithDiffType.ts +0 -0
- package/ts/object/KnownKeys.spec.ts +39 -0
- package/ts/object/KnownKeys.ts +16 -0
- package/{src → ts}/object/OptionalKeys.spec.ts +0 -0
- package/{src → ts}/object/OptionalKeys.ts +0 -0
- package/ts/object/Partial.spec.ts +49 -0
- package/{src → ts}/object/Partial.ts +0 -0
- package/ts/object/RecursiveIntersect.spec.ts +39 -0
- package/{src → ts}/object/RecursiveIntersect.ts +0 -0
- package/{src → ts}/object/RecursivePartial.ts +0 -0
- package/{src → ts}/object/RecursiveRequired.spec.ts +0 -0
- package/{src → ts}/object/RecursiveRequired.ts +0 -0
- package/ts/object/Required.spec.ts +29 -0
- package/{src → ts}/object/Required.ts +0 -0
- package/{src → ts}/object/RequiredKeys.spec.ts +0 -0
- package/{src → ts}/object/RequiredKeys.ts +0 -0
- package/ts/object/SpreadRecord.spec.ts +14 -0
- package/ts/object/SpreadRecord.ts +6 -0
- package/ts/object/ValueOf.spec.ts +36 -0
- package/{src → ts}/object/ValueOf.ts +0 -0
- package/{src → ts}/object/everyKey.spec.ts +0 -0
- package/{src → ts}/object/everyKey.ts +0 -0
- package/{src → ts}/object/facade.spec.ts +0 -0
- package/ts/object/facade.ts +39 -0
- package/{src → ts}/object/filterKey.spec.ts +0 -0
- package/{src → ts}/object/filterKey.ts +0 -0
- package/{src → ts}/object/findKey.spec.ts +0 -0
- package/{src → ts}/object/findKey.ts +0 -0
- package/{src → ts}/object/forEachKey.spec.ts +0 -0
- package/{src → ts}/object/forEachKey.ts +0 -0
- package/ts/object/getField.spec.ts +21 -0
- package/ts/object/getField.ts +21 -0
- package/{src → ts}/object/hasKey.spec.ts +0 -0
- package/ts/object/hasKey.ts +7 -0
- package/ts/object/hasProperty.spec.ts +15 -0
- package/{src → ts}/object/hasProperty.ts +0 -0
- package/ts/object/index.ts +35 -0
- package/{src → ts}/object/mapKey.spec.ts +0 -0
- package/{src → ts}/object/mapKey.ts +0 -0
- package/ts/object/mapProperties.spec.ts +27 -0
- package/{src → ts}/object/mapProperties.ts +0 -0
- package/ts/object/omit.spec.ts +104 -0
- package/ts/object/omit.ts +36 -0
- package/ts/object/pick.spec.ts +66 -0
- package/ts/object/pick.ts +35 -0
- package/{src → ts}/object/reduceKey.spec.ts +0 -0
- package/{src → ts}/object/reduceKey.ts +0 -0
- package/{src → ts}/object/replaceProperty.spec.ts +0 -0
- package/{src → ts}/object/replaceProperty.ts +0 -0
- package/{src → ts}/object/someKey.spec.ts +0 -0
- package/{src → ts}/object/someKey.ts +0 -0
- package/ts/object/typeOverrideIncompatible.spec.ts +24 -0
- package/ts/object/typeOverrideIncompatible.ts +10 -0
- package/ts/predicates/CanAssign.spec.ts +57 -0
- package/{src → ts}/predicates/CanAssign.ts +0 -0
- package/ts/predicates/Equal.spec.ts +71 -0
- package/ts/predicates/Equal.ts +14 -0
- package/ts/predicates/Extends.ts +4 -0
- package/ts/predicates/If.spec.ts +14 -0
- package/ts/predicates/If.ts +5 -0
- package/ts/predicates/index.spec.ts +73 -0
- package/ts/predicates/index.ts +17 -0
- package/ts/predicates/isEmptyObject.spec.ts +15 -0
- package/ts/predicates/isEmptyObject.ts +2 -0
- package/ts/predicates/isType.spec.ts +106 -0
- package/ts/predicates/isType.ts +30 -0
- package/ts/predicates/logical.spec.ts +59 -0
- package/ts/predicates/logical.ts +4 -0
- package/ts/promise/PromiseValue.spec.ts +6 -0
- package/{src → ts}/promise/PromiseValue.ts +0 -0
- package/{src → ts}/promise/PromiseValueMerge.spec.ts +0 -0
- package/{src → ts}/promise/PromiseValueMerge.ts +0 -0
- package/{src → ts}/promise/index.ts +0 -0
- package/{src → ts}/promise/isPromise.spec.ts +0 -0
- package/ts/promise/isPromise.ts +4 -0
- package/{src → ts}/promise/mapSeries.spec.ts +0 -0
- package/ts/promise/mapSeries.ts +5 -0
- package/{src → ts}/type-checker/.eslintrc.json +0 -0
- package/{src → ts}/type-checker/AnyType.ts +0 -0
- package/{src → ts}/type-checker/Boolean.ts +0 -0
- package/{src → ts}/type-checker/Tuple.spec.ts +0 -0
- package/{src → ts}/type-checker/Tuple.ts +0 -0
- package/ts/type-checker/buildTypes.spec.ts +28 -0
- package/{src → ts}/type-checker/index.ts +0 -0
- package/ts/type-checker/typeChecker.spec.ts +14 -0
- package/{src → ts}/type-checker/typeChecker.ts +0 -0
- package/{src → ts}/type-checker/types.ts +0 -0
- package/{src → ts}/types/.eslintrc.json +0 -0
- package/{src → ts}/types/AllType.ts +0 -0
- package/{src → ts}/types/Any.ts +0 -0
- package/{src → ts}/types/Array.ts +0 -0
- package/{src → ts}/types/BigInt.ts +0 -0
- package/{src → ts}/types/Boolean.ts +0 -0
- package/ts/types/Generate.ts +48 -0
- package/{src → ts}/types/Null.ts +0 -0
- package/ts/types/Number.ts +56 -0
- package/ts/types/Object.ts +53 -0
- package/{src → ts}/types/Record.ts +0 -0
- package/ts/types/String.ts +56 -0
- package/ts/types/Symbol.ts +19 -0
- package/ts/types/Tuple.ts +50 -0
- package/{src → ts}/types/Undefined.ts +0 -0
- package/{src → ts}/types/Union.ts +0 -0
- package/{src → ts}/types/Unknown.ts +0 -0
- package/{src → ts}/types/analyze.spec.ts +0 -0
- package/{src → ts}/types/analyze.ts +0 -0
- package/ts/types/check.spec.ts +12 -0
- package/{src → ts}/types/check.ts +0 -0
- package/ts/types/conform.spec.ts +7 -0
- package/{src → ts}/types/conform.ts +0 -0
- package/{src → ts}/types/getPlainAnalysisReport.spec.ts +0 -0
- package/ts/types/getPlainAnalysisReport.ts +115 -0
- package/ts/types/index.ts +28 -0
- package/ts/types/optional.ts +30 -0
- package/ts/types/required.ts +30 -0
- package/ts/types/satisfy.accept.ts +39 -0
- package/ts/types/satisfy.spec.ts +600 -0
- package/{src → ts}/types/satisfy.ts +0 -0
- package/{src → ts}/types/types.ts +0 -0
- package/{src → ts}/utils/Widen.ts +0 -0
- package/ts/utils/as.spec.ts +24 -0
- package/ts/utils/as.ts +7 -0
- package/ts/utils/index.ts +2 -0
- package/lib/JSONTypes.js +0 -23
- package/lib/JSONTypes.js.map +0 -1
- package/lib/PrimitiveTypes.js.map +0 -1
- package/lib/UnionKeys.js.map +0 -1
- package/lib/array/CommonPropKeys.js.map +0 -1
- package/lib/array/Concat.js.map +0 -1
- package/lib/array/CreateTuple.js.map +0 -1
- package/lib/array/DropFirst.js.map +0 -1
- package/lib/array/DropLast.js.map +0 -1
- package/lib/array/Filter.js.map +0 -1
- package/lib/array/FindFirst.js.map +0 -1
- package/lib/array/FindLast.js.map +0 -1
- package/lib/array/Head.js.map +0 -1
- package/lib/array/IntersectOfProps.js.map +0 -1
- package/lib/array/IsArray.js.map +0 -1
- package/lib/array/PadLeft.js.map +0 -1
- package/lib/array/Reverse.js.map +0 -1
- package/lib/array/Some.js.map +0 -1
- package/lib/array/Tail.js.map +0 -1
- package/lib/array/UnionOfProps.js.map +0 -1
- package/lib/array/UnionOfValues.js.map +0 -1
- package/lib/array/index.js.map +0 -1
- package/lib/array/literalArray.js.map +0 -1
- package/lib/array/reduceWhile.js.map +0 -1
- package/lib/assertion/assertType.d.ts +0 -78
- package/lib/assertion/assertType.js +0 -107
- package/lib/assertion/assertType.js.map +0 -1
- package/lib/assertion/index.js.map +0 -1
- package/lib/class/AnyConstructor.js.map +0 -1
- package/lib/class/index.js.map +0 -1
- package/lib/class/isConstructor.js +0 -18
- package/lib/class/isConstructor.js.map +0 -1
- package/lib/function/AnyFunction.js.map +0 -1
- package/lib/function/index.js.map +0 -1
- package/lib/functional/ChainFn.js.map +0 -1
- package/lib/functional/index.js.map +0 -1
- package/lib/index.d.ts +0 -19
- package/lib/index.js +0 -48
- package/lib/index.js.map +0 -1
- package/lib/math/Abs.js.map +0 -1
- package/lib/math/Add.js.map +0 -1
- package/lib/math/Digit.js.map +0 -1
- package/lib/math/GreaterThan.js.map +0 -1
- package/lib/math/IsPositive.js.map +0 -1
- package/lib/math/IsWhole.js.map +0 -1
- package/lib/math/Max.js.map +0 -1
- package/lib/math/Subtract.js.map +0 -1
- package/lib/math/index.js.map +0 -1
- package/lib/nominal-types/Brand.js.map +0 -1
- package/lib/nominal-types/Flavor.js.map +0 -1
- package/lib/nominal-types/index.js.map +0 -1
- package/lib/nominal-types/nominalMatch.js.map +0 -1
- package/lib/nominal-types/types.js.map +0 -1
- package/lib/object/ANotB.js.map +0 -1
- package/lib/object/AnyRecord.js.map +0 -1
- package/lib/object/ExcludePropType.js.map +0 -1
- package/lib/object/IsDisjoint.js.map +0 -1
- package/lib/object/IsRecord.js.map +0 -1
- package/lib/object/KeyTypes.js.map +0 -1
- package/lib/object/KeyofOptional.js.map +0 -1
- package/lib/object/KeysWithDiffType.js.map +0 -1
- package/lib/object/KnownKeys.js.map +0 -1
- package/lib/object/OptionalKeys.js.map +0 -1
- package/lib/object/Partial.js.map +0 -1
- package/lib/object/RecursiveIntersect.js.map +0 -1
- package/lib/object/RecursivePartial.js.map +0 -1
- package/lib/object/RecursiveRequired.js.map +0 -1
- package/lib/object/Required.js.map +0 -1
- package/lib/object/RequiredKeys.js.map +0 -1
- package/lib/object/SpreadRecord.js.map +0 -1
- package/lib/object/ValueOf.js.map +0 -1
- package/lib/object/everyKey.js.map +0 -1
- package/lib/object/facade.js.map +0 -1
- package/lib/object/filterKey.js.map +0 -1
- package/lib/object/findKey.js.map +0 -1
- package/lib/object/forEachKey.js.map +0 -1
- package/lib/object/getField.js.map +0 -1
- package/lib/object/hasKey.js.map +0 -1
- package/lib/object/hasProperty.js.map +0 -1
- package/lib/object/index.js.map +0 -1
- package/lib/object/mapKey.js.map +0 -1
- package/lib/object/mapProperties.js +0 -18
- package/lib/object/mapProperties.js.map +0 -1
- package/lib/object/omit.js +0 -17
- package/lib/object/omit.js.map +0 -1
- package/lib/object/pick.js +0 -17
- package/lib/object/pick.js.map +0 -1
- package/lib/object/reduceKey.js.map +0 -1
- package/lib/object/replaceProperty.js.map +0 -1
- package/lib/object/someKey.js.map +0 -1
- package/lib/object/typeOverrideIncompatible.js.map +0 -1
- package/lib/predicates/CanAssign.js.map +0 -1
- package/lib/predicates/Equal.js.map +0 -1
- package/lib/predicates/Extends.js.map +0 -1
- package/lib/predicates/If.js.map +0 -1
- package/lib/predicates/index.js.map +0 -1
- package/lib/predicates/isEmptyObject.js.map +0 -1
- package/lib/predicates/isType.d.ts +0 -20
- package/lib/predicates/isType.js +0 -28
- package/lib/predicates/isType.js.map +0 -1
- package/lib/predicates/logical.js.map +0 -1
- package/lib/promise/PromiseValue.js.map +0 -1
- package/lib/promise/PromiseValueMerge.js.map +0 -1
- package/lib/promise/index.js.map +0 -1
- package/lib/promise/isPromise.js.map +0 -1
- package/lib/promise/mapSeries.js.map +0 -1
- package/lib/types/AllType.d.ts +0 -18
- package/lib/types/AllType.js +0 -3
- package/lib/types/AllType.js.map +0 -1
- package/lib/types/Any.d.ts +0 -6
- package/lib/types/Any.js +0 -5
- package/lib/types/Any.js.map +0 -1
- package/lib/types/Array.d.ts +0 -28
- package/lib/types/Array.js +0 -30
- package/lib/types/Array.js.map +0 -1
- package/lib/types/Boolean.d.ts +0 -29
- package/lib/types/Boolean.js +0 -28
- package/lib/types/Boolean.js.map +0 -1
- package/lib/types/Generate.d.ts +0 -32
- package/lib/types/Generate.js +0 -3
- package/lib/types/Generate.js.map +0 -1
- package/lib/types/Null.d.ts +0 -8
- package/lib/types/Null.js +0 -10
- package/lib/types/Null.js.map +0 -1
- package/lib/types/Number.d.ts +0 -36
- package/lib/types/Number.js +0 -46
- package/lib/types/Number.js.map +0 -1
- package/lib/types/Object.d.ts +0 -329
- package/lib/types/Object.js +0 -35
- package/lib/types/Object.js.map +0 -1
- package/lib/types/Record.d.ts +0 -16
- package/lib/types/Record.js +0 -17
- package/lib/types/Record.js.map +0 -1
- package/lib/types/String.d.ts +0 -36
- package/lib/types/String.js +0 -47
- package/lib/types/String.js.map +0 -1
- package/lib/types/Symbol.d.ts +0 -8
- package/lib/types/Symbol.js +0 -13
- package/lib/types/Symbol.js.map +0 -1
- package/lib/types/Tuple.d.ts +0 -35
- package/lib/types/Tuple.js +0 -39
- package/lib/types/Tuple.js.map +0 -1
- package/lib/types/Undefined.d.ts +0 -6
- package/lib/types/Undefined.js +0 -5
- package/lib/types/Undefined.js.map +0 -1
- package/lib/types/Union.d.ts +0 -20
- package/lib/types/Union.js +0 -48
- package/lib/types/Union.js.map +0 -1
- package/lib/types/Unknown.d.ts +0 -6
- package/lib/types/Unknown.js +0 -5
- package/lib/types/Unknown.js.map +0 -1
- package/lib/types/analyze.d.ts +0 -13
- package/lib/types/analyze.js +0 -158
- package/lib/types/analyze.js.map +0 -1
- package/lib/types/check.d.ts +0 -14
- package/lib/types/check.js +0 -25
- package/lib/types/check.js.map +0 -1
- package/lib/types/conform.d.ts +0 -15
- package/lib/types/conform.js +0 -26
- package/lib/types/conform.js.map +0 -1
- package/lib/types/getPlainAnalysisReport.d.ts +0 -2
- package/lib/types/getPlainAnalysisReport.js +0 -116
- package/lib/types/getPlainAnalysisReport.js.map +0 -1
- package/lib/types/index.d.ts +0 -26
- package/lib/types/index.js +0 -45
- package/lib/types/index.js.map +0 -1
- package/lib/types/optional.d.ts +0 -344
- package/lib/types/optional.js +0 -33
- package/lib/types/optional.js.map +0 -1
- package/lib/types/required.d.ts +0 -696
- package/lib/types/required.js +0 -33
- package/lib/types/required.js.map +0 -1
- package/lib/types/satisfy.d.ts +0 -15
- package/lib/types/satisfy.js +0 -26
- package/lib/types/satisfy.js.map +0 -1
- package/lib/types/types.d.ts +0 -9
- package/lib/types/types.js +0 -3
- package/lib/types/types.js.map +0 -1
- package/lib/utils/Widen.js.map +0 -1
- package/lib/utils/as.js.map +0 -1
- package/lib/utils/index.js.map +0 -1
- package/libm/JSONTypes.js.map +0 -1
- package/libm/PrimitiveTypes.js.map +0 -1
- package/libm/UnionKeys.js.map +0 -1
- package/libm/array/CommonPropKeys.js.map +0 -1
- package/libm/array/Concat.js.map +0 -1
- package/libm/array/CreateTuple.js.map +0 -1
- package/libm/array/DropFirst.js.map +0 -1
- package/libm/array/DropLast.js.map +0 -1
- package/libm/array/Filter.js.map +0 -1
- package/libm/array/FindFirst.js.map +0 -1
- package/libm/array/FindLast.js.map +0 -1
- package/libm/array/Head.js.map +0 -1
- package/libm/array/IntersectOfProps.js.map +0 -1
- package/libm/array/IsArray.js.map +0 -1
- package/libm/array/PadLeft.js.map +0 -1
- package/libm/array/Reverse.js.map +0 -1
- package/libm/array/Some.js.map +0 -1
- package/libm/array/Tail.js.map +0 -1
- package/libm/array/UnionOfProps.js.map +0 -1
- package/libm/array/UnionOfValues.js.map +0 -1
- package/libm/array/index.js.map +0 -1
- package/libm/array/literalArray.js.map +0 -1
- package/libm/array/reduceWhile.js.map +0 -1
- package/libm/assertion/assertType.js.map +0 -1
- package/libm/assertion/index.js.map +0 -1
- package/libm/class/AnyConstructor.js.map +0 -1
- package/libm/class/index.js.map +0 -1
- package/libm/class/isConstructor.js +0 -14
- package/libm/class/isConstructor.js.map +0 -1
- package/libm/function/AnyFunction.js.map +0 -1
- package/libm/function/index.js.map +0 -1
- package/libm/functional/ChainFn.js.map +0 -1
- package/libm/functional/index.js.map +0 -1
- package/libm/index.js +0 -20
- package/libm/index.js.map +0 -1
- package/libm/math/Abs.js.map +0 -1
- package/libm/math/Add.js.map +0 -1
- package/libm/math/Digit.js.map +0 -1
- package/libm/math/GreaterThan.js.map +0 -1
- package/libm/math/IsPositive.js.map +0 -1
- package/libm/math/IsWhole.js.map +0 -1
- package/libm/math/Max.js.map +0 -1
- package/libm/math/Subtract.js.map +0 -1
- package/libm/math/index.js.map +0 -1
- package/libm/nominal-types/Brand.js.map +0 -1
- package/libm/nominal-types/Flavor.js.map +0 -1
- package/libm/nominal-types/index.js.map +0 -1
- package/libm/nominal-types/nominalMatch.js.map +0 -1
- package/libm/nominal-types/types.js.map +0 -1
- package/libm/object/ANotB.js.map +0 -1
- package/libm/object/AnyRecord.js.map +0 -1
- package/libm/object/ExcludePropType.js.map +0 -1
- package/libm/object/IsDisjoint.js.map +0 -1
- package/libm/object/IsRecord.js.map +0 -1
- package/libm/object/KeyTypes.js.map +0 -1
- package/libm/object/KeyofOptional.js.map +0 -1
- package/libm/object/KeysWithDiffType.js.map +0 -1
- package/libm/object/KnownKeys.js.map +0 -1
- package/libm/object/OptionalKeys.js.map +0 -1
- package/libm/object/Partial.js.map +0 -1
- package/libm/object/RecursiveIntersect.js.map +0 -1
- package/libm/object/RecursivePartial.js.map +0 -1
- package/libm/object/RecursiveRequired.js.map +0 -1
- package/libm/object/Required.js.map +0 -1
- package/libm/object/RequiredKeys.js.map +0 -1
- package/libm/object/SpreadRecord.js.map +0 -1
- package/libm/object/ValueOf.js.map +0 -1
- package/libm/object/everyKey.js.map +0 -1
- package/libm/object/facade.js.map +0 -1
- package/libm/object/filterKey.js.map +0 -1
- package/libm/object/findKey.js.map +0 -1
- package/libm/object/forEachKey.js.map +0 -1
- package/libm/object/getField.js.map +0 -1
- package/libm/object/hasKey.js.map +0 -1
- package/libm/object/hasProperty.js.map +0 -1
- package/libm/object/index.js.map +0 -1
- package/libm/object/mapKey.js.map +0 -1
- package/libm/object/mapProperties.js.map +0 -1
- package/libm/object/omit.js.map +0 -1
- package/libm/object/pick.js.map +0 -1
- package/libm/object/reduceKey.js.map +0 -1
- package/libm/object/replaceProperty.js.map +0 -1
- package/libm/object/someKey.js.map +0 -1
- package/libm/object/typeOverrideIncompatible.js.map +0 -1
- package/libm/predicates/CanAssign.js.map +0 -1
- package/libm/predicates/Equal.js.map +0 -1
- package/libm/predicates/Extends.js.map +0 -1
- package/libm/predicates/If.js.map +0 -1
- package/libm/predicates/index.js.map +0 -1
- package/libm/predicates/isEmptyObject.js.map +0 -1
- package/libm/predicates/isType.js.map +0 -1
- package/libm/predicates/logical.js.map +0 -1
- package/libm/promise/PromiseValue.js.map +0 -1
- package/libm/promise/PromiseValueMerge.js.map +0 -1
- package/libm/promise/index.js.map +0 -1
- package/libm/promise/isPromise.js.map +0 -1
- package/libm/promise/mapSeries.js.map +0 -1
- package/libm/types/AllType.js +0 -2
- package/libm/types/AllType.js.map +0 -1
- package/libm/types/Any.js +0 -2
- package/libm/types/Any.js.map +0 -1
- package/libm/types/Array.js +0 -27
- package/libm/types/Array.js.map +0 -1
- package/libm/types/Boolean.js +0 -25
- package/libm/types/Boolean.js.map +0 -1
- package/libm/types/Generate.js +0 -2
- package/libm/types/Generate.js.map +0 -1
- package/libm/types/Null.js +0 -7
- package/libm/types/Null.js.map +0 -1
- package/libm/types/Number.js +0 -30
- package/libm/types/Number.js.map +0 -1
- package/libm/types/Object.js +0 -31
- package/libm/types/Object.js.map +0 -1
- package/libm/types/Record.js +0 -14
- package/libm/types/Record.js.map +0 -1
- package/libm/types/String.js +0 -31
- package/libm/types/String.js.map +0 -1
- package/libm/types/Symbol.js +0 -10
- package/libm/types/Symbol.js.map +0 -1
- package/libm/types/Tuple.js +0 -23
- package/libm/types/Tuple.js.map +0 -1
- package/libm/types/Undefined.js +0 -2
- package/libm/types/Undefined.js.map +0 -1
- package/libm/types/Union.js +0 -32
- package/libm/types/Union.js.map +0 -1
- package/libm/types/Unknown.js +0 -2
- package/libm/types/Unknown.js.map +0 -1
- package/libm/types/analyze.js +0 -142
- package/libm/types/analyze.js.map +0 -1
- package/libm/types/check.js +0 -21
- package/libm/types/check.js.map +0 -1
- package/libm/types/conform.js +0 -22
- package/libm/types/conform.js.map +0 -1
- package/libm/types/getPlainAnalysisReport.js +0 -106
- package/libm/types/getPlainAnalysisReport.js.map +0 -1
- package/libm/types/index.js +0 -28
- package/libm/types/index.js.map +0 -1
- package/libm/types/optional.js +0 -30
- package/libm/types/optional.js.map +0 -1
- package/libm/types/required.js +0 -30
- package/libm/types/required.js.map +0 -1
- package/libm/types/satisfy.js +0 -22
- package/libm/types/satisfy.js.map +0 -1
- package/libm/types/types.js +0 -2
- package/libm/types/types.js.map +0 -1
- package/libm/utils/Widen.js.map +0 -1
- package/libm/utils/as.js.map +0 -1
- package/libm/utils/index.js.map +0 -1
- package/src/JSONTypes.spec.ts +0 -43
- package/src/JSONTypes.ts +0 -18
- package/src/PrimitiveTypes.ts +0 -2
- package/src/UnionToIntersection.ts +0 -7
- package/src/array/CommonPropKeys.spec.ts +0 -20
- package/src/array/CommonPropKeys.ts +0 -18
- package/src/array/Concat.spec.ts +0 -21
- package/src/array/Concat.ts +0 -1
- package/src/array/CreateTuple.spec.ts +0 -21
- package/src/array/CreateTuple.ts +0 -7
- package/src/array/DropFirst.spec.ts +0 -21
- package/src/array/DropFirst.ts +0 -9
- package/src/array/DropLast.spec.ts +0 -21
- package/src/array/DropLast.ts +0 -9
- package/src/array/Filter.spec.ts +0 -21
- package/src/array/Filter.ts +0 -12
- package/src/array/FindFirst.spec.ts +0 -27
- package/src/array/FindFirst.ts +0 -13
- package/src/array/FindLast.spec.ts +0 -27
- package/src/array/FindLast.ts +0 -8
- package/src/array/Head.spec.ts +0 -21
- package/src/array/Head.ts +0 -1
- package/src/array/IntersectOfProps.spec.ts +0 -14
- package/src/array/IntersectOfProps.ts +0 -20
- package/src/array/IsArray.ts +0 -1
- package/src/array/PadLeft.spec.ts +0 -26
- package/src/array/PadLeft.ts +0 -16
- package/src/array/Reverse.spec.ts +0 -17
- package/src/array/Reverse.ts +0 -10
- package/src/array/Some.spec.ts +0 -79
- package/src/array/Some.ts +0 -24
- package/src/array/Tail.spec.ts +0 -32
- package/src/array/Tail.ts +0 -7
- package/src/array/UnionOfProps.spec.ts +0 -14
- package/src/array/UnionOfProps.ts +0 -18
- package/src/array/UnionOfValues.spec.ts +0 -11
- package/src/array/UnionOfValues.ts +0 -10
- package/src/array/index.ts +0 -19
- package/src/assertion/assertType.spec.ts +0 -507
- package/src/assertion/assertType.ts +0 -105
- package/src/assertion/index.ts +0 -1
- package/src/class/AnyConstructor.spec.ts +0 -13
- package/src/class/isConstructor.spec.ts +0 -35
- package/src/class/isConstructor.ts +0 -15
- package/src/function/AnyFunction.spec.ts +0 -21
- package/src/functional/ChainFn.spec.ts +0 -7
- package/src/functional/ChainFn.ts +0 -6
- package/src/functional/Maybe.spec.ts +0 -43
- package/src/functional/Maybe.ts +0 -19
- package/src/functional/index.ts +0 -2
- package/src/index.ts +0 -19
- package/src/math/Abs.spec.ts +0 -14
- package/src/math/Abs.ts +0 -4
- package/src/math/Add.spec.ts +0 -82
- package/src/math/Add.ts +0 -49
- package/src/math/Digit.spec.ts +0 -185
- package/src/math/Digit.ts +0 -115
- package/src/math/GreaterThan.spec.ts +0 -40
- package/src/math/GreaterThan.ts +0 -36
- package/src/math/IsPositive.ts +0 -9
- package/src/math/IsWhole.spec.ts +0 -19
- package/src/math/IsWhole.ts +0 -9
- package/src/math/Max.spec.ts +0 -35
- package/src/math/Max.ts +0 -31
- package/src/math/README.md +0 -7
- package/src/math/Subtract.spec.ts +0 -40
- package/src/math/Subtract.ts +0 -40
- package/src/math/index.ts +0 -7
- package/src/nominal-types/Brand.spec.ts +0 -43
- package/src/nominal-types/Brand.ts +0 -32
- package/src/nominal-types/Flavor.spec.ts +0 -51
- package/src/nominal-types/Flavor.ts +0 -32
- package/src/object/ANotB.ts +0 -21
- package/src/object/ExcludePropType.spec.ts +0 -13
- package/src/object/IsDisjoint.spec.ts +0 -25
- package/src/object/IsDisjoint.ts +0 -12
- package/src/object/IsRecord.spec.ts +0 -22
- package/src/object/IsRecord.ts +0 -4
- package/src/object/KeyofOptional.spec.ts +0 -8
- package/src/object/KeysWithDiffType.spec.ts +0 -21
- package/src/object/KnownKeys.spec.ts +0 -39
- package/src/object/KnownKeys.ts +0 -16
- package/src/object/Partial.spec.ts +0 -49
- package/src/object/RecursiveIntersect.spec.ts +0 -39
- package/src/object/Required.spec.ts +0 -29
- package/src/object/SpreadRecord.spec.ts +0 -14
- package/src/object/SpreadRecord.ts +0 -6
- package/src/object/ValueOf.spec.ts +0 -36
- package/src/object/facade.ts +0 -39
- package/src/object/getField.spec.ts +0 -21
- package/src/object/getField.ts +0 -21
- package/src/object/hasKey.ts +0 -7
- package/src/object/hasProperty.spec.ts +0 -15
- package/src/object/index.ts +0 -35
- package/src/object/mapProperties.spec.ts +0 -27
- package/src/object/omit.spec.ts +0 -104
- package/src/object/omit.ts +0 -36
- package/src/object/pick.spec.ts +0 -66
- package/src/object/pick.ts +0 -35
- package/src/object/typeOverrideIncompatible.spec.ts +0 -24
- package/src/object/typeOverrideIncompatible.ts +0 -10
- package/src/predicates/CanAssign.spec.ts +0 -57
- package/src/predicates/Equal.spec.ts +0 -71
- package/src/predicates/Equal.ts +0 -14
- package/src/predicates/Extends.ts +0 -4
- package/src/predicates/If.spec.ts +0 -14
- package/src/predicates/If.ts +0 -5
- package/src/predicates/index.spec.ts +0 -73
- package/src/predicates/index.ts +0 -17
- package/src/predicates/isEmptyObject.spec.ts +0 -15
- package/src/predicates/isEmptyObject.ts +0 -2
- package/src/predicates/isType.spec.ts +0 -106
- package/src/predicates/isType.ts +0 -30
- package/src/predicates/logical.spec.ts +0 -59
- package/src/predicates/logical.ts +0 -4
- package/src/promise/PromiseValue.spec.ts +0 -6
- package/src/promise/isPromise.ts +0 -4
- package/src/promise/mapSeries.ts +0 -5
- package/src/type-checker/buildTypes.spec.ts +0 -28
- package/src/type-checker/typeChecker.spec.ts +0 -13
- package/src/types/Generate.ts +0 -48
- package/src/types/Number.ts +0 -56
- package/src/types/Object.ts +0 -53
- package/src/types/String.ts +0 -56
- package/src/types/Symbol.ts +0 -19
- package/src/types/Tuple.ts +0 -50
- package/src/types/check.spec.ts +0 -12
- package/src/types/conform.spec.ts +0 -7
- package/src/types/getPlainAnalysisReport.ts +0 -115
- package/src/types/index.ts +0 -28
- package/src/types/optional.ts +0 -30
- package/src/types/required.ts +0 -30
- package/src/types/satisfy.accept.ts +0 -38
- package/src/types/satisfy.spec.ts +0 -599
- package/src/utils/as.spec.ts +0 -24
- package/src/utils/as.ts +0 -7
- package/src/utils/index.ts +0 -2
|
@@ -1,507 +0,0 @@
|
|
|
1
|
-
import a from 'assertron'
|
|
2
|
-
import { AnyConstructor, AnyFunction, assertType, Equal } from '..'
|
|
3
|
-
|
|
4
|
-
describe('assertType()', () => {
|
|
5
|
-
test('input satisfies specified type', () => {
|
|
6
|
-
const subject = { a: 1, b: 2 } as const
|
|
7
|
-
assertType<{ a: 1 }>(subject)
|
|
8
|
-
})
|
|
9
|
-
test('Specify T in the validate function', () => {
|
|
10
|
-
const s: unknown = false
|
|
11
|
-
assertType(s, (s: boolean) => typeof s === 'boolean')
|
|
12
|
-
assertType<boolean>(s)
|
|
13
|
-
})
|
|
14
|
-
test('Specify T at type declaration', () => {
|
|
15
|
-
const s: unknown = false
|
|
16
|
-
assertType<boolean>(s, s => typeof s === 'boolean')
|
|
17
|
-
assertType<boolean>(s)
|
|
18
|
-
})
|
|
19
|
-
test('error message contains info from validator', () => {
|
|
20
|
-
const s: unknown = 1
|
|
21
|
-
a.throws(() => assertType(s, s => typeof s === 'boolean'), e => /subject fails to satisfy s => typeof s === 'boolean'/.test(e))
|
|
22
|
-
})
|
|
23
|
-
test('Class as validator', () => {
|
|
24
|
-
const s: unknown = new Error()
|
|
25
|
-
assertType(s, Error)
|
|
26
|
-
assertType<Error>(s)
|
|
27
|
-
})
|
|
28
|
-
test('Class as validator fails', () => {
|
|
29
|
-
class Foo { }
|
|
30
|
-
const s: unknown = 1
|
|
31
|
-
a.throws(
|
|
32
|
-
() => assertType(s, Foo),
|
|
33
|
-
(e: Error) => /subject fails to satisfy class Foo{}/.test(e.message)
|
|
34
|
-
)
|
|
35
|
-
})
|
|
36
|
-
test('subject can be type any', () => {
|
|
37
|
-
const s: any = false
|
|
38
|
-
assertType<boolean>(s, s => typeof s === 'boolean')
|
|
39
|
-
assertType<boolean>(s)
|
|
40
|
-
})
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
describe('assertType.isUndefined()', () => {
|
|
44
|
-
test('ensure the input type is undefined and nothing else', () => {
|
|
45
|
-
assertType.isUndefined(undefined)
|
|
46
|
-
|
|
47
|
-
// These fails
|
|
48
|
-
// assertType.isUndefined(null)
|
|
49
|
-
// assertType.isUndefined(1)
|
|
50
|
-
// assertType.isUndefined(true)
|
|
51
|
-
// assertType.isUndefined('a')
|
|
52
|
-
// assertType.isUndefined([])
|
|
53
|
-
// assertType.isUndefined({})
|
|
54
|
-
// assertType.isUndefined(undefined as undefined | number)
|
|
55
|
-
// assertType.isUndefined(undefined as unknown)
|
|
56
|
-
})
|
|
57
|
-
test('not undefined throws TypeError', () => {
|
|
58
|
-
a.throws(() => assertType.isUndefined(1 as any), TypeError)
|
|
59
|
-
})
|
|
60
|
-
test('narrow any to undefined', () => {
|
|
61
|
-
const x: any = undefined
|
|
62
|
-
assertType.isUndefined(x)
|
|
63
|
-
assertType.isTrue(true as Equal<undefined, typeof x>)
|
|
64
|
-
})
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
describe('assertType.noUndefined()', () => {
|
|
68
|
-
test('ensure the input type does not contain undefined', () => {
|
|
69
|
-
assertType.noUndefined(null)
|
|
70
|
-
assertType.noUndefined(1)
|
|
71
|
-
assertType.noUndefined(true)
|
|
72
|
-
assertType.noUndefined('a')
|
|
73
|
-
assertType.noUndefined([])
|
|
74
|
-
assertType.noUndefined({})
|
|
75
|
-
|
|
76
|
-
// These fails
|
|
77
|
-
// assertType.noUndefined(undefined)
|
|
78
|
-
// assertType.noUndefined(1 as undefined | number)
|
|
79
|
-
assertType.noUndefined(1 as unknown)
|
|
80
|
-
})
|
|
81
|
-
test('undefined throws TypeError', () => {
|
|
82
|
-
a.throws(() => assertType.noUndefined(undefined as any), TypeError)
|
|
83
|
-
})
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
describe('assertType.isNull()', () => {
|
|
87
|
-
test('ensure the input type is null and nothing else', () => {
|
|
88
|
-
assertType.isNull(null)
|
|
89
|
-
|
|
90
|
-
a.throws(() => assertType.isNull(1 as any), TypeError)
|
|
91
|
-
const x: any = null
|
|
92
|
-
assertType.isNull(x)
|
|
93
|
-
// `x` is narrowed to `null` here
|
|
94
|
-
assertType.isNull(x)
|
|
95
|
-
|
|
96
|
-
// These fails
|
|
97
|
-
// assertType.isNull(undefined)
|
|
98
|
-
// assertType.isNull(1)
|
|
99
|
-
// assertType.isNull(true)
|
|
100
|
-
// assertType.isNull('a')
|
|
101
|
-
// assertType.isNull([])
|
|
102
|
-
// assertType.isNull({})
|
|
103
|
-
// assertType.isNull(null as null | undefined)
|
|
104
|
-
// assertType.isNull(null as unknown)
|
|
105
|
-
})
|
|
106
|
-
test('not null throws TypeError', () => {
|
|
107
|
-
a.throws(() => assertType.isNull(1 as any), TypeError)
|
|
108
|
-
})
|
|
109
|
-
test('narrow any to null', () => {
|
|
110
|
-
const x: any = null
|
|
111
|
-
assertType.isNull(x)
|
|
112
|
-
assertType.isTrue(true as Equal<null, typeof x>)
|
|
113
|
-
})
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
describe('assertType.noNull()', () => {
|
|
117
|
-
test('ensure the input type does not contain null', () => {
|
|
118
|
-
assertType.noNull(undefined)
|
|
119
|
-
assertType.noNull(1)
|
|
120
|
-
assertType.noNull(true)
|
|
121
|
-
assertType.noNull('a')
|
|
122
|
-
assertType.noNull([])
|
|
123
|
-
assertType.noNull({})
|
|
124
|
-
|
|
125
|
-
// These fails
|
|
126
|
-
// assertType.noNull(null)
|
|
127
|
-
// assertType.noNull(undefined as undefined | null)
|
|
128
|
-
})
|
|
129
|
-
test('null throws TypeError', () => {
|
|
130
|
-
a.throws(() => assertType.noNull(null as any), TypeError)
|
|
131
|
-
})
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
describe('assertType.isNumber()', () => {
|
|
135
|
-
test('ensure the input type is number and nothing else', () => {
|
|
136
|
-
assertType.isNumber(0)
|
|
137
|
-
|
|
138
|
-
// These fails
|
|
139
|
-
// assertType.isNumber(undefined)
|
|
140
|
-
// assertType.isNumber(null)
|
|
141
|
-
// assertType.isNumber(true)
|
|
142
|
-
// assertType.isNumber('a')
|
|
143
|
-
// assertType.isNumber([])
|
|
144
|
-
// assertType.isNumber({})
|
|
145
|
-
// assertType.isNumber(1 as number | undefined)
|
|
146
|
-
// assertType.isNumber(1 as unknown)
|
|
147
|
-
})
|
|
148
|
-
test('not number throws TypeError', () => {
|
|
149
|
-
a.throws(() => assertType.isNumber(undefined as any), TypeError)
|
|
150
|
-
})
|
|
151
|
-
test('narrow any to number', () => {
|
|
152
|
-
const x: any = 1
|
|
153
|
-
assertType.isNumber(x)
|
|
154
|
-
assertType.isTrue(true as Equal<number, typeof x>)
|
|
155
|
-
})
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
describe('assertType.noNumber()', () => {
|
|
159
|
-
test('ensure the input type does not contain number', () => {
|
|
160
|
-
assertType.noNumber(undefined)
|
|
161
|
-
assertType.noNumber(null)
|
|
162
|
-
assertType.noNumber(true)
|
|
163
|
-
assertType.noNumber('a')
|
|
164
|
-
assertType.noNumber([])
|
|
165
|
-
assertType.noNumber({})
|
|
166
|
-
|
|
167
|
-
// These fails
|
|
168
|
-
// assertType.noNumber(1)
|
|
169
|
-
// assertType.noNumber(1 as number | undefined)
|
|
170
|
-
})
|
|
171
|
-
test('number throws TypeError', () => {
|
|
172
|
-
a.throws(() => assertType.noNumber(1 as any), TypeError)
|
|
173
|
-
})
|
|
174
|
-
})
|
|
175
|
-
|
|
176
|
-
describe('assertType.isBoolean()', () => {
|
|
177
|
-
test('ensure the input type is boolean and nothing else', () => {
|
|
178
|
-
assertType.isBoolean(true)
|
|
179
|
-
assertType.isBoolean(false)
|
|
180
|
-
|
|
181
|
-
// These fails
|
|
182
|
-
// assertType.isBoolean(undefined)
|
|
183
|
-
// assertType.isBoolean(null)
|
|
184
|
-
// assertType.isBoolean(1)
|
|
185
|
-
// assertType.isBoolean('a')
|
|
186
|
-
// assertType.isBoolean([])
|
|
187
|
-
// assertType.isBoolean({})
|
|
188
|
-
// assertType.isBoolean(true as boolean | undefined)
|
|
189
|
-
})
|
|
190
|
-
test('not boolean throws TypeError', () => {
|
|
191
|
-
a.throws(() => assertType.isBoolean(undefined as any), TypeError)
|
|
192
|
-
})
|
|
193
|
-
test('narrow any to boolean', () => {
|
|
194
|
-
const x: any = true
|
|
195
|
-
assertType.isBoolean(x)
|
|
196
|
-
assertType.isTrue(true as Equal<boolean, typeof x>)
|
|
197
|
-
})
|
|
198
|
-
})
|
|
199
|
-
|
|
200
|
-
describe('assertType.noBoolean()', () => {
|
|
201
|
-
test('ensure the input type does not contain boolean', () => {
|
|
202
|
-
assertType.noBoolean(undefined)
|
|
203
|
-
assertType.noBoolean(null)
|
|
204
|
-
assertType.noBoolean(1)
|
|
205
|
-
assertType.noBoolean('a')
|
|
206
|
-
assertType.noBoolean([])
|
|
207
|
-
assertType.noBoolean({})
|
|
208
|
-
|
|
209
|
-
// These fails
|
|
210
|
-
// assertType.noBoolean(true)
|
|
211
|
-
// assertType.noBoolean(true as boolean | undefined)
|
|
212
|
-
})
|
|
213
|
-
test('boolean throws TypeError', () => {
|
|
214
|
-
a.throws(() => assertType.noBoolean(true as any), TypeError)
|
|
215
|
-
})
|
|
216
|
-
})
|
|
217
|
-
|
|
218
|
-
describe('assertType.isTrue()', () => {
|
|
219
|
-
test('ensure the input type is true and nothing else', () => {
|
|
220
|
-
assertType.isTrue(true)
|
|
221
|
-
|
|
222
|
-
// These fails
|
|
223
|
-
// assertType.isTrue(undefined)
|
|
224
|
-
// assertType.isTrue(null)
|
|
225
|
-
// assertType.isTrue(1)
|
|
226
|
-
// assertType.isTrue('a')
|
|
227
|
-
// assertType.isTrue(false)
|
|
228
|
-
// assertType.isTrue([])
|
|
229
|
-
// assertType.isTrue({})
|
|
230
|
-
// assertType.isTrue(true as true | undefined)
|
|
231
|
-
// assertType.isTrue(true as unknown)
|
|
232
|
-
})
|
|
233
|
-
test('not true throws TypeError', () => {
|
|
234
|
-
a.throws(() => assertType.isTrue(undefined as any), TypeError)
|
|
235
|
-
})
|
|
236
|
-
test('narrow any to true', () => {
|
|
237
|
-
const x: any = true
|
|
238
|
-
assertType.isTrue(x)
|
|
239
|
-
assertType.isTrue(true as Equal<true, typeof x>)
|
|
240
|
-
})
|
|
241
|
-
})
|
|
242
|
-
|
|
243
|
-
describe('assertType.noTrue()', () => {
|
|
244
|
-
test('ensure the input type does not contain boolean', () => {
|
|
245
|
-
assertType.noTrue(false)
|
|
246
|
-
assertType.noTrue(undefined)
|
|
247
|
-
assertType.noTrue(null)
|
|
248
|
-
assertType.noTrue(1)
|
|
249
|
-
assertType.noTrue('a')
|
|
250
|
-
assertType.noTrue([])
|
|
251
|
-
assertType.noTrue({})
|
|
252
|
-
|
|
253
|
-
// These fails
|
|
254
|
-
// assertType.noTrue(true)
|
|
255
|
-
// assertType.noTrue(true as true | undefined)
|
|
256
|
-
// assertType.noTrue(true as boolean | undefined)
|
|
257
|
-
})
|
|
258
|
-
test('true throws TypeError', () => {
|
|
259
|
-
a.throws(() => assertType.noTrue(true as any), TypeError)
|
|
260
|
-
})
|
|
261
|
-
})
|
|
262
|
-
|
|
263
|
-
describe('assertType.isFalse()', () => {
|
|
264
|
-
test('ensure the input type is false and nothing else', () => {
|
|
265
|
-
assertType.isFalse(false)
|
|
266
|
-
|
|
267
|
-
a.throws(() => assertType.isFalse(true as any), TypeError)
|
|
268
|
-
const x: any = false
|
|
269
|
-
assertType.isFalse(x)
|
|
270
|
-
// `x` is narrowed to `true` here
|
|
271
|
-
assertType.isFalse(x)
|
|
272
|
-
|
|
273
|
-
// These fails
|
|
274
|
-
// assertType.isFalse(undefined)
|
|
275
|
-
// assertType.isFalse(null)
|
|
276
|
-
// assertType.isFalse(1)
|
|
277
|
-
// assertType.isFalse('a')
|
|
278
|
-
// assertType.isFalse(false)
|
|
279
|
-
// assertType.isFalse([])
|
|
280
|
-
// assertType.isFalse({})
|
|
281
|
-
// assertType.isFalse(false as false | undefined)
|
|
282
|
-
// assertType.isFalse(false as unknown)
|
|
283
|
-
})
|
|
284
|
-
test('boolean throws TypeError', () => {
|
|
285
|
-
a.throws(() => assertType.noBoolean(true as any), TypeError)
|
|
286
|
-
})
|
|
287
|
-
})
|
|
288
|
-
|
|
289
|
-
describe('assertType.noFalse()', () => {
|
|
290
|
-
test('ensure the input type does not contain boolean', () => {
|
|
291
|
-
assertType.noFalse(true)
|
|
292
|
-
assertType.noFalse(undefined)
|
|
293
|
-
assertType.noFalse(null)
|
|
294
|
-
assertType.noFalse(1)
|
|
295
|
-
assertType.noFalse('a')
|
|
296
|
-
assertType.noFalse([])
|
|
297
|
-
assertType.noFalse({})
|
|
298
|
-
|
|
299
|
-
// These fails
|
|
300
|
-
// assertType.noFalse(false)
|
|
301
|
-
// assertType.noFalse(false as false | undefined)
|
|
302
|
-
// assertType.noFalse(false as boolean | undefined)
|
|
303
|
-
})
|
|
304
|
-
test('false throws TypeError', () => {
|
|
305
|
-
a.throws(() => assertType.noFalse(false as any), TypeError)
|
|
306
|
-
})
|
|
307
|
-
})
|
|
308
|
-
|
|
309
|
-
describe('assertType.isString()', () => {
|
|
310
|
-
test('ensure the input type is string and nothing else', () => {
|
|
311
|
-
assertType.isString('a')
|
|
312
|
-
|
|
313
|
-
// These fails
|
|
314
|
-
// assertType.isString(undefined)
|
|
315
|
-
// assertType.isString(null)
|
|
316
|
-
// assertType.isString(1)
|
|
317
|
-
// assertType.isString(true)
|
|
318
|
-
// assertType.isString([])
|
|
319
|
-
// assertType.isString({})
|
|
320
|
-
// assertType.isString('a' as string | undefined)
|
|
321
|
-
// assertType.isString('a' as unknown)
|
|
322
|
-
})
|
|
323
|
-
test('not string throws TypeError', () => {
|
|
324
|
-
a.throws(() => assertType.isString(undefined as any), TypeError)
|
|
325
|
-
})
|
|
326
|
-
test('narrow any to string', () => {
|
|
327
|
-
const x: any = ''
|
|
328
|
-
assertType.isString(x)
|
|
329
|
-
assertType.isTrue(true as Equal<string, typeof x>)
|
|
330
|
-
})
|
|
331
|
-
})
|
|
332
|
-
|
|
333
|
-
describe('assertType.noString()', () => {
|
|
334
|
-
test('ensure the input type does not contain boolean', () => {
|
|
335
|
-
assertType.noString(undefined)
|
|
336
|
-
assertType.noString(null)
|
|
337
|
-
assertType.noString(1)
|
|
338
|
-
assertType.noString(true)
|
|
339
|
-
assertType.noString([])
|
|
340
|
-
assertType.noString({})
|
|
341
|
-
|
|
342
|
-
// These fails
|
|
343
|
-
// assertType.noString('a')
|
|
344
|
-
// assertType.noString('a' as string | undefined)
|
|
345
|
-
})
|
|
346
|
-
test('string throws TypeError', () => {
|
|
347
|
-
a.throws(() => assertType.noString('' as any), TypeError)
|
|
348
|
-
})
|
|
349
|
-
})
|
|
350
|
-
|
|
351
|
-
describe('assertType.isFunction()', () => {
|
|
352
|
-
test('ensure the input type is function and nothing else', () => {
|
|
353
|
-
assertType.isFunction(() => { })
|
|
354
|
-
assertType.isFunction(function () { })
|
|
355
|
-
|
|
356
|
-
// These fails
|
|
357
|
-
// assertType.isFunction(undefined)
|
|
358
|
-
// assertType.isFunction(null)
|
|
359
|
-
// assertType.isFunction(1)
|
|
360
|
-
// assertType.isFunction('a')
|
|
361
|
-
// assertType.isFunction([])
|
|
362
|
-
// assertType.isFunction({})
|
|
363
|
-
// assertType.isFunction((() => { }) as AnyFunction | undefined)
|
|
364
|
-
})
|
|
365
|
-
test('not function throws TypeError', () => {
|
|
366
|
-
a.throws(() => assertType.isFunction(undefined as any), TypeError)
|
|
367
|
-
})
|
|
368
|
-
test('narrow any to function', () => {
|
|
369
|
-
const x: any = () => { }
|
|
370
|
-
assertType.isFunction(x)
|
|
371
|
-
assertType.isTrue(true as Equal<AnyFunction, typeof x>)
|
|
372
|
-
})
|
|
373
|
-
})
|
|
374
|
-
|
|
375
|
-
describe('assertType.noFunction()', () => {
|
|
376
|
-
test('ensure the input type does not contain function', () => {
|
|
377
|
-
assertType.noFunction(undefined)
|
|
378
|
-
assertType.noFunction(null)
|
|
379
|
-
assertType.noFunction(1)
|
|
380
|
-
assertType.noFunction('a')
|
|
381
|
-
assertType.noFunction([])
|
|
382
|
-
assertType.noFunction({})
|
|
383
|
-
|
|
384
|
-
// These fails
|
|
385
|
-
// assertType.noFunction(() => {})
|
|
386
|
-
// assertType.noFunction((() => {}) as AnyFunction | undefined)
|
|
387
|
-
})
|
|
388
|
-
test('function throws TypeError', () => {
|
|
389
|
-
a.throws(() => assertType.noFunction((() => { }) as any), TypeError)
|
|
390
|
-
})
|
|
391
|
-
})
|
|
392
|
-
|
|
393
|
-
describe('assertType.isConstructor()', () => {
|
|
394
|
-
test('ensure the input type is constructor and nothing else', () => {
|
|
395
|
-
class Foo { }
|
|
396
|
-
assertType.isConstructor(Foo)
|
|
397
|
-
|
|
398
|
-
// These fails
|
|
399
|
-
// assertType.isConstructor(function () { })
|
|
400
|
-
// assertType.isConstructor(undefined)
|
|
401
|
-
// assertType.isConstructor(null)
|
|
402
|
-
// assertType.isConstructor(1)
|
|
403
|
-
// assertType.isConstructor('a')
|
|
404
|
-
// assertType.isConstructor([])
|
|
405
|
-
// assertType.isConstructor({})
|
|
406
|
-
// assertType.isConstructor((() => { }) as AnyFunction | undefined)
|
|
407
|
-
})
|
|
408
|
-
test('not constructor throws TypeError', () => {
|
|
409
|
-
a.throws(() => assertType.isConstructor(undefined as any), TypeError)
|
|
410
|
-
})
|
|
411
|
-
test('narrow any to constructor', () => {
|
|
412
|
-
class Foo { }
|
|
413
|
-
const x: any = Foo
|
|
414
|
-
assertType.isConstructor(x)
|
|
415
|
-
assertType.isTrue(true as Equal<AnyConstructor, typeof x>)
|
|
416
|
-
})
|
|
417
|
-
})
|
|
418
|
-
|
|
419
|
-
describe('assertType.isError()', () => {
|
|
420
|
-
test('ensure the input type is instance of Error and nothing else', () => {
|
|
421
|
-
assertType.isError(new Error('x'))
|
|
422
|
-
|
|
423
|
-
a.throws(() => assertType.isError(false as any), TypeError)
|
|
424
|
-
const x: any = new Error()
|
|
425
|
-
assertType.isError(x)
|
|
426
|
-
// `x` is narrowed to `true` here
|
|
427
|
-
assertType.isError(x)
|
|
428
|
-
|
|
429
|
-
// These fails
|
|
430
|
-
// assertType.isError(undefined)
|
|
431
|
-
// assertType.isError(null)
|
|
432
|
-
// assertType.isError(1)
|
|
433
|
-
// assertType.isError(true)
|
|
434
|
-
// assertType.isError([])
|
|
435
|
-
// assertType.isError({})
|
|
436
|
-
// assertType.isError('a')
|
|
437
|
-
// assertType.isError(new Error() as Error | undefined)
|
|
438
|
-
// assertType.isError(new Error() as unknown)
|
|
439
|
-
})
|
|
440
|
-
|
|
441
|
-
test('not error throws TypeError', () => {
|
|
442
|
-
a.throws(() => assertType.isError(undefined as any), TypeError)
|
|
443
|
-
})
|
|
444
|
-
test('narrow any to Error', () => {
|
|
445
|
-
const x: any = new Error('hello')
|
|
446
|
-
assertType.isError(x)
|
|
447
|
-
assertType.isTrue(true as Equal<Error, typeof x>)
|
|
448
|
-
})
|
|
449
|
-
})
|
|
450
|
-
|
|
451
|
-
describe('assertType.noError()', () => {
|
|
452
|
-
test('ensure the input type does not contain Error', () => {
|
|
453
|
-
assertType.noError(undefined)
|
|
454
|
-
assertType.noError(null)
|
|
455
|
-
assertType.noError(1)
|
|
456
|
-
assertType.noError('a')
|
|
457
|
-
assertType.noError([])
|
|
458
|
-
assertType.noError({})
|
|
459
|
-
|
|
460
|
-
// These fails
|
|
461
|
-
// assertType.noError(new Error('a'))
|
|
462
|
-
// assertType.noError(new Error('a') as Error | undefined)
|
|
463
|
-
})
|
|
464
|
-
test('error instance throws TypeError', () => {
|
|
465
|
-
a.throws(() => assertType.noError(new Error('a') as any), TypeError)
|
|
466
|
-
})
|
|
467
|
-
})
|
|
468
|
-
|
|
469
|
-
describe('assertType.isNever()', () => {
|
|
470
|
-
test('ensure the input type is never and nothing else', () => {
|
|
471
|
-
const s: never = 0 as never
|
|
472
|
-
assertType.isNever(s)
|
|
473
|
-
|
|
474
|
-
// these fails
|
|
475
|
-
// assertType.isNever(undefined)
|
|
476
|
-
// assertType.isNever(null)
|
|
477
|
-
// assertType.isNever(1)
|
|
478
|
-
// assertType.isNever('a')
|
|
479
|
-
// assertType.isNever(false)
|
|
480
|
-
// assertType.isNever([])
|
|
481
|
-
// assertType.isNever({})
|
|
482
|
-
// assertType.isNever(x as any)
|
|
483
|
-
// assertType.isNever(false as never | undefined)
|
|
484
|
-
// assertType.isNever(false as unknown)
|
|
485
|
-
})
|
|
486
|
-
test('boolean throws TypeError', () => {
|
|
487
|
-
a.throws(() => assertType.noBoolean(true as any), TypeError)
|
|
488
|
-
})
|
|
489
|
-
})
|
|
490
|
-
|
|
491
|
-
describe('assertType.custom', () => {
|
|
492
|
-
test('specify T in the validator', () => {
|
|
493
|
-
const isBool = assertType.custom((s: boolean) => typeof s === 'boolean')
|
|
494
|
-
const s: unknown = false
|
|
495
|
-
expect(isBool(s)).toBe(undefined)
|
|
496
|
-
})
|
|
497
|
-
test('specify T at type declaration', () => {
|
|
498
|
-
const isBool = assertType.custom<boolean>(s => typeof s === 'boolean')
|
|
499
|
-
const s: unknown = false
|
|
500
|
-
expect(isBool(s)).toBe(undefined)
|
|
501
|
-
})
|
|
502
|
-
test('error message contains info from validator', () => {
|
|
503
|
-
const isBool = assertType.custom<boolean>(s => typeof s === 'boolean')
|
|
504
|
-
const s: unknown = 1
|
|
505
|
-
a.throws(() => isBool(s), e => /subject fails to satisfy s => typeof s === 'boolean'/.test(e))
|
|
506
|
-
})
|
|
507
|
-
})
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { tersify } from 'tersify'
|
|
2
|
-
import { AnyConstructor, isConstructor } from '../class'
|
|
3
|
-
import { AnyFunction } from '../function'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* assert the subject satisfies the specified type T
|
|
7
|
-
* @type T the type to check against.
|
|
8
|
-
*/
|
|
9
|
-
export function assertType<T>(subject: T): asserts subject is T
|
|
10
|
-
export function assertType<T>(subject: unknown, validator: (s: T) => boolean): asserts subject is T
|
|
11
|
-
export function assertType<T extends new (...args: any) => any>(subject: unknown, constructor: T): asserts subject is InstanceType<T>
|
|
12
|
-
export function assertType(subject: unknown, validator?: (s: any) => boolean) {
|
|
13
|
-
if (validator) {
|
|
14
|
-
if ((isConstructor(validator) && !(subject instanceof validator)) || !validator(subject))
|
|
15
|
-
throw new TypeError(`subject fails to satisfy ${tersify(validator)}`)
|
|
16
|
-
}
|
|
17
|
-
return
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
assertType.isUndefined = function (subject: undefined): asserts subject is undefined {
|
|
21
|
-
if (typeof subject !== 'undefined') throw TypeError(`subject is not undefined`)
|
|
22
|
-
}
|
|
23
|
-
assertType.noUndefined = function <S>(subject: Exclude<S, undefined>): void {
|
|
24
|
-
if (typeof subject === 'undefined') throw TypeError(`subject is undefined`)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
assertType.isNull = function (subject: null): asserts subject is null {
|
|
28
|
-
if (subject !== null) throw TypeError(`subject is not null`)
|
|
29
|
-
}
|
|
30
|
-
assertType.noNull = function <S>(subject: Exclude<S, null>): void {
|
|
31
|
-
if (subject === null) throw TypeError(`subject is null`)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
assertType.isNumber = function (subject: number): asserts subject is number {
|
|
35
|
-
if (typeof subject !== 'number') throw TypeError(`subject is not number`)
|
|
36
|
-
}
|
|
37
|
-
assertType.noNumber = function <S>(subject: Exclude<S, number>): void {
|
|
38
|
-
if (typeof subject === 'number') throw TypeError(`subject is number`)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
assertType.isBoolean = function (subject: boolean): asserts subject is boolean {
|
|
42
|
-
if (typeof subject !== 'boolean') throw TypeError(`subject is not boolean`)
|
|
43
|
-
}
|
|
44
|
-
assertType.noBoolean = function <S>(subject: Exclude<S, boolean>): void {
|
|
45
|
-
if (typeof subject === 'boolean') throw TypeError(`subject is boolean`)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
assertType.isTrue = function (subject: true): asserts subject is true {
|
|
49
|
-
if (subject !== true) throw TypeError(`subject is not true`)
|
|
50
|
-
}
|
|
51
|
-
assertType.noTrue = function <S>(subject: Exclude<S, true>): void {
|
|
52
|
-
// @ts-ignore
|
|
53
|
-
if (subject === true) throw TypeError(`subject is true`)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
assertType.isFalse = function (subject: false): asserts subject is false {
|
|
57
|
-
if (subject !== false) throw TypeError(`subject is not false`)
|
|
58
|
-
}
|
|
59
|
-
assertType.noFalse = function <S>(subject: Exclude<S, false>): void {
|
|
60
|
-
// @ts-ignore
|
|
61
|
-
if (subject === false) throw TypeError(`subject is false`)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
assertType.isString = function (subject: string): asserts subject is string {
|
|
65
|
-
if (typeof subject !== 'string') throw TypeError(`subject is not string`)
|
|
66
|
-
}
|
|
67
|
-
assertType.noString = function <S>(subject: Exclude<S, string>): void {
|
|
68
|
-
if (typeof subject === 'string') throw TypeError(`subject is string`)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
assertType.isFunction = function (subject: AnyFunction): asserts subject is AnyFunction {
|
|
72
|
-
if (typeof subject !== 'function') throw TypeError(`subject is not function`)
|
|
73
|
-
}
|
|
74
|
-
assertType.noFunction = function <S>(subject: Exclude<S, AnyFunction>): void {
|
|
75
|
-
if (typeof subject === 'function') throw TypeError(`subject is function`)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
assertType.isConstructor = function (subject: AnyConstructor): asserts subject is AnyConstructor {
|
|
79
|
-
if (!isConstructor(subject)) throw TypeError(`subject is not a constructor`)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
assertType.isError = function (subject: Error): asserts subject is Error {
|
|
83
|
-
if (!(subject instanceof Error)) throw TypeError(`subject is not an Error`)
|
|
84
|
-
}
|
|
85
|
-
assertType.noError = function <S>(subject: Exclude<S, Error>): void {
|
|
86
|
-
if (subject instanceof Error) throw TypeError(`subject is an Error`)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
assertType.isNever = function (subject: never): asserts subject is never {
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* creates a custom assertion function with standard TypeError.
|
|
94
|
-
* Currently this requires explicity type annotation,
|
|
95
|
-
* thus making it hard to use:
|
|
96
|
-
* https://github.com/microsoft/TypeScript/issues/41047
|
|
97
|
-
*/
|
|
98
|
-
assertType.custom = function <T>(
|
|
99
|
-
validator: (s: T) => boolean
|
|
100
|
-
): (subject: unknown) => asserts subject is T {
|
|
101
|
-
return function (subject) {
|
|
102
|
-
if (!validator(subject as any)) throw new TypeError(`subject fails to satisfy ${tersify(validator)}`)
|
|
103
|
-
return
|
|
104
|
-
}
|
|
105
|
-
}
|
package/src/assertion/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './assertType'
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { AnyConstructor } from '..'
|
|
2
|
-
|
|
3
|
-
test('basic', () => {
|
|
4
|
-
const a = function () { } as any as AnyConstructor
|
|
5
|
-
|
|
6
|
-
new a()
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
test('specify params with tuple', () => {
|
|
10
|
-
const a = function () { } as any as AnyConstructor<[count: number, value: string]>
|
|
11
|
-
|
|
12
|
-
new a(1, 'a')
|
|
13
|
-
})
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { AnyConstructor, assertType, isConstructor } from '..'
|
|
2
|
-
|
|
3
|
-
test('check constructor', () => {
|
|
4
|
-
const x: unknown = Error
|
|
5
|
-
if (isConstructor(x))
|
|
6
|
-
assertType<AnyConstructor>(x)
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
test('check not constructor', () => {
|
|
10
|
-
expect(isConstructor(() => { })).toBe(false)
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
test('check throw function', () => {
|
|
14
|
-
expect(isConstructor(() => { throw new Error() })).toBe(false)
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
test('check throwing constructor is still true', () => {
|
|
18
|
-
class Foo { constructor() { throw new Error() } }
|
|
19
|
-
expect(isConstructor(Foo)).toBe(true)
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
test('constructor throwing non-error', () => {
|
|
23
|
-
class Foo { constructor() { throw 'abc' } }
|
|
24
|
-
expect(isConstructor(Foo)).toBe(true)
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
test('constructor throwing undefined', () => {
|
|
28
|
-
class Foo { constructor() { throw undefined } }
|
|
29
|
-
expect(isConstructor(Foo)).toBe(true)
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
test('class with params returns true', () => {
|
|
33
|
-
class Boo { constructor(public a: number) { } }
|
|
34
|
-
expect(isConstructor(Boo)).toBe(true)
|
|
35
|
-
})
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { AnyConstructor } from './AnyConstructor'
|
|
2
|
-
|
|
3
|
-
export function isConstructor(subject: unknown): subject is AnyConstructor {
|
|
4
|
-
try {
|
|
5
|
-
new (subject as AnyConstructor)()
|
|
6
|
-
}
|
|
7
|
-
catch (err) {
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
9
|
-
const msg = err?.message as string | undefined
|
|
10
|
-
if (msg && msg.indexOf('is not a constructor') >= 0) {
|
|
11
|
-
return false
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return true
|
|
15
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { AnyFunction, assertType } from '..'
|
|
2
|
-
|
|
3
|
-
test('basic', () => {
|
|
4
|
-
function doCallback(cb: AnyFunction) {
|
|
5
|
-
cb()
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
doCallback(() => { })
|
|
9
|
-
doCallback(_ => { })
|
|
10
|
-
doCallback((a: number, b: number) => a + b)
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
test('define param as tuple', () => {
|
|
14
|
-
const foo: AnyFunction<[number, string]> = x => x
|
|
15
|
-
foo(1, 'a')
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
test('define result type', () => {
|
|
19
|
-
const foo: AnyFunction<string[], string> = x => x
|
|
20
|
-
assertType.isString(foo('a'))
|
|
21
|
-
})
|