@duplojs/utils 1.3.32 → 1.4.33
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/dist/array/at/default.d.ts +32 -0
- package/dist/array/at/first.cjs +3 -0
- package/dist/array/at/first.d.ts +25 -0
- package/dist/array/at/first.mjs +3 -0
- package/dist/array/at/last.cjs +3 -0
- package/dist/array/at/last.d.ts +25 -0
- package/dist/array/at/last.mjs +3 -0
- package/dist/array/chunk.d.ts +27 -0
- package/dist/array/coalescing.cjs +3 -0
- package/dist/array/coalescing.d.ts +22 -0
- package/dist/array/coalescing.mjs +3 -0
- package/dist/array/concat.d.ts +28 -0
- package/dist/array/copyWithin.d.ts +31 -0
- package/dist/array/every.d.ts +37 -0
- package/dist/array/fill/all.d.ts +36 -0
- package/dist/array/fill/default.d.ts +36 -0
- package/dist/array/filter.d.ts +33 -0
- package/dist/array/find.d.ts +34 -0
- package/dist/array/findAndReplace.d.ts +40 -0
- package/dist/array/findAndSplice/delete.d.ts +40 -0
- package/dist/array/findAndSplice/insert.d.ts +40 -0
- package/dist/array/findAndSplice/replace.d.ts +40 -0
- package/dist/array/findIndex.d.ts +37 -0
- package/dist/array/findLast.d.ts +39 -0
- package/dist/array/findLastIndex.d.ts +37 -0
- package/dist/array/flat.d.ts +32 -0
- package/dist/array/flatMap.d.ts +37 -0
- package/dist/array/from.cjs +3 -0
- package/dist/array/from.d.ts +33 -0
- package/dist/array/from.mjs +3 -0
- package/dist/array/group.d.ts +67 -0
- package/dist/array/includes.d.ts +40 -0
- package/dist/array/index.cjs +3 -1
- package/dist/array/index.d.ts +27 -0
- package/dist/array/index.mjs +4 -0
- package/dist/array/indexOf.d.ts +38 -0
- package/dist/array/insert.d.ts +34 -0
- package/dist/array/is.cjs +3 -0
- package/dist/array/is.d.ts +25 -0
- package/dist/array/is.mjs +3 -0
- package/dist/array/isLastIndex.d.ts +28 -0
- package/dist/array/join.d.ts +35 -0
- package/dist/array/lastIndexOf.d.ts +37 -0
- package/dist/array/length.cjs +3 -0
- package/dist/array/length.d.ts +24 -0
- package/dist/array/length.mjs +3 -0
- package/dist/array/lengthEqual.d.ts +44 -0
- package/dist/array/map.d.ts +33 -0
- package/dist/array/maxElements.d.ts +33 -0
- package/dist/array/maxOf.cjs +3 -0
- package/dist/array/maxOf.d.ts +28 -0
- package/dist/array/maxOf.mjs +3 -0
- package/dist/array/minElements.d.ts +47 -0
- package/dist/array/minOf.cjs +3 -0
- package/dist/array/minOf.d.ts +28 -0
- package/dist/array/minOf.mjs +3 -0
- package/dist/array/notIncludes.d.ts +41 -0
- package/dist/array/pop.cjs +3 -0
- package/dist/array/pop.d.ts +31 -0
- package/dist/array/pop.mjs +3 -0
- package/dist/array/push.d.ts +38 -0
- package/dist/array/reduce.cjs +3 -0
- package/dist/array/reduce.d.ts +74 -0
- package/dist/array/reduce.mjs +3 -0
- package/dist/array/reduceRight.d.ts +39 -0
- package/dist/array/reverse.cjs +3 -0
- package/dist/array/reverse.d.ts +31 -0
- package/dist/array/reverse.mjs +3 -0
- package/dist/array/select.d.ts +39 -0
- package/dist/array/set.d.ts +39 -0
- package/dist/array/shift.cjs +3 -0
- package/dist/array/shift.d.ts +31 -0
- package/dist/array/shift.mjs +3 -0
- package/dist/array/slice.d.ts +36 -0
- package/dist/array/some.d.ts +44 -0
- package/dist/array/sort.d.ts +29 -0
- package/dist/array/splice/delete.d.ts +32 -0
- package/dist/array/splice/insert.d.ts +39 -0
- package/dist/array/splice/replace.d.ts +39 -0
- package/dist/array/sum.cjs +3 -0
- package/dist/array/sum.d.ts +22 -0
- package/dist/array/sum.mjs +3 -0
- package/dist/array/toTuple.d.ts +33 -0
- package/dist/array/unshift.d.ts +38 -0
- package/dist/clean/constraint/base.cjs +3 -0
- package/dist/clean/constraint/base.d.ts +106 -0
- package/dist/clean/constraint/base.mjs +3 -0
- package/dist/clean/constraint/defaultConstraint/number.cjs +9 -0
- package/dist/clean/constraint/defaultConstraint/number.d.ts +81 -0
- package/dist/clean/constraint/defaultConstraint/number.mjs +9 -0
- package/dist/clean/constraint/defaultConstraint/string.cjs +6 -0
- package/dist/clean/constraint/defaultConstraint/string.d.ts +54 -0
- package/dist/clean/constraint/defaultConstraint/string.mjs +6 -0
- package/dist/clean/entity.cjs +3 -0
- package/dist/clean/entity.d.ts +141 -0
- package/dist/clean/entity.mjs +3 -0
- package/dist/clean/flag.cjs +3 -0
- package/dist/clean/flag.d.ts +96 -0
- package/dist/clean/flag.mjs +3 -0
- package/dist/clean/index.cjs +3 -1
- package/dist/clean/index.d.ts +25 -0
- package/dist/clean/index.mjs +4 -0
- package/dist/clean/kind.cjs +3 -0
- package/dist/clean/kind.d.ts +33 -0
- package/dist/clean/kind.mjs +3 -0
- package/dist/clean/newType.cjs +3 -0
- package/dist/clean/newType.d.ts +106 -0
- package/dist/clean/newType.mjs +3 -0
- package/dist/clean/primitive/base.cjs +18 -0
- package/dist/clean/primitive/base.d.ts +242 -0
- package/dist/clean/primitive/base.mjs +18 -0
- package/dist/clean/primitive/operations/date/dateAddTime.d.ts +35 -0
- package/dist/clean/primitive/operations/date/dateGreaterThan.d.ts +24 -0
- package/dist/clean/primitive/operations/date/dateLessThan.d.ts +24 -0
- package/dist/clean/primitive/operations/date/dateMax.cjs +3 -0
- package/dist/clean/primitive/operations/date/dateMax.d.ts +36 -0
- package/dist/clean/primitive/operations/date/dateMax.mjs +3 -0
- package/dist/clean/primitive/operations/date/dateMin.cjs +3 -0
- package/dist/clean/primitive/operations/date/dateMin.d.ts +36 -0
- package/dist/clean/primitive/operations/date/dateMin.mjs +3 -0
- package/dist/clean/primitive/operations/date/dateSubtractTime.d.ts +35 -0
- package/dist/clean/primitive/operations/equal.d.ts +34 -0
- package/dist/clean/primitive/operations/number/add.d.ts +34 -0
- package/dist/clean/primitive/operations/number/divide.d.ts +34 -0
- package/dist/clean/primitive/operations/number/greaterThan.d.ts +25 -0
- package/dist/clean/primitive/operations/number/lessThan.d.ts +25 -0
- package/dist/clean/primitive/operations/number/max.cjs +3 -0
- package/dist/clean/primitive/operations/number/max.d.ts +33 -0
- package/dist/clean/primitive/operations/number/max.mjs +3 -0
- package/dist/clean/primitive/operations/number/min.cjs +3 -0
- package/dist/clean/primitive/operations/number/min.d.ts +33 -0
- package/dist/clean/primitive/operations/number/min.mjs +3 -0
- package/dist/clean/primitive/operations/number/multiply.d.ts +34 -0
- package/dist/clean/primitive/operations/number/subtract.d.ts +34 -0
- package/dist/clean/primitive/operations/sort.d.ts +38 -0
- package/dist/clean/primitive/operations/string/concat.d.ts +35 -0
- package/dist/clean/primitive/operations/string/length.cjs +3 -0
- package/dist/clean/primitive/operations/string/length.d.ts +27 -0
- package/dist/clean/primitive/operations/string/length.mjs +3 -0
- package/dist/clean/primitive/operations/string/lengthEqual.d.ts +25 -0
- package/dist/clean/primitive/operations/string/lengthGreaterThan.d.ts +25 -0
- package/dist/clean/primitive/operations/string/lengthLessThan.d.ts +25 -0
- package/dist/clean/primitive/operations/time/timeGreaterThan.d.ts +24 -0
- package/dist/clean/primitive/operations/time/timeLessThan.d.ts +24 -0
- package/dist/clean/primitive/operations/time/timeMax.cjs +3 -0
- package/dist/clean/primitive/operations/time/timeMax.d.ts +36 -0
- package/dist/clean/primitive/operations/time/timeMax.mjs +3 -0
- package/dist/clean/primitive/operations/time/timeMin.cjs +3 -0
- package/dist/clean/primitive/operations/time/timeMin.d.ts +36 -0
- package/dist/clean/primitive/operations/time/timeMin.mjs +3 -0
- package/dist/clean/repository.cjs +3 -0
- package/dist/clean/repository.d.ts +87 -0
- package/dist/clean/repository.mjs +3 -0
- package/dist/clean/useCase.cjs +6 -0
- package/dist/clean/useCase.d.ts +140 -0
- package/dist/clean/useCase.mjs +6 -0
- package/dist/common/addWrappedProperties.cjs +3 -0
- package/dist/common/addWrappedProperties.d.ts +12 -0
- package/dist/common/addWrappedProperties.mjs +3 -0
- package/dist/common/and.d.ts +53 -0
- package/dist/common/asyncInnerPipe.d.ts +49 -0
- package/dist/common/asyncLoop.cjs +3 -0
- package/dist/common/asyncLoop.d.ts +29 -0
- package/dist/common/asyncLoop.mjs +3 -0
- package/dist/common/asyncPipe.cjs +3 -0
- package/dist/common/asyncPipe.d.ts +35 -0
- package/dist/common/asyncPipe.mjs +3 -0
- package/dist/common/asyncRetry.cjs +6 -0
- package/dist/common/asyncRetry.d.ts +64 -0
- package/dist/common/asyncRetry.mjs +6 -0
- package/dist/common/builder.cjs +3 -0
- package/dist/common/builder.d.ts +88 -0
- package/dist/common/builder.mjs +3 -0
- package/dist/common/clone.cjs +3 -0
- package/dist/common/clone.d.ts +12 -0
- package/dist/common/clone.mjs +3 -0
- package/dist/common/enum.cjs +3 -0
- package/dist/common/enum.d.ts +34 -0
- package/dist/common/enum.mjs +3 -0
- package/dist/common/equal.d.ts +38 -0
- package/dist/common/escapeRegExp.cjs +3 -0
- package/dist/common/escapeRegExp.d.ts +20 -0
- package/dist/common/escapeRegExp.mjs +3 -0
- package/dist/common/externalPromise.cjs +3 -0
- package/dist/common/externalPromise.d.ts +20 -0
- package/dist/common/externalPromise.mjs +3 -0
- package/dist/common/falsy.cjs +3 -0
- package/dist/common/falsy.d.ts +27 -0
- package/dist/common/falsy.mjs +3 -0
- package/dist/common/forward.cjs +3 -0
- package/dist/common/forward.d.ts +23 -0
- package/dist/common/forward.mjs +3 -0
- package/dist/common/forwardLog.cjs +3 -0
- package/dist/common/forwardLog.d.ts +28 -0
- package/dist/common/forwardLog.mjs +3 -0
- package/dist/common/globalStore.cjs +3 -0
- package/dist/common/globalStore.d.ts +12 -0
- package/dist/common/globalStore.mjs +3 -0
- package/dist/common/hasKinds.d.ts +39 -0
- package/dist/common/hasSomeKinds.d.ts +39 -0
- package/dist/common/index.d.ts +27 -0
- package/dist/common/innerPipe.d.ts +35 -0
- package/dist/common/instanceOf.d.ts +33 -0
- package/dist/common/isType.d.ts +35 -0
- package/dist/common/justReturn.d.ts +43 -0
- package/dist/common/kind.cjs +6 -0
- package/dist/common/kind.d.ts +94 -0
- package/dist/common/kind.mjs +6 -0
- package/dist/common/loop.cjs +3 -0
- package/dist/common/loop.d.ts +26 -0
- package/dist/common/loop.mjs +3 -0
- package/dist/common/memo.cjs +3 -0
- package/dist/common/memo.d.ts +25 -0
- package/dist/common/memo.mjs +3 -0
- package/dist/common/or.d.ts +41 -0
- package/dist/common/override.cjs +3 -0
- package/dist/common/override.d.ts +45 -0
- package/dist/common/override.mjs +3 -0
- package/dist/common/pipe.d.ts +29 -0
- package/dist/common/promiseObject.cjs +3 -0
- package/dist/common/promiseObject.d.ts +26 -0
- package/dist/common/promiseObject.mjs +3 -0
- package/dist/common/simpleClone.cjs +3 -0
- package/dist/common/simpleClone.d.ts +23 -0
- package/dist/common/simpleClone.mjs +3 -0
- package/dist/common/sleep.cjs +3 -0
- package/dist/common/sleep.d.ts +21 -0
- package/dist/common/sleep.mjs +3 -0
- package/dist/common/stringToBytes.cjs +3 -0
- package/dist/common/stringToBytes.d.ts +17 -0
- package/dist/common/stringToBytes.mjs +3 -0
- package/dist/common/stringToMillisecond.cjs +3 -0
- package/dist/common/stringToMillisecond.d.ts +17 -0
- package/dist/common/stringToMillisecond.mjs +3 -0
- package/dist/common/toJSON.cjs +3 -0
- package/dist/common/toJSON.d.ts +35 -0
- package/dist/common/toJSON.mjs +3 -0
- package/dist/common/toString.cjs +3 -0
- package/dist/common/toString.d.ts +18 -0
- package/dist/common/toString.mjs +3 -0
- package/dist/common/toTransform.cjs +3 -0
- package/dist/common/toTransform.d.ts +41 -0
- package/dist/common/toTransform.mjs +3 -0
- package/dist/common/toWrappedValue.cjs +3 -0
- package/dist/common/toWrappedValue.d.ts +22 -0
- package/dist/common/toWrappedValue.mjs +3 -0
- package/dist/common/truthy.cjs +3 -0
- package/dist/common/truthy.d.ts +27 -0
- package/dist/common/truthy.mjs +3 -0
- package/dist/common/unwrap.d.ts +22 -0
- package/dist/common/when.d.ts +40 -0
- package/dist/common/whenElse.d.ts +42 -0
- package/dist/common/whenNot.d.ts +40 -0
- package/dist/common/wrapValue.cjs +9 -0
- package/dist/common/wrapValue.d.ts +55 -0
- package/dist/common/wrapValue.mjs +9 -0
- package/dist/dataParser/base.d.ts +104 -0
- package/dist/dataParser/baseExtended.d.ts +333 -0
- package/dist/dataParser/extended/array.cjs +3 -0
- package/dist/dataParser/extended/array.d.ts +84 -0
- package/dist/dataParser/extended/array.mjs +3 -0
- package/dist/dataParser/extended/bigint.cjs +3 -0
- package/dist/dataParser/extended/bigint.d.ts +84 -0
- package/dist/dataParser/extended/bigint.mjs +3 -0
- package/dist/dataParser/extended/boolean.cjs +3 -0
- package/dist/dataParser/extended/boolean.d.ts +28 -0
- package/dist/dataParser/extended/boolean.mjs +3 -0
- package/dist/dataParser/extended/date.cjs +3 -0
- package/dist/dataParser/extended/date.d.ts +28 -0
- package/dist/dataParser/extended/date.mjs +3 -0
- package/dist/dataParser/extended/empty.cjs +3 -0
- package/dist/dataParser/extended/empty.d.ts +27 -0
- package/dist/dataParser/extended/empty.mjs +3 -0
- package/dist/dataParser/extended/lazy.cjs +3 -0
- package/dist/dataParser/extended/lazy.d.ts +38 -0
- package/dist/dataParser/extended/lazy.mjs +3 -0
- package/dist/dataParser/extended/literal.cjs +3 -0
- package/dist/dataParser/extended/literal.d.ts +28 -0
- package/dist/dataParser/extended/literal.mjs +3 -0
- package/dist/dataParser/extended/nil.cjs +3 -0
- package/dist/dataParser/extended/nil.d.ts +28 -0
- package/dist/dataParser/extended/nil.mjs +3 -0
- package/dist/dataParser/extended/nullable.cjs +3 -0
- package/dist/dataParser/extended/nullable.d.ts +28 -0
- package/dist/dataParser/extended/nullable.mjs +3 -0
- package/dist/dataParser/extended/number.cjs +6 -0
- package/dist/dataParser/extended/number.d.ts +143 -0
- package/dist/dataParser/extended/number.mjs +6 -0
- package/dist/dataParser/extended/object.cjs +3 -0
- package/dist/dataParser/extended/object.d.ts +243 -0
- package/dist/dataParser/extended/object.mjs +3 -0
- package/dist/dataParser/extended/optional.cjs +3 -0
- package/dist/dataParser/extended/optional.d.ts +28 -0
- package/dist/dataParser/extended/optional.mjs +3 -0
- package/dist/dataParser/extended/pipe.cjs +3 -0
- package/dist/dataParser/extended/pipe.d.ts +28 -0
- package/dist/dataParser/extended/pipe.mjs +3 -0
- package/dist/dataParser/extended/record.cjs +3 -0
- package/dist/dataParser/extended/record.d.ts +38 -0
- package/dist/dataParser/extended/record.mjs +3 -0
- package/dist/dataParser/extended/recover.cjs +3 -0
- package/dist/dataParser/extended/recover.d.ts +27 -0
- package/dist/dataParser/extended/recover.mjs +3 -0
- package/dist/dataParser/extended/string.cjs +9 -0
- package/dist/dataParser/extended/string.d.ts +162 -0
- package/dist/dataParser/extended/string.mjs +9 -0
- package/dist/dataParser/extended/templateLiteral.cjs +3 -0
- package/dist/dataParser/extended/templateLiteral.d.ts +28 -0
- package/dist/dataParser/extended/templateLiteral.mjs +3 -0
- package/dist/dataParser/extended/time.cjs +3 -0
- package/dist/dataParser/extended/time.d.ts +84 -0
- package/dist/dataParser/extended/time.mjs +3 -0
- package/dist/dataParser/extended/transform.cjs +3 -0
- package/dist/dataParser/extended/transform.d.ts +28 -0
- package/dist/dataParser/extended/transform.mjs +3 -0
- package/dist/dataParser/extended/tuple.cjs +3 -0
- package/dist/dataParser/extended/tuple.d.ts +28 -0
- package/dist/dataParser/extended/tuple.mjs +3 -0
- package/dist/dataParser/extended/union.cjs +3 -0
- package/dist/dataParser/extended/union.d.ts +28 -0
- package/dist/dataParser/extended/union.mjs +3 -0
- package/dist/dataParser/extended/unknown.cjs +3 -0
- package/dist/dataParser/extended/unknown.d.ts +26 -0
- package/dist/dataParser/extended/unknown.mjs +3 -0
- package/dist/dataParser/parsers/array/index.cjs +3 -0
- package/dist/dataParser/parsers/array/index.d.ts +30 -0
- package/dist/dataParser/parsers/array/index.mjs +3 -0
- package/dist/dataParser/parsers/bigint/index.cjs +3 -0
- package/dist/dataParser/parsers/bigint/index.d.ts +30 -0
- package/dist/dataParser/parsers/bigint/index.mjs +3 -0
- package/dist/dataParser/parsers/boolean.cjs +3 -0
- package/dist/dataParser/parsers/boolean.d.ts +30 -0
- package/dist/dataParser/parsers/boolean.mjs +3 -0
- package/dist/dataParser/parsers/date.cjs +3 -0
- package/dist/dataParser/parsers/date.d.ts +30 -0
- package/dist/dataParser/parsers/date.mjs +3 -0
- package/dist/dataParser/parsers/empty.cjs +3 -0
- package/dist/dataParser/parsers/empty.d.ts +29 -0
- package/dist/dataParser/parsers/empty.mjs +3 -0
- package/dist/dataParser/parsers/lazy.cjs +3 -0
- package/dist/dataParser/parsers/lazy.d.ts +39 -0
- package/dist/dataParser/parsers/lazy.mjs +3 -0
- package/dist/dataParser/parsers/literal.cjs +3 -0
- package/dist/dataParser/parsers/literal.d.ts +29 -0
- package/dist/dataParser/parsers/literal.mjs +3 -0
- package/dist/dataParser/parsers/nil.cjs +3 -0
- package/dist/dataParser/parsers/nil.d.ts +30 -0
- package/dist/dataParser/parsers/nil.mjs +3 -0
- package/dist/dataParser/parsers/nullable.cjs +3 -0
- package/dist/dataParser/parsers/nullable.d.ts +30 -0
- package/dist/dataParser/parsers/nullable.mjs +3 -0
- package/dist/dataParser/parsers/number/index.cjs +3 -0
- package/dist/dataParser/parsers/number/index.d.ts +30 -0
- package/dist/dataParser/parsers/number/index.mjs +3 -0
- package/dist/dataParser/parsers/object/extends.cjs +3 -0
- package/dist/dataParser/parsers/object/extends.d.ts +50 -0
- package/dist/dataParser/parsers/object/extends.mjs +3 -0
- package/dist/dataParser/parsers/object/index.cjs +3 -0
- package/dist/dataParser/parsers/object/index.d.ts +39 -0
- package/dist/dataParser/parsers/object/index.mjs +3 -0
- package/dist/dataParser/parsers/object/omit.cjs +3 -0
- package/dist/dataParser/parsers/object/omit.d.ts +38 -0
- package/dist/dataParser/parsers/object/omit.mjs +3 -0
- package/dist/dataParser/parsers/object/partial.cjs +3 -0
- package/dist/dataParser/parsers/object/partial.d.ts +28 -0
- package/dist/dataParser/parsers/object/partial.mjs +3 -0
- package/dist/dataParser/parsers/object/pick.cjs +3 -0
- package/dist/dataParser/parsers/object/pick.d.ts +35 -0
- package/dist/dataParser/parsers/object/pick.mjs +3 -0
- package/dist/dataParser/parsers/object/required.cjs +3 -0
- package/dist/dataParser/parsers/object/required.d.ts +37 -0
- package/dist/dataParser/parsers/object/required.mjs +3 -0
- package/dist/dataParser/parsers/optional.cjs +3 -0
- package/dist/dataParser/parsers/optional.d.ts +30 -0
- package/dist/dataParser/parsers/optional.mjs +3 -0
- package/dist/dataParser/parsers/pipe.cjs +3 -0
- package/dist/dataParser/parsers/pipe.d.ts +31 -0
- package/dist/dataParser/parsers/pipe.mjs +3 -0
- package/dist/dataParser/parsers/record/index.cjs +3 -0
- package/dist/dataParser/parsers/record/index.d.ts +37 -0
- package/dist/dataParser/parsers/record/index.mjs +3 -0
- package/dist/dataParser/parsers/recover.cjs +3 -0
- package/dist/dataParser/parsers/recover.d.ts +30 -0
- package/dist/dataParser/parsers/recover.mjs +3 -0
- package/dist/dataParser/parsers/string/index.cjs +3 -0
- package/dist/dataParser/parsers/string/index.d.ts +30 -0
- package/dist/dataParser/parsers/string/index.mjs +3 -0
- package/dist/dataParser/parsers/templateLiteral/index.cjs +3 -0
- package/dist/dataParser/parsers/templateLiteral/index.d.ts +30 -0
- package/dist/dataParser/parsers/templateLiteral/index.mjs +3 -0
- package/dist/dataParser/parsers/time/index.cjs +3 -0
- package/dist/dataParser/parsers/time/index.d.ts +30 -0
- package/dist/dataParser/parsers/time/index.mjs +3 -0
- package/dist/dataParser/parsers/transform.cjs +3 -0
- package/dist/dataParser/parsers/transform.d.ts +29 -0
- package/dist/dataParser/parsers/transform.mjs +3 -0
- package/dist/dataParser/parsers/tuple.cjs +3 -0
- package/dist/dataParser/parsers/tuple.d.ts +26 -0
- package/dist/dataParser/parsers/tuple.mjs +3 -0
- package/dist/dataParser/parsers/union.cjs +3 -0
- package/dist/dataParser/parsers/union.d.ts +31 -0
- package/dist/dataParser/parsers/union.mjs +3 -0
- package/dist/dataParser/parsers/unknown.cjs +3 -0
- package/dist/dataParser/parsers/unknown.d.ts +30 -0
- package/dist/dataParser/parsers/unknown.mjs +3 -0
- package/dist/date/applyTimezone.d.ts +29 -0
- package/dist/date/closestTo.d.ts +35 -0
- package/dist/date/create.d.ts +52 -0
- package/dist/date/createOrThrow.d.ts +35 -0
- package/dist/date/createTheDate.cjs +3 -0
- package/dist/date/createTheDate.d.ts +26 -0
- package/dist/date/createTheDate.mjs +3 -0
- package/dist/date/createTheTime.cjs +3 -0
- package/dist/date/createTheTime.d.ts +23 -0
- package/dist/date/createTheTime.mjs +3 -0
- package/dist/date/createTime.d.ts +37 -0
- package/dist/date/createTimeOrThrow.cjs +3 -0
- package/dist/date/createTimeOrThrow.d.ts +35 -0
- package/dist/date/createTimeOrThrow.mjs +3 -0
- package/dist/date/each.cjs +3 -0
- package/dist/date/each.d.ts +32 -0
- package/dist/date/each.mjs +3 -0
- package/dist/date/format.cjs +2 -1
- package/dist/date/format.d.ts +29 -0
- package/dist/date/format.mjs +2 -1
- package/dist/date/formatTime.cjs +38 -0
- package/dist/date/formatTime.d.ts +35 -0
- package/dist/date/formatTime.mjs +36 -0
- package/dist/date/getTimezoneOffset.d.ts +29 -0
- package/dist/date/getters/getDayOfMonth.cjs +3 -0
- package/dist/date/getters/getDayOfMonth.d.ts +29 -0
- package/dist/date/getters/getDayOfMonth.mjs +3 -0
- package/dist/date/getters/getDayOfWeek.cjs +3 -0
- package/dist/date/getters/getDayOfWeek.d.ts +29 -0
- package/dist/date/getters/getDayOfWeek.mjs +3 -0
- package/dist/date/getters/getDayOfYear.cjs +3 -0
- package/dist/date/getters/getDayOfYear.d.ts +26 -0
- package/dist/date/getters/getDayOfYear.mjs +3 -0
- package/dist/date/getters/getFirstDayOfMonth.cjs +3 -0
- package/dist/date/getters/getFirstDayOfMonth.d.ts +24 -0
- package/dist/date/getters/getFirstDayOfMonth.mjs +3 -0
- package/dist/date/getters/getFirstDayOfWeek.cjs +3 -0
- package/dist/date/getters/getFirstDayOfWeek.d.ts +24 -0
- package/dist/date/getters/getFirstDayOfWeek.mjs +3 -0
- package/dist/date/getters/getHour.cjs +3 -0
- package/dist/date/getters/getHour.d.ts +29 -0
- package/dist/date/getters/getHour.mjs +3 -0
- package/dist/date/getters/getLastDayOfMonth.cjs +3 -0
- package/dist/date/getters/getLastDayOfMonth.d.ts +24 -0
- package/dist/date/getters/getLastDayOfMonth.mjs +3 -0
- package/dist/date/getters/getLastDayOfWeek.cjs +3 -0
- package/dist/date/getters/getLastDayOfWeek.d.ts +24 -0
- package/dist/date/getters/getLastDayOfWeek.mjs +3 -0
- package/dist/date/getters/getMilliseconds.cjs +3 -0
- package/dist/date/getters/getMilliseconds.d.ts +29 -0
- package/dist/date/getters/getMilliseconds.mjs +3 -0
- package/dist/date/getters/getMinute.cjs +3 -0
- package/dist/date/getters/getMinute.d.ts +29 -0
- package/dist/date/getters/getMinute.mjs +3 -0
- package/dist/date/getters/getMonth.cjs +3 -0
- package/dist/date/getters/getMonth.d.ts +29 -0
- package/dist/date/getters/getMonth.mjs +3 -0
- package/dist/date/getters/getSecond.cjs +3 -0
- package/dist/date/getters/getSecond.d.ts +29 -0
- package/dist/date/getters/getSecond.mjs +3 -0
- package/dist/date/getters/getWeekOfYear.cjs +3 -0
- package/dist/date/getters/getWeekOfYear.d.ts +26 -0
- package/dist/date/getters/getWeekOfYear.mjs +3 -0
- package/dist/date/getters/getYear.cjs +3 -0
- package/dist/date/getters/getYear.d.ts +29 -0
- package/dist/date/getters/getYear.mjs +3 -0
- package/dist/date/index.cjs +7 -1
- package/dist/date/index.d.ts +34 -0
- package/dist/date/index.mjs +6 -0
- package/dist/date/is.cjs +3 -0
- package/dist/date/is.d.ts +30 -0
- package/dist/date/is.mjs +3 -0
- package/dist/date/isSafeTimeValue.cjs +3 -0
- package/dist/date/isSafeTimeValue.d.ts +26 -0
- package/dist/date/isSafeTimeValue.mjs +3 -0
- package/dist/date/isSafeTimestamp.cjs +3 -0
- package/dist/date/isSafeTimestamp.d.ts +31 -0
- package/dist/date/isSafeTimestamp.mjs +3 -0
- package/dist/date/isTime.cjs +3 -0
- package/dist/date/isTime.d.ts +29 -0
- package/dist/date/isTime.mjs +3 -0
- package/dist/date/makeSafeTimeValue.cjs +3 -0
- package/dist/date/makeSafeTimeValue.d.ts +26 -0
- package/dist/date/makeSafeTimeValue.mjs +3 -0
- package/dist/date/makeSafeTimestamp.cjs +3 -0
- package/dist/date/makeSafeTimestamp.d.ts +26 -0
- package/dist/date/makeSafeTimestamp.mjs +3 -0
- package/dist/date/max.cjs +3 -0
- package/dist/date/max.d.ts +24 -0
- package/dist/date/max.mjs +3 -0
- package/dist/date/maxTime.cjs +3 -0
- package/dist/date/maxTime.d.ts +33 -0
- package/dist/date/maxTime.mjs +3 -0
- package/dist/date/min.cjs +3 -0
- package/dist/date/min.d.ts +24 -0
- package/dist/date/min.mjs +3 -0
- package/dist/date/minTime.cjs +3 -0
- package/dist/date/minTime.d.ts +33 -0
- package/dist/date/minTime.mjs +3 -0
- package/dist/date/now.cjs +3 -0
- package/dist/date/now.d.ts +18 -0
- package/dist/date/now.mjs +3 -0
- package/dist/date/operators/addDays.d.ts +26 -0
- package/dist/date/operators/addHours.d.ts +26 -0
- package/dist/date/operators/addMilliseconds.d.ts +26 -0
- package/dist/date/operators/addMinutes.d.ts +26 -0
- package/dist/date/operators/addMonths.d.ts +30 -0
- package/dist/date/operators/addSeconds.d.ts +26 -0
- package/dist/date/operators/addTime.d.ts +31 -0
- package/dist/date/operators/addWeeks.d.ts +26 -0
- package/dist/date/operators/addYears.d.ts +30 -0
- package/dist/date/operators/between.d.ts +32 -0
- package/dist/date/operators/betweenThan.d.ts +32 -0
- package/dist/date/operators/betweenThanTime.d.ts +36 -0
- package/dist/date/operators/betweenTime.d.ts +36 -0
- package/dist/date/operators/greater.d.ts +28 -0
- package/dist/date/operators/greaterThan.d.ts +28 -0
- package/dist/date/operators/greaterThanTime.d.ts +35 -0
- package/dist/date/operators/greaterTime.d.ts +35 -0
- package/dist/date/operators/less.d.ts +28 -0
- package/dist/date/operators/lessThan.d.ts +28 -0
- package/dist/date/operators/lessThanTime.d.ts +35 -0
- package/dist/date/operators/lessTime.d.ts +35 -0
- package/dist/date/operators/subtractDays.d.ts +26 -0
- package/dist/date/operators/subtractHours.d.ts +26 -0
- package/dist/date/operators/subtractMilliseconds.d.ts +26 -0
- package/dist/date/operators/subtractMinutes.d.ts +26 -0
- package/dist/date/operators/subtractMonths.d.ts +26 -0
- package/dist/date/operators/subtractSeconds.d.ts +26 -0
- package/dist/date/operators/subtractTime.d.ts +31 -0
- package/dist/date/operators/subtractWeeks.d.ts +26 -0
- package/dist/date/operators/subtractYears.d.ts +26 -0
- package/dist/date/round.cjs +3 -0
- package/dist/date/round.d.ts +35 -0
- package/dist/date/round.mjs +3 -0
- package/dist/date/sort.d.ts +29 -0
- package/dist/date/sortTimes.d.ts +36 -0
- package/dist/date/toISOString.cjs +3 -0
- package/dist/date/toISOString.d.ts +24 -0
- package/dist/date/toISOString.mjs +3 -0
- package/dist/date/toNative.cjs +3 -0
- package/dist/date/toNative.d.ts +24 -0
- package/dist/date/toNative.mjs +3 -0
- package/dist/date/toTimeValue.cjs +3 -0
- package/dist/date/toTimeValue.d.ts +24 -0
- package/dist/date/toTimeValue.mjs +3 -0
- package/dist/date/toTimestamp.cjs +3 -0
- package/dist/date/toTimestamp.d.ts +24 -0
- package/dist/date/toTimestamp.mjs +3 -0
- package/dist/date/today.cjs +3 -0
- package/dist/date/today.d.ts +18 -0
- package/dist/date/today.mjs +3 -0
- package/dist/date/tomorrow.cjs +3 -0
- package/dist/date/tomorrow.d.ts +18 -0
- package/dist/date/tomorrow.mjs +3 -0
- package/dist/date/types/isLeapYear.d.ts +8 -0
- package/dist/date/types/isSafeYear.d.ts +8 -0
- package/dist/date/types/theDate.d.ts +10 -0
- package/dist/date/types/theTime.d.ts +9 -0
- package/dist/date/yesterday.cjs +3 -0
- package/dist/date/yesterday.d.ts +18 -0
- package/dist/date/yesterday.mjs +3 -0
- package/dist/either/bool/create.d.ts +22 -0
- package/dist/either/bool/falsy.cjs +9 -0
- package/dist/either/bool/falsy.d.ts +69 -0
- package/dist/either/bool/falsy.mjs +9 -0
- package/dist/either/bool/truthy.cjs +9 -0
- package/dist/either/bool/truthy.d.ts +69 -0
- package/dist/either/bool/truthy.mjs +9 -0
- package/dist/either/future/create.cjs +3 -0
- package/dist/either/future/create.d.ts +23 -0
- package/dist/either/future/create.mjs +3 -0
- package/dist/either/future/error.cjs +3 -0
- package/dist/either/future/error.d.ts +18 -0
- package/dist/either/future/error.mjs +3 -0
- package/dist/either/future/success.cjs +3 -0
- package/dist/either/future/success.d.ts +18 -0
- package/dist/either/future/success.mjs +3 -0
- package/dist/either/hasInformation.d.ts +30 -0
- package/dist/either/index.cjs +3 -1
- package/dist/either/index.d.ts +24 -0
- package/dist/either/index.mjs +4 -0
- package/dist/either/left/create.cjs +3 -0
- package/dist/either/left/create.d.ts +29 -0
- package/dist/either/left/create.mjs +3 -0
- package/dist/either/left/error.cjs +3 -0
- package/dist/either/left/error.d.ts +28 -0
- package/dist/either/left/error.mjs +3 -0
- package/dist/either/left/fail.cjs +3 -0
- package/dist/either/left/fail.d.ts +29 -0
- package/dist/either/left/fail.mjs +3 -0
- package/dist/either/left/is.cjs +3 -0
- package/dist/either/left/is.d.ts +22 -0
- package/dist/either/left/is.mjs +3 -0
- package/dist/either/left/when.d.ts +26 -0
- package/dist/either/nullable/create.d.ts +18 -0
- package/dist/either/nullable/empty.cjs +9 -0
- package/dist/either/nullable/empty.d.ts +59 -0
- package/dist/either/nullable/empty.mjs +9 -0
- package/dist/either/nullable/filled.cjs +9 -0
- package/dist/either/nullable/filled.d.ts +61 -0
- package/dist/either/nullable/filled.mjs +9 -0
- package/dist/either/nullish/create.d.ts +20 -0
- package/dist/either/nullish/empty.cjs +9 -0
- package/dist/either/nullish/empty.d.ts +61 -0
- package/dist/either/nullish/empty.mjs +9 -0
- package/dist/either/nullish/filled.cjs +9 -0
- package/dist/either/nullish/filled.d.ts +61 -0
- package/dist/either/nullish/filled.mjs +9 -0
- package/dist/either/optional/create.d.ts +18 -0
- package/dist/either/optional/empty.cjs +9 -0
- package/dist/either/optional/empty.d.ts +59 -0
- package/dist/either/optional/empty.mjs +9 -0
- package/dist/either/optional/filled.cjs +9 -0
- package/dist/either/optional/filled.d.ts +61 -0
- package/dist/either/optional/filled.mjs +9 -0
- package/dist/either/right/asyncGroup.cjs +3 -0
- package/dist/either/right/asyncGroup.d.ts +29 -0
- package/dist/either/right/asyncGroup.mjs +3 -0
- package/dist/either/right/asyncPipe.d.ts +37 -0
- package/dist/either/right/create.cjs +3 -0
- package/dist/either/right/create.d.ts +36 -0
- package/dist/either/right/create.mjs +3 -0
- package/dist/either/right/group.cjs +3 -0
- package/dist/either/right/group.d.ts +26 -0
- package/dist/either/right/group.mjs +3 -0
- package/dist/either/right/is.cjs +3 -0
- package/dist/either/right/is.d.ts +22 -0
- package/dist/either/right/is.mjs +3 -0
- package/dist/either/right/ok.cjs +3 -0
- package/dist/either/right/ok.d.ts +25 -0
- package/dist/either/right/ok.mjs +3 -0
- package/dist/either/right/pipe.d.ts +33 -0
- package/dist/either/right/success.cjs +3 -0
- package/dist/either/right/success.d.ts +28 -0
- package/dist/either/right/success.mjs +3 -0
- package/dist/either/right/when.d.ts +26 -0
- package/dist/either/safeCallback.cjs +3 -0
- package/dist/either/safeCallback.d.ts +26 -0
- package/dist/either/safeCallback.mjs +3 -0
- package/dist/either/whenHasInformation.d.ts +36 -0
- package/dist/generator/asyncChunk.d.ts +34 -0
- package/dist/generator/asyncFilter.d.ts +50 -0
- package/dist/generator/asyncLoop.cjs +3 -0
- package/dist/generator/asyncLoop.d.ts +43 -0
- package/dist/generator/asyncLoop.mjs +3 -0
- package/dist/generator/asyncMap.d.ts +38 -0
- package/dist/generator/asyncReduce.d.ts +34 -0
- package/dist/generator/chunk.d.ts +27 -0
- package/dist/generator/execute.d.ts +33 -0
- package/dist/generator/filter.d.ts +40 -0
- package/dist/generator/index.cjs +3 -1
- package/dist/generator/index.d.ts +26 -0
- package/dist/generator/index.mjs +4 -0
- package/dist/generator/loop.cjs +3 -0
- package/dist/generator/loop.d.ts +35 -0
- package/dist/generator/loop.mjs +3 -0
- package/dist/generator/map.d.ts +35 -0
- package/dist/generator/reduce.cjs +3 -0
- package/dist/generator/reduce.d.ts +60 -0
- package/dist/generator/reduce.mjs +3 -0
- package/dist/metadata.json +9 -0
- package/dist/number/abs.cjs +3 -0
- package/dist/number/abs.d.ts +27 -0
- package/dist/number/abs.mjs +3 -0
- package/dist/number/acos.cjs +3 -0
- package/dist/number/acos.d.ts +27 -0
- package/dist/number/acos.mjs +3 -0
- package/dist/number/add.d.ts +24 -0
- package/dist/number/asin.cjs +3 -0
- package/dist/number/asin.d.ts +27 -0
- package/dist/number/asin.mjs +3 -0
- package/dist/number/atan.cjs +3 -0
- package/dist/number/atan.d.ts +27 -0
- package/dist/number/atan.mjs +3 -0
- package/dist/number/atan2.d.ts +3 -0
- package/dist/number/between.d.ts +33 -0
- package/dist/number/betweenThan.d.ts +33 -0
- package/dist/number/ceil.cjs +3 -0
- package/dist/number/ceil.d.ts +27 -0
- package/dist/number/ceil.mjs +3 -0
- package/dist/number/clamp.d.ts +32 -0
- package/dist/number/cos.cjs +3 -0
- package/dist/number/cos.d.ts +27 -0
- package/dist/number/cos.mjs +3 -0
- package/dist/number/divide.d.ts +30 -0
- package/dist/number/floor.cjs +3 -0
- package/dist/number/floor.d.ts +27 -0
- package/dist/number/floor.mjs +3 -0
- package/dist/number/greater.d.ts +30 -0
- package/dist/number/greaterThan.d.ts +30 -0
- package/dist/number/index.cjs +3 -1
- package/dist/number/index.d.ts +25 -0
- package/dist/number/index.mjs +4 -0
- package/dist/number/less.d.ts +30 -0
- package/dist/number/lessThan.d.ts +30 -0
- package/dist/number/max.cjs +3 -0
- package/dist/number/max.d.ts +26 -0
- package/dist/number/max.mjs +3 -0
- package/dist/number/min.cjs +3 -0
- package/dist/number/min.d.ts +26 -0
- package/dist/number/min.mjs +3 -0
- package/dist/number/modulo.d.ts +30 -0
- package/dist/number/multiply.d.ts +30 -0
- package/dist/number/negate.cjs +3 -0
- package/dist/number/negate.d.ts +25 -0
- package/dist/number/negate.mjs +3 -0
- package/dist/number/power.d.ts +30 -0
- package/dist/number/round.cjs +3 -0
- package/dist/number/round.d.ts +27 -0
- package/dist/number/round.mjs +3 -0
- package/dist/number/sin.cjs +3 -0
- package/dist/number/sin.d.ts +27 -0
- package/dist/number/sin.mjs +3 -0
- package/dist/number/sort.d.ts +32 -0
- package/dist/number/sqrt.cjs +3 -0
- package/dist/number/sqrt.d.ts +27 -0
- package/dist/number/sqrt.mjs +3 -0
- package/dist/number/subtract.d.ts +30 -0
- package/dist/number/tan.cjs +3 -0
- package/dist/number/tan.d.ts +27 -0
- package/dist/number/tan.mjs +3 -0
- package/dist/number/toFixed.d.ts +33 -0
- package/dist/number/trunc.cjs +3 -0
- package/dist/number/trunc.d.ts +27 -0
- package/dist/number/trunc.mjs +3 -0
- package/dist/object/assign.d.ts +40 -0
- package/dist/object/deepDiscriminate.d.ts +54 -0
- package/dist/object/discriminate.d.ts +53 -0
- package/dist/object/entries.cjs +3 -0
- package/dist/object/entries.d.ts +31 -0
- package/dist/object/entries.mjs +3 -0
- package/dist/object/entry.cjs +3 -0
- package/dist/object/entry.d.ts +29 -0
- package/dist/object/entry.mjs +3 -0
- package/dist/object/fromEntries.cjs +3 -0
- package/dist/object/fromEntries.d.ts +39 -0
- package/dist/object/fromEntries.mjs +3 -0
- package/dist/object/getDeepProperty.d.ts +46 -0
- package/dist/object/getProperty.d.ts +39 -0
- package/dist/object/hasKeys.d.ts +48 -0
- package/dist/object/index.cjs +3 -1
- package/dist/object/index.d.ts +25 -0
- package/dist/object/index.mjs +4 -0
- package/dist/object/keys.cjs +3 -0
- package/dist/object/keys.d.ts +33 -0
- package/dist/object/keys.mjs +3 -0
- package/dist/object/omit.d.ts +46 -0
- package/dist/object/override.d.ts +49 -0
- package/dist/object/pick.d.ts +47 -0
- package/dist/object/to.d.ts +43 -0
- package/dist/object/transformProperties.d.ts +46 -0
- package/dist/object/transformProperty.d.ts +41 -0
- package/dist/object/values.cjs +3 -0
- package/dist/object/values.d.ts +33 -0
- package/dist/object/values.mjs +3 -0
- package/dist/pattern/exhaustive.cjs +3 -0
- package/dist/pattern/exhaustive.d.ts +51 -0
- package/dist/pattern/exhaustive.mjs +3 -0
- package/dist/pattern/index.cjs +3 -1
- package/dist/pattern/index.d.ts +24 -0
- package/dist/pattern/index.mjs +4 -0
- package/dist/pattern/isMatch.d.ts +36 -0
- package/dist/pattern/match/index.d.ts +58 -0
- package/dist/pattern/otherwise.d.ts +56 -0
- package/dist/pattern/union.cjs +3 -0
- package/dist/pattern/union.d.ts +37 -0
- package/dist/pattern/union.mjs +3 -0
- package/dist/pattern/when.d.ts +43 -0
- package/dist/string/at/default.d.ts +30 -0
- package/dist/string/capitalize.cjs +3 -0
- package/dist/string/capitalize.d.ts +27 -0
- package/dist/string/capitalize.mjs +3 -0
- package/dist/string/charAt.d.ts +29 -0
- package/dist/string/concat.d.ts +31 -0
- package/dist/string/endsWith.d.ts +41 -0
- package/dist/string/includes.d.ts +41 -0
- package/dist/string/index.cjs +3 -1
- package/dist/string/index.d.ts +27 -0
- package/dist/string/index.mjs +4 -0
- package/dist/string/indexOf.d.ts +30 -0
- package/dist/string/isIn.d.ts +45 -0
- package/dist/string/isKeyof.d.ts +45 -0
- package/dist/string/lastIndexOf.d.ts +30 -0
- package/dist/string/length.cjs +3 -0
- package/dist/string/length.d.ts +24 -0
- package/dist/string/length.mjs +3 -0
- package/dist/string/match.d.ts +29 -0
- package/dist/string/matchAll.d.ts +36 -0
- package/dist/string/normalize.d.ts +29 -0
- package/dist/string/padEnd.d.ts +29 -0
- package/dist/string/padStart.d.ts +29 -0
- package/dist/string/repeat.d.ts +29 -0
- package/dist/string/replace.d.ts +30 -0
- package/dist/string/replaceAll.d.ts +29 -0
- package/dist/string/search.d.ts +30 -0
- package/dist/string/slice.d.ts +29 -0
- package/dist/string/sort.d.ts +42 -0
- package/dist/string/sortCompare.d.ts +33 -0
- package/dist/string/split.d.ts +29 -0
- package/dist/string/startsWith.d.ts +41 -0
- package/dist/string/substring.d.ts +29 -0
- package/dist/string/test.d.ts +29 -0
- package/dist/string/toLowerCase.cjs +3 -0
- package/dist/string/toLowerCase.d.ts +27 -0
- package/dist/string/toLowerCase.mjs +3 -0
- package/dist/string/toUpperCase.cjs +3 -0
- package/dist/string/toUpperCase.d.ts +27 -0
- package/dist/string/toUpperCase.mjs +3 -0
- package/dist/string/trim/default.cjs +3 -0
- package/dist/string/trim/default.d.ts +27 -0
- package/dist/string/trim/default.mjs +3 -0
- package/dist/string/trim/end.cjs +3 -0
- package/dist/string/trim/end.d.ts +27 -0
- package/dist/string/trim/end.mjs +3 -0
- package/dist/string/trim/start.cjs +3 -0
- package/dist/string/trim/start.d.ts +27 -0
- package/dist/string/trim/start.mjs +3 -0
- package/dist/string/uncapitalize.cjs +3 -0
- package/dist/string/uncapitalize.d.ts +27 -0
- package/dist/string/uncapitalize.mjs +3 -0
- package/package.json +1 -1
package/dist/object/to.d.ts
CHANGED
|
@@ -5,6 +5,49 @@ type ShapeObject<GenericInput extends unknown = unknown> = {
|
|
|
5
5
|
type ComputesResult<GenericShapeObject extends ShapeObject<any>> = SimplifyTopLevel<{
|
|
6
6
|
[Prop in keyof GenericShapeObject]: (ReturnType<Adaptor<GenericShapeObject[Prop], AnyFunction>> | (undefined extends GenericShapeObject[Prop] ? undefined : never));
|
|
7
7
|
}>;
|
|
8
|
+
/**
|
|
9
|
+
* Builds an object from an input using a shape of functions.
|
|
10
|
+
*
|
|
11
|
+
* **Supported call styles:**
|
|
12
|
+
* - Classic: `to(input, shapeObject)` → returns a new object
|
|
13
|
+
* - Curried: `to(shapeObject)` → returns a function waiting for the input
|
|
14
|
+
*
|
|
15
|
+
* The input value is not mutated.
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* O.to(
|
|
19
|
+
* {
|
|
20
|
+
* name: "Ada",
|
|
21
|
+
* age: 36,
|
|
22
|
+
* },
|
|
23
|
+
* {
|
|
24
|
+
* label: (input) => `${input.name}:${input.age}`,
|
|
25
|
+
* },
|
|
26
|
+
* ); // { label: "Ada:36" }
|
|
27
|
+
*
|
|
28
|
+
* pipe(
|
|
29
|
+
* {
|
|
30
|
+
* name: "Ada",
|
|
31
|
+
* },
|
|
32
|
+
* O.to({
|
|
33
|
+
* upper: (input) => input.name.toUpperCase(),
|
|
34
|
+
* }),
|
|
35
|
+
* ); // { upper: "ADA" }
|
|
36
|
+
*
|
|
37
|
+
* O.to(
|
|
38
|
+
* "alpha",
|
|
39
|
+
* {
|
|
40
|
+
* len: (input) => input.length,
|
|
41
|
+
* },
|
|
42
|
+
* ); // { len: 5 }
|
|
43
|
+
*
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @see https://utils.duplojs.dev/en/v1/api/object/to
|
|
47
|
+
*
|
|
48
|
+
* @namespace O
|
|
49
|
+
*
|
|
50
|
+
*/
|
|
8
51
|
export declare function to<GenericInput extends unknown, GenericShapeObject extends ShapeObject<NoInfer<GenericInput>>>(shapeObject: ShapeObject<NoInfer<GenericInput>> & GenericShapeObject): (input: GenericInput) => ComputesResult<NoInfer<GenericShapeObject>>;
|
|
9
52
|
export declare function to<GenericInput extends unknown, GenericShapeObject extends ShapeObject<GenericInput>>(input: GenericInput, shapeObject: FixDeepFunctionInfer<ShapeObject<GenericInput>, GenericShapeObject>): ComputesResult<GenericShapeObject>;
|
|
10
53
|
export {};
|
|
@@ -5,6 +5,52 @@ type TransformObject<GenericObjectInput extends object = object> = {
|
|
|
5
5
|
type ComputesResult<GenericObjectInput extends object, GenericTransformObject extends TransformObject<GenericObjectInput>> = SimplifyTopLevel<Omit<GenericObjectInput, keyof GenericTransformObject> & {
|
|
6
6
|
[Prop in keyof GenericTransformObject]: (ReturnType<Adaptor<GenericTransformObject[Prop], AnyFunction>> | (undefined extends GenericTransformObject[Prop] ? GenericObjectInput[Adaptor<Prop, keyof GenericObjectInput>] : never));
|
|
7
7
|
}>;
|
|
8
|
+
/**
|
|
9
|
+
* Transforms multiple object properties.
|
|
10
|
+
*
|
|
11
|
+
* **Supported call styles:**
|
|
12
|
+
* - Classic: `transformProperties(obj, transformObject)` → returns a new object
|
|
13
|
+
* - Curried: `transformProperties(transformObject)` → returns a function waiting for the object
|
|
14
|
+
*
|
|
15
|
+
* The input object is not mutated.
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* O.transformProperties(
|
|
19
|
+
* {
|
|
20
|
+
* count: 2,
|
|
21
|
+
* label: "item",
|
|
22
|
+
* },
|
|
23
|
+
* {
|
|
24
|
+
* count: (value) => value + 1,
|
|
25
|
+
* label: (value) => value.toUpperCase(),
|
|
26
|
+
* },
|
|
27
|
+
* ); // { count: 3, label: "ITEM" }
|
|
28
|
+
*
|
|
29
|
+
* pipe(
|
|
30
|
+
* {
|
|
31
|
+
* name: "Ada",
|
|
32
|
+
* age: 36,
|
|
33
|
+
* },
|
|
34
|
+
* O.transformProperties({
|
|
35
|
+
* age: (value) => value + 1,
|
|
36
|
+
* }),
|
|
37
|
+
* ); // { name: "Ada", age: 37 }
|
|
38
|
+
*
|
|
39
|
+
* O.transformProperties(
|
|
40
|
+
* {
|
|
41
|
+
* active: true,
|
|
42
|
+
* },
|
|
43
|
+
* {},
|
|
44
|
+
* ); // { active: true }
|
|
45
|
+
*
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @see [`O.transformProperty`](https://utils.duplojs.dev/en/v1/api/object/transformProperty) For a single key
|
|
49
|
+
* @see https://utils.duplojs.dev/en/v1/api/object/transformProperties
|
|
50
|
+
*
|
|
51
|
+
* @namespace O
|
|
52
|
+
*
|
|
53
|
+
*/
|
|
8
54
|
export declare function transformProperties<GenericObjectInput extends object, GenericTransformObject extends TransformObject<NoInfer<GenericObjectInput>>>(transformObject: TransformObject<NoInfer<GenericObjectInput>> & GenericTransformObject): (obj: GenericObjectInput) => ComputesResult<NoInfer<GenericObjectInput>, NoInfer<GenericTransformObject>>;
|
|
9
55
|
export declare function transformProperties<GenericObjectInput extends object, GenericTransformObject extends TransformObject<GenericObjectInput>>(obj: GenericObjectInput, transformObject: FixDeepFunctionInfer<TransformObject<GenericObjectInput>, GenericTransformObject>): ComputesResult<GenericObjectInput, GenericTransformObject>;
|
|
10
56
|
export {};
|
|
@@ -1,4 +1,45 @@
|
|
|
1
1
|
import { type SimplifyTopLevel } from "../common";
|
|
2
|
+
/**
|
|
3
|
+
* Transforms a single object property.
|
|
4
|
+
*
|
|
5
|
+
* **Supported call styles:**
|
|
6
|
+
* - Classic: `transformProperty(obj, key, transform)` → returns a new object
|
|
7
|
+
* - Curried: `transformProperty(key, transform)` → returns a function waiting for the object
|
|
8
|
+
*
|
|
9
|
+
* The input object is not mutated.
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* O.transformProperty(
|
|
13
|
+
* {
|
|
14
|
+
* count: 2,
|
|
15
|
+
* },
|
|
16
|
+
* "count",
|
|
17
|
+
* (value) => value + 1,
|
|
18
|
+
* ); // { count: 3 }
|
|
19
|
+
*
|
|
20
|
+
* pipe(
|
|
21
|
+
* {
|
|
22
|
+
* name: "Ada",
|
|
23
|
+
* },
|
|
24
|
+
* O.transformProperty("name", (value) => value.toUpperCase()),
|
|
25
|
+
* ); // { name: "ADA" }
|
|
26
|
+
*
|
|
27
|
+
* O.transformProperty(
|
|
28
|
+
* {
|
|
29
|
+
* active: true,
|
|
30
|
+
* },
|
|
31
|
+
* "active",
|
|
32
|
+
* (value) => !value,
|
|
33
|
+
* ); // { active: false }
|
|
34
|
+
*
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @see [`O.transformProperties`](https://utils.duplojs.dev/en/v1/api/object/transformProperties) For multiple keys
|
|
38
|
+
* @see https://utils.duplojs.dev/en/v1/api/object/transformProperty
|
|
39
|
+
*
|
|
40
|
+
* @namespace O
|
|
41
|
+
*
|
|
42
|
+
*/
|
|
2
43
|
export declare function transformProperty<GenericObject extends object, GenericKey extends keyof GenericObject, GenericNewValue extends unknown>(key: GenericKey, transform: (value: GenericObject[GenericKey]) => GenericNewValue): (obj: GenericObject) => SimplifyTopLevel<{
|
|
3
44
|
[Prop in GenericKey]: GenericNewValue;
|
|
4
45
|
} & Omit<GenericObject, GenericKey>>;
|
package/dist/object/values.cjs
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
var wrapValue = require('../common/wrapValue.cjs');
|
|
4
4
|
var kind = require('../common/kind.cjs');
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* {@include object/values/index.md}
|
|
8
|
+
*/
|
|
6
9
|
function values(object) {
|
|
7
10
|
return Object.entries(object)
|
|
8
11
|
.filter(([key]) => !wrapValue.isRuntimeWrappedValueKey(key) && !kind.isRuntimeKind(key))
|
package/dist/object/values.d.ts
CHANGED
|
@@ -1,2 +1,35 @@
|
|
|
1
1
|
import { type AnyValue } from "../common/types/anyValue";
|
|
2
|
+
/**
|
|
3
|
+
* Returns object values.
|
|
4
|
+
*
|
|
5
|
+
* Signature: `values(object)` → returns values
|
|
6
|
+
*
|
|
7
|
+
* The input object is not mutated.
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* O.values(
|
|
11
|
+
* {
|
|
12
|
+
* name: "Ada",
|
|
13
|
+
* age: 36,
|
|
14
|
+
* },
|
|
15
|
+
* ); // ["Ada", 36]
|
|
16
|
+
*
|
|
17
|
+
* pipe(
|
|
18
|
+
* {
|
|
19
|
+
* name: "William",
|
|
20
|
+
* role: "client",
|
|
21
|
+
* },
|
|
22
|
+
* O.values,
|
|
23
|
+
* ); // ["William", "client"]
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @remarks
|
|
27
|
+
* - Filters runtime keys used by the library
|
|
28
|
+
* - Uses the same semantics as [`Object.values`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values)
|
|
29
|
+
*
|
|
30
|
+
* @see https://utils.duplojs.dev/en/v1/api/object/values
|
|
31
|
+
*
|
|
32
|
+
* @namespace O
|
|
33
|
+
*
|
|
34
|
+
*/
|
|
2
35
|
export declare function values<GenericValue extends AnyValue>(object: Record<string, GenericValue>): GenericValue[];
|
package/dist/object/values.mjs
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { isRuntimeWrappedValueKey } from '../common/wrapValue.mjs';
|
|
2
2
|
import { isRuntimeKind } from '../common/kind.mjs';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* {@include object/values/index.md}
|
|
6
|
+
*/
|
|
4
7
|
function values(object) {
|
|
5
8
|
return Object.entries(object)
|
|
6
9
|
.filter(([key]) => !isRuntimeWrappedValueKey(key) && !isRuntimeKind(key))
|
|
@@ -1,3 +1,54 @@
|
|
|
1
1
|
import { type Unwrap } from "../common";
|
|
2
2
|
import { type PatternResult } from "./result";
|
|
3
|
+
/**
|
|
4
|
+
* Unwraps a pattern result when all cases are handled.
|
|
5
|
+
*
|
|
6
|
+
* Signature: `exhaustive(result)` → returns the unwrapped value
|
|
7
|
+
*
|
|
8
|
+
* Use this to signal that all patterns have been handled.
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* const input = <{
|
|
12
|
+
* kind: "circle";
|
|
13
|
+
* radius: number;
|
|
14
|
+
* } | {
|
|
15
|
+
* kind: "square";
|
|
16
|
+
* size: number;
|
|
17
|
+
* }>{
|
|
18
|
+
* kind: "circle",
|
|
19
|
+
* radius: 2,
|
|
20
|
+
* };
|
|
21
|
+
*
|
|
22
|
+
* P.match(input)
|
|
23
|
+
* .with(
|
|
24
|
+
* { kind: "circle" },
|
|
25
|
+
* (shape) => shape.radius * 2,
|
|
26
|
+
* )
|
|
27
|
+
* .with(
|
|
28
|
+
* { kind: "square" },
|
|
29
|
+
* (shape) => shape.size * 2,
|
|
30
|
+
*
|
|
31
|
+
* )
|
|
32
|
+
* .exhaustive(); // 4
|
|
33
|
+
*
|
|
34
|
+
* pipe(
|
|
35
|
+
* input,
|
|
36
|
+
* P.match(
|
|
37
|
+
* { kind: "circle" },
|
|
38
|
+
* (shape) => shape.radius * 2,
|
|
39
|
+
* ),
|
|
40
|
+
* P.match(
|
|
41
|
+
* { kind: "square" },
|
|
42
|
+
* (shape) => shape.size * 2,
|
|
43
|
+
* ),
|
|
44
|
+
* P.exhaustive,
|
|
45
|
+
* ); // 4
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @see [`P.match`](https://utils.duplojs.dev/en/v1/api/pattern/match) For building match chains
|
|
49
|
+
* @see https://utils.duplojs.dev/en/v1/api/pattern/exhaustive
|
|
50
|
+
*
|
|
51
|
+
* @namespace P
|
|
52
|
+
*
|
|
53
|
+
*/
|
|
3
54
|
export declare function exhaustive<const GenericValue extends unknown, GenericResult extends PatternResult<GenericValue>>(result: GenericResult): Unwrap<GenericResult>;
|
package/dist/pattern/index.cjs
CHANGED
|
@@ -10,7 +10,9 @@ var when = require('./when.cjs');
|
|
|
10
10
|
var builder = require('./match/builder.cjs');
|
|
11
11
|
var pattern = require('./types/pattern.cjs');
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* {@include pattern/index.md}
|
|
15
|
+
*/
|
|
14
16
|
|
|
15
17
|
exports.isResult = result.isResult;
|
|
16
18
|
exports.result = result.result;
|
package/dist/pattern/index.d.ts
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pattern matching utilities for building typed match pipelines. Functions preserve
|
|
3
|
+
* inputs and return new values.
|
|
4
|
+
*
|
|
5
|
+
* **How to import:**
|
|
6
|
+
* - From the main entry (namespace style)
|
|
7
|
+
* - Via direct import for tree-shaking
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { DPattern, P } from "@duplojs/utils";
|
|
11
|
+
* import * as DPattern from "@duplojs/utils/pattern";
|
|
12
|
+
* import * as P from "@duplojs/utils/pattern";
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* What you will find in this namespace:
|
|
16
|
+
* - matching flow (`P.match`, `P.when`, `P.otherwise`, `P.exhaustive`)
|
|
17
|
+
* - predicates and patterns (`P.isMatch`, `P.union`)
|
|
18
|
+
*
|
|
19
|
+
* @see https://utils.duplojs.dev/en/v1/api/pattern
|
|
20
|
+
* @see https://utils.duplojs.dev/fr/v1/api/pattern
|
|
21
|
+
*
|
|
22
|
+
* @namespace P
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
1
25
|
export * from "./result";
|
|
2
26
|
export * from "./exhaustive";
|
|
3
27
|
export * from "./otherwise";
|
package/dist/pattern/index.mjs
CHANGED
|
@@ -7,3 +7,7 @@ export { union } from './union.mjs';
|
|
|
7
7
|
export { when } from './when.mjs';
|
|
8
8
|
export { InvalidExhaustivePatternError, matchBuilder } from './match/builder.mjs';
|
|
9
9
|
export { SymbolToolPatternFunctionLabel } from './types/pattern.mjs';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* {@include pattern/index.md}
|
|
13
|
+
*/
|
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
import { type ForcePredicate, type AnyValue, type FixDeepFunctionInfer } from "../common";
|
|
2
2
|
import { type Pattern, type PatternValue } from "./types/pattern";
|
|
3
3
|
import { type ComplexMatchedValue } from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* Checks whether a value matches a pattern.
|
|
6
|
+
*
|
|
7
|
+
* **Supported call styles:**
|
|
8
|
+
* - Classic: `isMatch(input, pattern)` → returns a boolean
|
|
9
|
+
* - Curried: `isMatch(pattern)` → returns a function waiting for the input
|
|
10
|
+
* - Classic predicate: `isMatch(input, pattern)` → narrows the input type
|
|
11
|
+
* - Curried predicate: `isMatch(pattern)` → narrows the input type
|
|
12
|
+
*
|
|
13
|
+
* The input is not mutated.
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* const input = <{
|
|
17
|
+
* kind: "text";
|
|
18
|
+
* content: string;
|
|
19
|
+
* } | {
|
|
20
|
+
* kind: "image";
|
|
21
|
+
* url: string;
|
|
22
|
+
* }>{
|
|
23
|
+
* kind: "text",
|
|
24
|
+
* content: "hello",
|
|
25
|
+
* };
|
|
26
|
+
*
|
|
27
|
+
* if (P.isMatch(input, { kind: "text" })) {
|
|
28
|
+
* // { kind: "text", content: "hello" }
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* - Predicate overloads (type guards) narrow the output type
|
|
34
|
+
*
|
|
35
|
+
* @see https://utils.duplojs.dev/en/v1/api/pattern/isMatch
|
|
36
|
+
*
|
|
37
|
+
* @namespace P
|
|
38
|
+
*
|
|
39
|
+
*/
|
|
4
40
|
export declare function isMatch<GenericInput extends AnyValue, const GenericPattern extends Pattern<GenericInput>>(pattern: FixDeepFunctionInfer<Pattern<GenericInput>, GenericPattern>): (input: GenericInput) => input is ForcePredicate<GenericInput, ComplexMatchedValue<GenericInput, PatternValue<GenericPattern>>>;
|
|
5
41
|
export declare function isMatch<GenericInput extends AnyValue, const GenericPattern extends Pattern<GenericInput>>(input: GenericInput, pattern: FixDeepFunctionInfer<Pattern<GenericInput>, GenericPattern>): input is ForcePredicate<GenericInput, ComplexMatchedValue<GenericInput, PatternValue<GenericPattern>>>;
|
|
@@ -4,6 +4,64 @@ import { type PatternResult } from "../result";
|
|
|
4
4
|
import { type ComplexMatchedValue, type ComplexUnMatchedValue } from "../types";
|
|
5
5
|
import { type MatchBuilder } from "./builder";
|
|
6
6
|
export * from "./builder";
|
|
7
|
+
/**
|
|
8
|
+
* Creates a match builder or applies a single pattern.
|
|
9
|
+
*
|
|
10
|
+
* **Supported call styles:**
|
|
11
|
+
* - Classic: `match(input)` → returns a match builder
|
|
12
|
+
* - Classic: `match(input, pattern, handler)` → returns a result or the input
|
|
13
|
+
* - Curried: `match(pattern, handler)` → returns a function waiting for the input
|
|
14
|
+
*
|
|
15
|
+
* If the input matches the pattern, the handler runs and the result is wrapped for chaining.
|
|
16
|
+
* The input is not mutated.
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* const input = <{
|
|
20
|
+
* type: "text";
|
|
21
|
+
* value: string;
|
|
22
|
+
* } | {
|
|
23
|
+
* type: "count";
|
|
24
|
+
* value: number;
|
|
25
|
+
* }>{
|
|
26
|
+
* type: "text",
|
|
27
|
+
* value: "hello",
|
|
28
|
+
* };
|
|
29
|
+
*
|
|
30
|
+
* P.match(input)
|
|
31
|
+
* .with(
|
|
32
|
+
* { type: "text" },
|
|
33
|
+
* (item) => item.value.toUpperCase(),
|
|
34
|
+
* )
|
|
35
|
+
* .with(
|
|
36
|
+
* { type: "count" },
|
|
37
|
+
* (item) => `${item.value}:${item.type}`,
|
|
38
|
+
* )
|
|
39
|
+
* .otherwise(() => "unknown"); // "HELLO"
|
|
40
|
+
*
|
|
41
|
+
* pipe(
|
|
42
|
+
* input,
|
|
43
|
+
* P.match(
|
|
44
|
+
* { type: "count" },
|
|
45
|
+
* (item) => item.value * 2,
|
|
46
|
+
* ),
|
|
47
|
+
* P.otherwise(() => 0),
|
|
48
|
+
* ); // 4
|
|
49
|
+
*
|
|
50
|
+
* P.match(input)
|
|
51
|
+
* .when(
|
|
52
|
+
* (item) => typeof item === "number",
|
|
53
|
+
* () => "ok",
|
|
54
|
+
* )
|
|
55
|
+
* .otherwise(() => "no"); // "ok"
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @see [`P.when`](https://utils.duplojs.dev/en/v1/api/pattern/when) For predicate branches
|
|
59
|
+
* @see [`P.otherwise`](https://utils.duplojs.dev/en/v1/api/pattern/otherwise) For fallbacks
|
|
60
|
+
* @see https://utils.duplojs.dev/en/v1/api/pattern/match
|
|
61
|
+
*
|
|
62
|
+
* @namespace P
|
|
63
|
+
*
|
|
64
|
+
*/
|
|
7
65
|
export declare function match<GenericInput extends unknown>(input: GenericInput): MatchBuilder<IsEqual<GenericInput, unknown> extends true ? AnyValue : GenericInput>;
|
|
8
66
|
export declare function match<GenericInput extends unknown, GenericInputValue extends Exclude<IsEqual<GenericInput, unknown> extends true ? AnyValue : GenericInput, PatternResult>, GenericInputPatternResult extends Extract<GenericInput, PatternResult>, const GenericPattern extends Pattern<GenericInputValue>, GenericPatternValue extends PatternValue<GenericPattern>, GenericOutput extends AnyValue | EscapeVoid, GenericMatchedValue extends Extract<ComplexMatchedValue<GenericInputValue, GenericPatternValue>, any>>(pattern: FixDeepFunctionInfer<Pattern<GenericInputValue>, GenericPattern>, theFunction: (value: Extract<ComplexMatchedValue<GenericInputValue, PatternValue<GenericPattern>>, any>) => GenericOutput): (input: GenericInput | GenericInputValue | GenericInputPatternResult) => BreakGenericLink<((IsEqual<GenericMatchedValue, never> extends true ? never : PatternResult<GenericOutput>) | GenericInputPatternResult | Extract<ComplexUnMatchedValue<GenericInputValue, GenericPatternValue>, any>)>;
|
|
9
67
|
export declare function match<GenericInput extends unknown, GenericInputValue extends Exclude<IsEqual<GenericInput, unknown> extends true ? AnyValue : GenericInput, PatternResult>, GenericInputPatternResult extends Extract<GenericInput, PatternResult>, const GenericPattern extends Pattern<GenericInputValue>, GenericPatternValue extends PatternValue<GenericPattern>, GenericOutput extends AnyValue | EscapeVoid, GenericMatchedValue extends Extract<ComplexMatchedValue<GenericInputValue, GenericPatternValue>, any>>(input: GenericInput | GenericInputValue | GenericInputPatternResult, pattern: FixDeepFunctionInfer<Pattern<GenericInputValue>, GenericPattern>, theFunction: (value: Extract<ComplexMatchedValue<GenericInputValue, PatternValue<GenericPattern>>, any>) => GenericOutput): BreakGenericLink<(IsEqual<GenericMatchedValue, never> extends true ? never : PatternResult<GenericOutput>) | GenericInputPatternResult | Extract<ComplexUnMatchedValue<GenericInputValue, GenericPatternValue>, any>>;
|
|
@@ -1,4 +1,60 @@
|
|
|
1
1
|
import { type AnyValue, type Unwrap } from "../common";
|
|
2
2
|
import { type PatternResult } from "./result";
|
|
3
|
+
/**
|
|
4
|
+
* Applies a fallback handler when no prior pattern matched.
|
|
5
|
+
*
|
|
6
|
+
* **Supported call styles:**
|
|
7
|
+
* - Classic: `otherwise(input, handler)` → returns the unwrapped result or fallback
|
|
8
|
+
* - Curried: `otherwise(handler)` → returns a function waiting for the input
|
|
9
|
+
*
|
|
10
|
+
* If the input is already a pattern result, it is unwrapped and returned.
|
|
11
|
+
* The input is not mutated.
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* const input = <{
|
|
15
|
+
* type: "text";
|
|
16
|
+
* value: string;
|
|
17
|
+
* } | {
|
|
18
|
+
* type: "count";
|
|
19
|
+
* value: number;
|
|
20
|
+
* }>{
|
|
21
|
+
* type: "text",
|
|
22
|
+
* value: "hello",
|
|
23
|
+
* };
|
|
24
|
+
*
|
|
25
|
+
* P.match(input)
|
|
26
|
+
* .with(
|
|
27
|
+
* { type: "text" },
|
|
28
|
+
* (item) => item.value.toUpperCase(),
|
|
29
|
+
* )
|
|
30
|
+
* .with(
|
|
31
|
+
* { type: "count" },
|
|
32
|
+
* (item) => `${item.value}:${item.type}`,
|
|
33
|
+
* )
|
|
34
|
+
* .otherwise(() => "unknown"); // "HELLO"
|
|
35
|
+
*
|
|
36
|
+
* pipe(
|
|
37
|
+
* input,
|
|
38
|
+
* P.match(
|
|
39
|
+
* { type: "count" },
|
|
40
|
+
* (item) => item.value * 2,
|
|
41
|
+
* ),
|
|
42
|
+
* P.otherwise(() => 0),
|
|
43
|
+
* ); // 4
|
|
44
|
+
*
|
|
45
|
+
* P.match(input)
|
|
46
|
+
* .when(
|
|
47
|
+
* (item) => typeof item === "number",
|
|
48
|
+
* () => "ok",
|
|
49
|
+
* )
|
|
50
|
+
* .otherwise(() => "no"); // "ok"
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @see [`P.match`](https://utils.duplojs.dev/en/v1/api/pattern/match) For building match chains
|
|
54
|
+
* @see https://utils.duplojs.dev/en/v1/api/pattern/otherwise
|
|
55
|
+
*
|
|
56
|
+
* @namespace P
|
|
57
|
+
*
|
|
58
|
+
*/
|
|
3
59
|
export declare function otherwise<GenericInput extends AnyValue, GenericInputValue extends Exclude<GenericInput, PatternResult>, GenericInputPatternResult extends Extract<GenericInput, PatternResult>, GenericOutput extends AnyValue>(theFunction: (rest: GenericInputValue) => GenericOutput): (input: GenericInput | GenericInputPatternResult | GenericInputValue) => (GenericOutput | Unwrap<GenericInputPatternResult>);
|
|
4
60
|
export declare function otherwise<GenericInput extends AnyValue, GenericInputValue extends Exclude<GenericInput, PatternResult>, GenericInputPatternResult extends Extract<GenericInput, PatternResult>, GenericOutput extends AnyValue>(input: GenericInput | GenericInputPatternResult | GenericInputValue, theFunction: (rest: GenericInputValue) => GenericOutput): (GenericOutput | Unwrap<GenericInputPatternResult>);
|
package/dist/pattern/union.cjs
CHANGED
|
@@ -4,6 +4,9 @@ var isMatch = require('./isMatch.cjs');
|
|
|
4
4
|
var pattern = require('./types/pattern.cjs');
|
|
5
5
|
|
|
6
6
|
const SymbolToolPatternFunction = Symbol.for(pattern.SymbolToolPatternFunctionLabel);
|
|
7
|
+
/**
|
|
8
|
+
* {@include pattern/union/index.md}
|
|
9
|
+
*/
|
|
7
10
|
function union(...patterns) {
|
|
8
11
|
return {
|
|
9
12
|
[SymbolToolPatternFunction]: (input) => {
|
package/dist/pattern/union.d.ts
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
import { type FixDeepFunctionInfer } from "../common";
|
|
2
2
|
import { type Pattern, type ToolPattern } from "./types/pattern";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a pattern that matches any of the provided patterns.
|
|
5
|
+
*
|
|
6
|
+
* Signature: `union(...patterns)` → returns a pattern tool
|
|
7
|
+
*
|
|
8
|
+
* The returned tool can be used with `match` or `isMatch`.
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* const input = <{
|
|
12
|
+
* kind: "text";
|
|
13
|
+
* content: string;
|
|
14
|
+
* } | {
|
|
15
|
+
* kind: "error";
|
|
16
|
+
* message: string;
|
|
17
|
+
* } | {
|
|
18
|
+
* kind: "image";
|
|
19
|
+
* url: string;
|
|
20
|
+
* }>{
|
|
21
|
+
* kind: "text",
|
|
22
|
+
* content: "hello",
|
|
23
|
+
* };
|
|
24
|
+
*
|
|
25
|
+
* P.match(
|
|
26
|
+
* input,
|
|
27
|
+
* forward({ kind: P.union("text", "image") }),
|
|
28
|
+
* () => {
|
|
29
|
+
* // { kind: "text"; content: string; } | { kind: "error"; message: string;}
|
|
30
|
+
* },
|
|
31
|
+
* );
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @see [`P.isMatch`](https://utils.duplojs.dev/en/v1/api/pattern/isMatch) For checking values
|
|
35
|
+
* @see https://utils.duplojs.dev/en/v1/api/pattern/union
|
|
36
|
+
*
|
|
37
|
+
* @namespace P
|
|
38
|
+
*
|
|
39
|
+
*/
|
|
3
40
|
export declare function union<GenericInput extends unknown, const GenericPatterns extends readonly [
|
|
4
41
|
Pattern<GenericInput extends infer InferredInput ? InferredInput : never>,
|
|
5
42
|
...Pattern<GenericInput extends infer InferredInput ? InferredInput : never>[]
|
package/dist/pattern/union.mjs
CHANGED
|
@@ -2,6 +2,9 @@ import { isMatch } from './isMatch.mjs';
|
|
|
2
2
|
import { SymbolToolPatternFunctionLabel } from './types/pattern.mjs';
|
|
3
3
|
|
|
4
4
|
const SymbolToolPatternFunction = Symbol.for(SymbolToolPatternFunctionLabel);
|
|
5
|
+
/**
|
|
6
|
+
* {@include pattern/union/index.md}
|
|
7
|
+
*/
|
|
5
8
|
function union(...patterns) {
|
|
6
9
|
return {
|
|
7
10
|
[SymbolToolPatternFunction]: (input) => {
|
package/dist/pattern/when.d.ts
CHANGED
|
@@ -1,5 +1,48 @@
|
|
|
1
1
|
import { type AnyValue, type BreakGenericLink, type IsEqual, type EscapeVoid } from "../common";
|
|
2
2
|
import { type PatternResult } from "./result";
|
|
3
|
+
/**
|
|
4
|
+
* Applies a handler when a predicate matches.
|
|
5
|
+
*
|
|
6
|
+
* **Supported call styles:**
|
|
7
|
+
* - Classic: `when(input, predicate, handler)` → returns a result or the input
|
|
8
|
+
* - Curried: `when(predicate, handler)` → returns a function waiting for the input
|
|
9
|
+
* - Classic predicate: `when(input, isType, handler)` → narrows input types
|
|
10
|
+
* - Curried predicate: `when(isType, handler)` → narrows input types
|
|
11
|
+
*
|
|
12
|
+
* If the predicate matches, the handler runs and the result is wrapped for chaining.
|
|
13
|
+
* The input is not mutated.
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* pipe(
|
|
17
|
+
* 5,
|
|
18
|
+
* P.when(
|
|
19
|
+
* (value) => value > 3,
|
|
20
|
+
* (value) => value * 2,
|
|
21
|
+
* ),
|
|
22
|
+
* P.otherwise((value) => value),
|
|
23
|
+
* ); // 10
|
|
24
|
+
*
|
|
25
|
+
* A.map(
|
|
26
|
+
* <const>["alpha", 2],
|
|
27
|
+
* innerPipe(
|
|
28
|
+
* P.when(
|
|
29
|
+
* isType("string"),
|
|
30
|
+
* (value) => value.toUpperCase(),
|
|
31
|
+
* ),
|
|
32
|
+
* P.otherwise((value) => value),
|
|
33
|
+
* ),
|
|
34
|
+
* ); // ["ALPHA", 2]
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* - Predicate overloads (type guards) narrow the output type
|
|
39
|
+
*
|
|
40
|
+
* @see [`P.otherwise`](https://utils.duplojs.dev/en/v1/api/pattern/otherwise) For fallbacks
|
|
41
|
+
* @see https://utils.duplojs.dev/en/v1/api/pattern/when
|
|
42
|
+
*
|
|
43
|
+
* @namespace P
|
|
44
|
+
*
|
|
45
|
+
*/
|
|
3
46
|
export declare function when<GenericInput extends unknown, GenericInputValue extends Exclude<IsEqual<GenericInput, unknown> extends true ? AnyValue : GenericInput, PatternResult>, GenericInputPatternResult extends Extract<GenericInput, PatternResult>, GenericPredicatedInput extends GenericInputValue, GenericOutput extends AnyValue | EscapeVoid>(predicate: (input: GenericInputValue) => input is GenericPredicatedInput, theFunction: (predicatedInput: GenericPredicatedInput) => GenericOutput): (input: (GenericInput | GenericInputPatternResult | GenericInputValue)) => (GenericInputPatternResult | Exclude<BreakGenericLink<GenericInput>, GenericPredicatedInput | PatternResult> | PatternResult<GenericOutput>);
|
|
4
47
|
export declare function when<GenericInput extends unknown, GenericInputValue extends Exclude<IsEqual<GenericInput, unknown> extends true ? AnyValue : GenericInput, PatternResult>, GenericInputPatternResult extends Extract<GenericInput, PatternResult>, GenericOutput extends AnyValue | EscapeVoid>(predicate: (input: GenericInputValue) => boolean, theFunction: (predicatedInput: GenericInputValue) => GenericOutput): (input: (GenericInput | GenericInputPatternResult | GenericInputValue)) => (GenericInputPatternResult | GenericInputValue | PatternResult<GenericOutput>);
|
|
5
48
|
export declare function when<GenericInput extends unknown, GenericInputValue extends Exclude<IsEqual<GenericInput, unknown> extends true ? AnyValue : GenericInput, PatternResult>, GenericInputPatternResult extends Extract<GenericInput, PatternResult>, GenericPredicatedInput extends GenericInputValue, GenericOutput extends AnyValue | EscapeVoid>(input: (GenericInput | GenericInputPatternResult | GenericInputValue), predicate: (input: GenericInputValue) => input is GenericPredicatedInput, theFunction: (predicatedInput: GenericPredicatedInput) => GenericOutput): (GenericInputPatternResult | Exclude<BreakGenericLink<GenericInput>, GenericPredicatedInput | PatternResult> | PatternResult<GenericOutput>);
|
|
@@ -1,2 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the character at a given index.
|
|
3
|
+
*
|
|
4
|
+
* **Supported call styles:**
|
|
5
|
+
* - Classic: `at(input, index)` → returns a character or `undefined`
|
|
6
|
+
* - Curried: `at(index)` → returns a function waiting for the input
|
|
7
|
+
*
|
|
8
|
+
* Negative indexes count from the end.
|
|
9
|
+
* The input string is not mutated.
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* S.at("DuploJS", -1); // "S"
|
|
13
|
+
*
|
|
14
|
+
* pipe(
|
|
15
|
+
* "TypeScript",
|
|
16
|
+
* S.at(-1),
|
|
17
|
+
* ); // "t"
|
|
18
|
+
*
|
|
19
|
+
* S.at("Alpha", 12); // undefined
|
|
20
|
+
*
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* - Uses the same semantics as [`String.prototype.at`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/at)
|
|
25
|
+
*
|
|
26
|
+
* @see https://utils.duplojs.dev/en/v1/api/string/at
|
|
27
|
+
*
|
|
28
|
+
* @namespace S
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
1
31
|
export declare function at<GenericString extends string, GenericIndex extends number>(index: GenericIndex): (input: GenericString) => string | undefined;
|
|
2
32
|
export declare function at<GenericString extends string, GenericIndex extends number>(input: GenericString, index: GenericIndex): string | undefined;
|