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
package/ts/object/split.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
2
|
+
import type { AnyRecord } from './AnyRecord.js'
|
|
3
|
+
import type { Omit } from './omit.js'
|
|
4
|
+
import { reduceByKey } from './reduceKey.js'
|
|
4
5
|
|
|
5
6
|
type Splitter<T extends AnyRecord> = Partial<{ [k in keyof T]: T[k] | undefined }>
|
|
6
7
|
export type Split<T extends AnyRecord, S extends AnyRecord> = {
|
|
@@ -195,7 +196,7 @@ export function split(target: AnyRecord, ...splitters: AnyRecord[]): AnyRecord[]
|
|
|
195
196
|
const keyMap: AnyRecord = {}
|
|
196
197
|
const s = splitters.map(s => reduceByKey(
|
|
197
198
|
s,
|
|
198
|
-
(p, k) => (keyMap[k] = true, p[k] = target[k]
|
|
199
|
+
(p, k) => (keyMap[k] = true, p[k] = target[k] ?? s[k], p),
|
|
199
200
|
{} as AnyRecord))
|
|
200
201
|
const r = reduceByKey(target, (p, k) => keyMap[k] ? p : (p[k] = target[k], p), {} as AnyRecord)
|
|
201
202
|
return [...s, r]
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ANotB, AnyRecord } from '.'
|
|
2
|
-
|
|
3
|
-
export function typeOverrideIncompatible<A extends AnyRecord>() {
|
|
4
|
-
return function <B extends AnyRecord>(source: B, override: ANotB<A, B>): A {
|
|
5
|
-
return {
|
|
6
|
-
...source,
|
|
7
|
-
...override,
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
}
|
|
1
|
+
import type { ANotB, AnyRecord } from './index.js'
|
|
2
|
+
|
|
3
|
+
export function typeOverrideIncompatible<A extends AnyRecord>() {
|
|
4
|
+
return function <B extends AnyRecord>(source: B, override: ANotB<A, B>): A {
|
|
5
|
+
return {
|
|
6
|
+
...source,
|
|
7
|
+
...override,
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
package/ts/predicates/index.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export * from './CanAssign'
|
|
2
|
-
export type { Equal, IsEqual, IsNotEqual, NotEqual } from './Equal'
|
|
3
|
-
export type { Extendable, IsExtend, IsNotExtend, NotExtendable } from './Extends'
|
|
4
|
-
export type { If } from './If'
|
|
5
|
-
export * from './isType'
|
|
6
|
-
export type { And, Not, Or, Xor } from './logical'
|
|
7
|
-
export type { IsEmptyObject } from './IsEmptyObject'
|
|
1
|
+
export * from './CanAssign.js'
|
|
2
|
+
export type { Equal, IsEqual, IsNotEqual, NotEqual } from './Equal.js'
|
|
3
|
+
export type { Extendable, IsExtend, IsNotExtend, NotExtendable } from './Extends.js'
|
|
4
|
+
export type { If } from './If.js'
|
|
5
|
+
export * from './isType.js'
|
|
6
|
+
export type { And, Not, Or, Xor } from './logical.js'
|
|
7
|
+
export type { IsEmptyObject } from './IsEmptyObject.js'
|
|
8
8
|
|
|
9
|
-
import { IsExtend } from './Extends'
|
|
9
|
+
import type { IsExtend } from './Extends.js'
|
|
10
10
|
|
|
11
11
|
export type IsLiteral<T extends number | string, Then = true, Else = false> = number extends T ?
|
|
12
12
|
Else :
|
package/ts/predicates/isType.ts
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { AnyConstructor, isConstructor } from '../class'
|
|
2
|
-
import { Equal } from './Equal'
|
|
3
|
-
|
|
4
|
-
export function isType<T>(subject: T): subject is T
|
|
5
|
-
export function isType<T>(subject: unknown, validator: (s: T) => boolean): subject is T
|
|
6
|
-
export function isType<T extends AnyConstructor>(subject: unknown, constructor: T): subject is InstanceType<T>
|
|
7
|
-
export function isType(subject: unknown, validator?: AnyConstructor | ((s: unknown) => boolean)) {
|
|
8
|
-
if (validator) {
|
|
9
|
-
if (isConstructor(validator))
|
|
10
|
-
return subject instanceof validator
|
|
11
|
-
else
|
|
12
|
-
return validator(subject)
|
|
13
|
-
}
|
|
14
|
-
return true
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
isType.t = function <T extends true>(subject?: T) {
|
|
18
|
-
return subject === undefined || subject === true
|
|
19
|
-
}
|
|
20
|
-
isType.f = function <T extends false>(subject?: T) {
|
|
21
|
-
return subject === undefined || subject === false
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* are types A and B equals/not equals.
|
|
26
|
-
* Slightly easier to use then `isType.t<>()` and `isType.f<>()`,
|
|
27
|
-
* when doing type level only equality comparison as you don't have to import `Equal<>`.
|
|
28
|
-
*/
|
|
29
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
30
|
-
isType.equal = function <C extends Equal<A, B>, A, B>() { }
|
|
1
|
+
import { AnyConstructor, isConstructor } from '../class/index.js'
|
|
2
|
+
import type { Equal } from './Equal.js'
|
|
3
|
+
|
|
4
|
+
export function isType<T>(subject: T): subject is T
|
|
5
|
+
export function isType<T>(subject: unknown, validator: (s: T) => boolean): subject is T
|
|
6
|
+
export function isType<T extends AnyConstructor>(subject: unknown, constructor: T): subject is InstanceType<T>
|
|
7
|
+
export function isType(subject: unknown, validator?: AnyConstructor | ((s: unknown) => boolean)) {
|
|
8
|
+
if (validator) {
|
|
9
|
+
if (isConstructor(validator))
|
|
10
|
+
return subject instanceof validator
|
|
11
|
+
else
|
|
12
|
+
return validator(subject)
|
|
13
|
+
}
|
|
14
|
+
return true
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
isType.t = function <T extends true>(subject?: T) {
|
|
18
|
+
return subject === undefined || subject === true
|
|
19
|
+
}
|
|
20
|
+
isType.f = function <T extends false>(subject?: T) {
|
|
21
|
+
return subject === undefined || subject === false
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* are types A and B equals/not equals.
|
|
26
|
+
* Slightly easier to use then `isType.t<>()` and `isType.f<>()`,
|
|
27
|
+
* when doing type level only equality comparison as you don't have to import `Equal<>`.
|
|
28
|
+
*/
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
30
|
+
isType.equal = function <C extends Equal<A, B>, A, B>() { }
|
package/ts/promise/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './isPromise'
|
|
2
|
-
export type { PromiseValue } from './PromiseValue'
|
|
3
|
-
export type { PromiseValueMerge } from './PromiseValueMerge'
|
|
4
|
-
export * from './mapSeries'
|
|
1
|
+
export * from './isPromise.js'
|
|
2
|
+
export type { PromiseValue } from './PromiseValue.js'
|
|
3
|
+
export type { PromiseValueMerge } from './PromiseValueMerge.js'
|
|
4
|
+
export * from './mapSeries.js'
|
package/ts/testing/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './stub'
|
|
1
|
+
export * from './stub.js'
|
package/ts/testing/stub.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { requiredDeep } from 'unpartial'
|
|
2
|
-
import { AnyFunction } from '../function'
|
|
3
|
-
import { RecursivePartial } from '../object'
|
|
2
|
+
import type { AnyFunction } from '../function/index.js'
|
|
3
|
+
import type { RecursivePartial } from '../object/index.js'
|
|
4
4
|
|
|
5
5
|
export namespace stub {
|
|
6
6
|
export type Param<T> = T extends AnyFunction ? T : RecursivePartial<T>
|
package/ts/utils/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './as'
|
|
2
|
-
export type { NonNull } from './NonNull'
|
|
3
|
-
export type { NonUndefined } from './NonUndefined'
|
|
4
|
-
export type { Widen } from './Widen'
|
|
1
|
+
export * from './as.js'
|
|
2
|
+
export type { NonNull } from './NonNull.js'
|
|
3
|
+
export type { NonUndefined } from './NonUndefined.js'
|
|
4
|
+
export type { Widen } from './Widen.js'
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { assertType, canAssign, ComposableTypes, NonComposableTypes } from '.'
|
|
2
|
-
|
|
3
|
-
test('ComposableTypes includes object, array, and function', () => {
|
|
4
|
-
assertType<ComposableTypes>({})
|
|
5
|
-
assertType<ComposableTypes>([])
|
|
6
|
-
// function is composable because you can do
|
|
7
|
-
// `Object.assign(fn, { ... })
|
|
8
|
-
assertType<ComposableTypes>(() => { })
|
|
9
|
-
|
|
10
|
-
assertType.isTrue(canAssign<ComposableTypes>(false)(null))
|
|
11
|
-
assertType.isTrue(canAssign<ComposableTypes>(false)(undefined))
|
|
12
|
-
assertType.isTrue(canAssign<ComposableTypes>(false)(1))
|
|
13
|
-
assertType.isTrue(canAssign<ComposableTypes>(false)(true))
|
|
14
|
-
assertType.isTrue(canAssign<ComposableTypes>(false)(''))
|
|
15
|
-
assertType.isTrue(canAssign<ComposableTypes>(false)(Symbol()))
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
test('NonComposableType excludes object, array, and function', () => {
|
|
19
|
-
assertType<NonComposableTypes>(null)
|
|
20
|
-
assertType<NonComposableTypes>(undefined)
|
|
21
|
-
assertType<NonComposableTypes>(true)
|
|
22
|
-
assertType<NonComposableTypes>(1)
|
|
23
|
-
assertType<NonComposableTypes>('')
|
|
24
|
-
assertType<NonComposableTypes>(Symbol())
|
|
25
|
-
|
|
26
|
-
assertType.isTrue(canAssign<NonComposableTypes>(false)({}))
|
|
27
|
-
assertType.isTrue(canAssign<NonComposableTypes>(false)([]))
|
|
28
|
-
assertType.isTrue(canAssign<NonComposableTypes>(false)(() => { }))
|
|
29
|
-
})
|
package/ts/JSONTypes.spec.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { assertType } from './assertion'
|
|
2
|
-
import { JSONObject, JSONTypes } from './JSONTypes'
|
|
3
|
-
import { isType } from './predicates'
|
|
4
|
-
|
|
5
|
-
test('empty object', () => {
|
|
6
|
-
assertType<JSONTypes>({})
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
test('empty array', () => {
|
|
10
|
-
assertType<JSONTypes>([])
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
test('string array', () => {
|
|
14
|
-
assertType<JSONTypes>(['a'])
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
test('JSONObject', () => {
|
|
18
|
-
isType<JSONObject>({})
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
describe('JSONTypes.get', () => {
|
|
22
|
-
test('cast to T | undefined without props', () => {
|
|
23
|
-
const a = JSONTypes.get<string>('abc')
|
|
24
|
-
isType<string | undefined>(a)
|
|
25
|
-
expect(a).toBe('abc')
|
|
26
|
-
})
|
|
27
|
-
test('get object props', () => {
|
|
28
|
-
const a = JSONTypes.get<string>({ a: { b: 'abc' } }, 'a', 'b')
|
|
29
|
-
isType<string | undefined>(a)
|
|
30
|
-
expect(a).toBe('abc')
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
test('get array entry', () => {
|
|
34
|
-
const a = JSONTypes.get<string>(['abc'], 0)
|
|
35
|
-
isType<string | undefined>(a)
|
|
36
|
-
expect(a).toBe('abc')
|
|
37
|
-
})
|
|
38
|
-
test('nested', () => {
|
|
39
|
-
const a = JSONTypes.get<string>({ a: { b: [{ c: 'abc' }] } }, 'a', 'b', 0, 'c')
|
|
40
|
-
isType<string | undefined>(a)
|
|
41
|
-
expect(a).toBe('abc')
|
|
42
|
-
})
|
|
43
|
-
})
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { assertType, CommonPropKeys, Equal } from '..'
|
|
2
|
-
|
|
3
|
-
test('no common key returns never', () => {
|
|
4
|
-
type S = [{ a: number }, { b: number }]
|
|
5
|
-
type A = CommonPropKeys<S>
|
|
6
|
-
assertType.isTrue(true as Equal<A, never>)
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
test('single common key', () => {
|
|
10
|
-
type S = [{ a: number, c: number }, { a: number, b: number }]
|
|
11
|
-
type A = CommonPropKeys<S>
|
|
12
|
-
assertType.isTrue(true as Equal<A, 'a'>)
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
test('multiple common keys', () => {
|
|
16
|
-
type S = [{ a: number, b: number }, { a: number, b: number }]
|
|
17
|
-
|
|
18
|
-
type A = CommonPropKeys<S>
|
|
19
|
-
assertType.isTrue(true as Equal<A, 'a' | 'b'>)
|
|
20
|
-
})
|
package/ts/array/Concat.spec.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Concat, Equal, isType } from '..'
|
|
2
|
-
|
|
3
|
-
test('concat array', () => {
|
|
4
|
-
type A = Concat<string[], boolean[]>
|
|
5
|
-
isType.t<Equal<Array<string | boolean>, A>>()
|
|
6
|
-
})
|
|
7
|
-
|
|
8
|
-
test('concat tuples', () => {
|
|
9
|
-
type A = Concat<[1, 2, 3], [4, 5]>
|
|
10
|
-
isType.t<Equal<[1, 2, 3, 4, 5], A>>()
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
test('concat array to tuple', () => {
|
|
14
|
-
type A = Concat<string[], [1, 2, 3]>
|
|
15
|
-
isType.t<Equal<Array<string | 1 | 2 | 3>, A>>()
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
test('concat tuple to array', () => {
|
|
19
|
-
type A = Concat<[1, 2, 3], string[]>
|
|
20
|
-
isType.t<Equal<[1, 2, 3, ...string[]], A>>()
|
|
21
|
-
})
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { CreateTuple, isType } from '..'
|
|
2
|
-
|
|
3
|
-
test('create empty tuple', () => {
|
|
4
|
-
isType.equal<true, [], CreateTuple<0>>()
|
|
5
|
-
})
|
|
6
|
-
|
|
7
|
-
test('single element', () => {
|
|
8
|
-
isType.equal<true, [any], CreateTuple<1>>()
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
test('multiple elements', () => {
|
|
12
|
-
type A = CreateTuple<3>
|
|
13
|
-
isType.equal<true, [any, any, any], A>()
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
test('override element type', () => {
|
|
17
|
-
type A = CreateTuple<5, 1>
|
|
18
|
-
isType.equal<true, [1, 1, 1, 1, 1], A>()
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
test('negative length gets never', () => {
|
|
22
|
-
isType.equal<true, never, CreateTuple<-1>>()
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
test('Can create tuple up to 7000', () => {
|
|
26
|
-
type A = CreateTuple<7000>['length']
|
|
27
|
-
|
|
28
|
-
isType.equal<true, 7000, A>()
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
test('L = number gets array', () => {
|
|
32
|
-
type A = CreateTuple<number, 1>
|
|
33
|
-
isType.equal<true, 1[], A>()
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
test('Non whole number gets never', () => {
|
|
37
|
-
type A = CreateTuple<1.2>
|
|
38
|
-
|
|
39
|
-
isType.equal<true, never, A>()
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
test('can specify fail type', () => {
|
|
43
|
-
type A = CreateTuple<1.2, 1, null>
|
|
44
|
-
|
|
45
|
-
isType.equal<true, null, A>()
|
|
46
|
-
})
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { DropFirst, isType } from '..'
|
|
2
|
-
|
|
3
|
-
test('drop from empty gets itself', () => {
|
|
4
|
-
isType.equal<true, string[], DropFirst<string[]>>()
|
|
5
|
-
})
|
|
6
|
-
|
|
7
|
-
test('drop first value type from tuple', () => {
|
|
8
|
-
type Actual = DropFirst<[true, 1, 'x', 3]>
|
|
9
|
-
isType.equal<true, [1, 'x', 3], Actual>()
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
test('drop only value gets never[]', () => {
|
|
13
|
-
type Actual = DropFirst<['x']>
|
|
14
|
-
isType.equal<true, never[], Actual>()
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
test('array type gets itself', () => {
|
|
18
|
-
const s: string[] = ['a', 'b', 'c']
|
|
19
|
-
type Actual = DropFirst<typeof s>
|
|
20
|
-
isType.equal<true, string[], Actual>()
|
|
21
|
-
})
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { DropLast, isType } from '..'
|
|
2
|
-
|
|
3
|
-
test('drop from empty gets itself', () => {
|
|
4
|
-
isType.equal<true, string[], DropLast<string[]>>()
|
|
5
|
-
})
|
|
6
|
-
|
|
7
|
-
test('drop first value type from tuple', () => {
|
|
8
|
-
type Actual = DropLast<[true, 1, 'x', 3]>
|
|
9
|
-
isType.equal<true, [true, 1, 'x'], Actual>()
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
test('drop only value gets never[]', () => {
|
|
13
|
-
type Actual = DropLast<['x']>
|
|
14
|
-
isType.equal<true, never[], Actual>()
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
test('array type gets itself', () => {
|
|
18
|
-
const s: string[] = ['a', 'b', 'c']
|
|
19
|
-
type Actual = DropLast<typeof s>
|
|
20
|
-
isType.equal<true, string[], Actual>()
|
|
21
|
-
})
|
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
import { drop, DropMatch, DropNull, DropNullable, DropUndefined, isType } from '..'
|
|
2
|
-
|
|
3
|
-
describe('DropMatch<A, C>', () => {
|
|
4
|
-
describe('A is array', () => {
|
|
5
|
-
test('drop all types gets never[]', () => {
|
|
6
|
-
type A = DropMatch<Array<string>, string>
|
|
7
|
-
isType.equal<true, never[], A>()
|
|
8
|
-
|
|
9
|
-
type B = DropMatch<Array<string | boolean>, string | boolean>
|
|
10
|
-
isType.equal<true, never[], B>()
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
test('drop undefined and null from array', () => {
|
|
14
|
-
type A = DropMatch<Array<string | undefined>, undefined>
|
|
15
|
-
isType.equal<true, string[], A>()
|
|
16
|
-
|
|
17
|
-
type B = DropMatch<Array<string | number | undefined>, undefined>
|
|
18
|
-
isType.equal<true, Array<string | number>, B>()
|
|
19
|
-
|
|
20
|
-
type C = DropMatch<Array<string | number | undefined | null>, undefined | null>
|
|
21
|
-
isType.equal<true, Array<string | number>, C>()
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
test('can get undefined and null array when other types dropped', () => {
|
|
25
|
-
type A = DropMatch<Array<string | undefined>, string>
|
|
26
|
-
isType.equal<true, undefined[], A>()
|
|
27
|
-
|
|
28
|
-
type B = DropMatch<Array<string | number | null>, string>
|
|
29
|
-
isType.equal<true, Array<number | null>, B>()
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
test('unmatched criteria returns original', () => {
|
|
33
|
-
type Actual = DropMatch<Array<string | undefined>, number>
|
|
34
|
-
|
|
35
|
-
isType.equal<true, Array<string | undefined>, Actual>()
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
test('drop all narrow types', () => {
|
|
39
|
-
type A = DropMatch<Array<1 | 2 | 3>, number>
|
|
40
|
-
isType.equal<true, never[], A>()
|
|
41
|
-
|
|
42
|
-
type B = DropMatch<Array<1 | 2 | 3 | string>, number>
|
|
43
|
-
isType.equal<true, string[], B>()
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
test('will not drop widen type', () => {
|
|
48
|
-
type A = DropMatch<Array<number>, 1>
|
|
49
|
-
isType.equal<true, number[], A>()
|
|
50
|
-
|
|
51
|
-
type B = DropMatch<Array<string | 'foo'>, 'foo'>
|
|
52
|
-
isType.equal<true, string[], B>()
|
|
53
|
-
|
|
54
|
-
// C is currently `string[] | string[]` (TypeScript 4.6.2)
|
|
55
|
-
// It does not collapse to `string[]`
|
|
56
|
-
// type C = DropMatch<Array<string | 'foo'>, 'foo' | 'boo'>
|
|
57
|
-
// Here `string[] | string[]` literal collapses to `string[]`
|
|
58
|
-
// commenting this out as it will likely be improved in future versions of TypeScript
|
|
59
|
-
// isType.equal<true, string[] | string[], C>()
|
|
60
|
-
})
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
describe('A is Tuple', () => {
|
|
64
|
-
test('empty tuple', () => {
|
|
65
|
-
type A = DropMatch<[], undefined>
|
|
66
|
-
isType.equal<true, [], A>()
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
test('drop undefined from tuple', () => {
|
|
70
|
-
type A = DropMatch<[undefined], undefined>
|
|
71
|
-
isType.equal<true, [], A>()
|
|
72
|
-
|
|
73
|
-
type B = DropMatch<[1, undefined], undefined>
|
|
74
|
-
isType.equal<true, [1], B>()
|
|
75
|
-
|
|
76
|
-
type C = DropMatch<[1, undefined, 3], undefined>
|
|
77
|
-
isType.equal<true, [1, 3], C>()
|
|
78
|
-
|
|
79
|
-
type D = DropMatch<[1, string | undefined, 3], undefined>
|
|
80
|
-
isType.equal<true, [1, string, 3], D>()
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
test('drop undefined from readonly tuple', () => {
|
|
84
|
-
type A = DropMatch<readonly [undefined], undefined>
|
|
85
|
-
isType.equal<true, [], A>()
|
|
86
|
-
|
|
87
|
-
type B = DropMatch<[1, undefined], undefined>
|
|
88
|
-
isType.equal<true, [1], B>()
|
|
89
|
-
|
|
90
|
-
type C = DropMatch<[1, undefined, 3], undefined>
|
|
91
|
-
isType.equal<true, [1, 3], C>()
|
|
92
|
-
|
|
93
|
-
type D = DropMatch<[1, string | undefined, 3], undefined>
|
|
94
|
-
isType.equal<true, [1, string, 3], D>()
|
|
95
|
-
})
|
|
96
|
-
|
|
97
|
-
test('drop undefined keep null', () => {
|
|
98
|
-
type A = DropMatch<[undefined | null], undefined>
|
|
99
|
-
isType.equal<true, [null], A>()
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
test('drop null keep undefined', () => {
|
|
103
|
-
type A = DropMatch<[undefined | null], null>
|
|
104
|
-
isType.equal<true, [undefined], A>()
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
test('drop both null and undefined', () => {
|
|
108
|
-
type A = DropMatch<[undefined | null], null | undefined>
|
|
109
|
-
isType.equal<true, [], A>()
|
|
110
|
-
|
|
111
|
-
type B = DropMatch<[undefined | null | string], null | undefined>
|
|
112
|
-
isType.equal<true, [string], B>()
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
test('get original if not matched', () => {
|
|
116
|
-
type A = DropMatch<[1], undefined>
|
|
117
|
-
isType.equal<true, [1], A>()
|
|
118
|
-
|
|
119
|
-
type B = DropMatch<[1], undefined | string>
|
|
120
|
-
isType.equal<true, [1], B>()
|
|
121
|
-
|
|
122
|
-
type C = DropMatch<[1, 2, 3, 4], 5>
|
|
123
|
-
isType.equal<true, [1, 2, 3, 4], C>()
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
test('drop narrow type', () => {
|
|
127
|
-
type C = DropMatch<[1], number>
|
|
128
|
-
isType.equal<true, [], C>()
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
test('keep widen type', () => {
|
|
132
|
-
type D = DropMatch<[number], 1>
|
|
133
|
-
isType.equal<true, [number], D>()
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
test('drop type from tuple', () => {
|
|
137
|
-
type A = DropMatch<[1], 1>
|
|
138
|
-
isType.equal<true, [], A>()
|
|
139
|
-
|
|
140
|
-
type B = DropMatch<[number | string], number>
|
|
141
|
-
isType.equal<true, [string], B>()
|
|
142
|
-
|
|
143
|
-
type C = DropMatch<[1, undefined, 3], 1>
|
|
144
|
-
isType.equal<true, [undefined, 3], C>()
|
|
145
|
-
|
|
146
|
-
type D = DropMatch<[1, string | undefined, 3], 3>
|
|
147
|
-
isType.equal<true, [1, string | undefined], D>()
|
|
148
|
-
})
|
|
149
|
-
|
|
150
|
-
test('drop multiple types', () => {
|
|
151
|
-
type Actual = DropMatch<[1, 2, 3, 4], 2 | 4>
|
|
152
|
-
isType.equal<true, [1, 3], Actual>()
|
|
153
|
-
})
|
|
154
|
-
|
|
155
|
-
test('drop undefined and null', () => {
|
|
156
|
-
type Actual = DropMatch<[1, undefined, 3, null], undefined | null>
|
|
157
|
-
isType.equal<true, [1, 3], Actual>()
|
|
158
|
-
})
|
|
159
|
-
})
|
|
160
|
-
})
|
|
161
|
-
|
|
162
|
-
describe('DropUndefined<A>', () => {
|
|
163
|
-
test('drop from array type', () => {
|
|
164
|
-
type A = DropUndefined<Array<string | undefined>>
|
|
165
|
-
isType.equal<true, string[], A>()
|
|
166
|
-
|
|
167
|
-
type B = DropUndefined<Array<string | number>>
|
|
168
|
-
isType.equal<true, Array<string | number>, B>()
|
|
169
|
-
|
|
170
|
-
type C = DropUndefined<Array<string | number | undefined | null>>
|
|
171
|
-
isType.equal<true, Array<string | number | null>, C>()
|
|
172
|
-
})
|
|
173
|
-
|
|
174
|
-
test('drop from tuple type', () => {
|
|
175
|
-
type A = DropUndefined<[string, undefined, number, null]>
|
|
176
|
-
isType.equal<true, [string, number, null], A>()
|
|
177
|
-
})
|
|
178
|
-
})
|
|
179
|
-
|
|
180
|
-
describe('DropNull<A>', () => {
|
|
181
|
-
test('drop from array type', () => {
|
|
182
|
-
type A = DropNull<Array<string | null>>
|
|
183
|
-
isType.equal<true, string[], A>()
|
|
184
|
-
|
|
185
|
-
type B = DropNull<Array<string | number>>
|
|
186
|
-
isType.equal<true, Array<string | number>, B>()
|
|
187
|
-
|
|
188
|
-
type C = DropNull<Array<string | number | undefined | null>>
|
|
189
|
-
isType.equal<true, Array<string | number | undefined>, C>()
|
|
190
|
-
})
|
|
191
|
-
|
|
192
|
-
test('drop from tuple type', () => {
|
|
193
|
-
type A = DropNull<[string, undefined, number, null]>
|
|
194
|
-
isType.equal<true, [string, undefined, number], A>()
|
|
195
|
-
})
|
|
196
|
-
})
|
|
197
|
-
|
|
198
|
-
describe('DropNullable<A>', () => {
|
|
199
|
-
test('drop from array type', () => {
|
|
200
|
-
type A = DropNullable<Array<string | null>>
|
|
201
|
-
isType.equal<true, string[], A>()
|
|
202
|
-
|
|
203
|
-
type B = DropNullable<Array<string | number>>
|
|
204
|
-
isType.equal<true, Array<string | number>, B>()
|
|
205
|
-
|
|
206
|
-
type C = DropNullable<Array<string | number | undefined | null>>
|
|
207
|
-
isType.equal<true, Array<string | number>, C>()
|
|
208
|
-
})
|
|
209
|
-
|
|
210
|
-
test('drop from tuple type', () => {
|
|
211
|
-
type A = DropNullable<[string, undefined, number, null]>
|
|
212
|
-
isType.equal<true, [string, number], A>()
|
|
213
|
-
})
|
|
214
|
-
})
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
describe('drop()', () => {
|
|
218
|
-
test('array', () => {
|
|
219
|
-
const a = drop([1, 'a', 3, 4], 'a')
|
|
220
|
-
expect(a).toEqual([1, 3, 4])
|
|
221
|
-
isType.equal<true, number[], typeof a>()
|
|
222
|
-
})
|
|
223
|
-
test('tuple', () => {
|
|
224
|
-
const a = drop([1, 2, 3, 4] as const, 1 as const)
|
|
225
|
-
expect(a).toEqual([2, 3, 4])
|
|
226
|
-
isType.equal<true, [2, 3, 4], typeof a>()
|
|
227
|
-
})
|
|
228
|
-
|
|
229
|
-
test('drop undefined from tuple', () => {
|
|
230
|
-
const a = drop([1, undefined, 3, undefined, 4] as const, undefined)
|
|
231
|
-
expect(a).toEqual([1, 3, 4])
|
|
232
|
-
isType.equal<true, [1, 3, 4], typeof a>()
|
|
233
|
-
})
|
|
234
|
-
})
|