@duplojs/utils 1.1.15 → 1.2.16
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/reduce.cjs +25 -0
- package/dist/array/reduce.mjs +25 -0
- package/dist/array/reduceRight.cjs +25 -0
- package/dist/array/reduceRight.mjs +25 -0
- package/dist/array/types/extractTuple.d.ts +1 -1
- package/dist/common/asyncInnerPipe.d.ts +16 -11
- package/dist/common/asyncPipe.d.ts +16 -11
- package/dist/common/builder.cjs +5 -11
- package/dist/common/builder.d.ts +7 -7
- package/dist/common/builder.mjs +4 -10
- package/dist/common/createKindIdentifier.cjs +23 -0
- package/dist/common/createKindIdentifier.mjs +23 -0
- package/dist/common/equal.d.ts +4 -4
- package/dist/common/errorKindNamespace.cjs +9 -0
- package/dist/common/errorKindNamespace.d.ts +1 -0
- package/dist/common/errorKindNamespace.mjs +7 -0
- package/dist/common/forwardLog.cjs +8 -0
- package/dist/common/forwardLog.d.ts +1 -0
- package/dist/common/forwardLog.mjs +6 -0
- package/dist/common/index.d.ts +3 -0
- package/dist/common/innerPipe.d.ts +16 -11
- package/dist/common/instanceOf.cjs +25 -0
- package/dist/common/instanceOf.mjs +25 -0
- package/dist/common/kind.d.ts +1 -0
- package/dist/common/override.cjs +61 -0
- package/dist/common/override.d.ts +18 -0
- package/dist/common/override.mjs +59 -0
- package/dist/common/pipe.d.ts +16 -11
- package/dist/common/stringToBytes.cjs +4 -9
- package/dist/common/stringToBytes.d.ts +4 -4
- package/dist/common/stringToBytes.mjs +4 -9
- package/dist/common/stringToMillisecond.cjs +4 -9
- package/dist/common/stringToMillisecond.d.ts +4 -4
- package/dist/common/stringToMillisecond.mjs +4 -9
- package/dist/common/types/objectEntry.d.ts +1 -1
- package/dist/dataParser/base.cjs +27 -2
- package/dist/dataParser/base.d.ts +3 -0
- package/dist/dataParser/base.mjs +27 -2
- package/dist/dataParser/baseExtended.cjs +65 -5
- package/dist/dataParser/baseExtended.d.ts +3 -0
- package/dist/dataParser/baseExtended.mjs +65 -5
- package/dist/dataParser/extended/array.cjs +50 -4
- package/dist/dataParser/extended/array.d.ts +3 -0
- package/dist/dataParser/extended/array.mjs +50 -4
- package/dist/dataParser/extended/bigint.cjs +50 -4
- package/dist/dataParser/extended/bigint.d.ts +3 -0
- package/dist/dataParser/extended/bigint.mjs +50 -4
- package/dist/dataParser/extended/boolean.cjs +50 -4
- package/dist/dataParser/extended/boolean.d.ts +3 -0
- package/dist/dataParser/extended/boolean.mjs +50 -4
- package/dist/dataParser/extended/coerce/bigint.cjs +21 -4
- package/dist/dataParser/extended/coerce/bigint.mjs +21 -4
- package/dist/dataParser/extended/coerce/boolean.cjs +21 -4
- package/dist/dataParser/extended/coerce/boolean.mjs +21 -4
- package/dist/dataParser/extended/coerce/date.cjs +33 -0
- package/dist/dataParser/extended/coerce/date.d.ts +7 -0
- package/dist/dataParser/extended/coerce/date.mjs +31 -0
- package/dist/dataParser/extended/coerce/empty.cjs +21 -4
- package/dist/dataParser/extended/coerce/empty.mjs +21 -4
- package/dist/dataParser/extended/coerce/index.cjs +2 -0
- package/dist/dataParser/extended/coerce/index.d.ts +1 -0
- package/dist/dataParser/extended/coerce/index.mjs +1 -0
- package/dist/dataParser/extended/coerce/nil.cjs +21 -4
- package/dist/dataParser/extended/coerce/nil.mjs +21 -4
- package/dist/dataParser/extended/coerce/number.cjs +21 -4
- package/dist/dataParser/extended/coerce/number.mjs +21 -4
- package/dist/dataParser/extended/coerce/string.cjs +21 -4
- package/dist/dataParser/extended/coerce/string.mjs +21 -4
- package/dist/dataParser/extended/date.cjs +60 -0
- package/dist/dataParser/extended/date.d.ts +23 -0
- package/dist/dataParser/extended/date.mjs +58 -0
- package/dist/dataParser/extended/empty.cjs +50 -4
- package/dist/dataParser/extended/empty.d.ts +3 -0
- package/dist/dataParser/extended/empty.mjs +50 -4
- package/dist/dataParser/extended/index.cjs +15 -0
- package/dist/dataParser/extended/index.d.ts +3 -0
- package/dist/dataParser/extended/index.mjs +2 -0
- package/dist/dataParser/extended/lazy.cjs +50 -4
- package/dist/dataParser/extended/lazy.d.ts +5 -2
- package/dist/dataParser/extended/lazy.mjs +50 -4
- package/dist/dataParser/extended/literal.cjs +50 -4
- package/dist/dataParser/extended/literal.d.ts +3 -0
- package/dist/dataParser/extended/literal.mjs +50 -4
- package/dist/dataParser/extended/nil.cjs +50 -4
- package/dist/dataParser/extended/nil.d.ts +3 -0
- package/dist/dataParser/extended/nil.mjs +50 -4
- package/dist/dataParser/extended/nullable.cjs +50 -4
- package/dist/dataParser/extended/nullable.d.ts +3 -0
- package/dist/dataParser/extended/nullable.mjs +50 -4
- package/dist/dataParser/extended/number.cjs +50 -4
- package/dist/dataParser/extended/number.d.ts +3 -0
- package/dist/dataParser/extended/number.mjs +50 -4
- package/dist/dataParser/extended/object.cjs +65 -5
- package/dist/dataParser/extended/object.d.ts +5 -0
- package/dist/dataParser/extended/object.mjs +65 -5
- package/dist/dataParser/extended/optional.cjs +50 -4
- package/dist/dataParser/extended/optional.d.ts +3 -0
- package/dist/dataParser/extended/optional.mjs +50 -4
- package/dist/dataParser/extended/pipe.cjs +50 -4
- package/dist/dataParser/extended/pipe.d.ts +3 -0
- package/dist/dataParser/extended/pipe.mjs +50 -4
- package/dist/dataParser/extended/record.cjs +50 -4
- package/dist/dataParser/extended/record.d.ts +3 -0
- package/dist/dataParser/extended/record.mjs +50 -4
- package/dist/dataParser/extended/recover.cjs +50 -4
- package/dist/dataParser/extended/recover.d.ts +3 -0
- package/dist/dataParser/extended/recover.mjs +50 -4
- package/dist/dataParser/extended/string.cjs +51 -5
- package/dist/dataParser/extended/string.d.ts +3 -0
- package/dist/dataParser/extended/string.mjs +51 -5
- package/dist/dataParser/extended/templateLiteral.cjs +50 -4
- package/dist/dataParser/extended/templateLiteral.d.ts +3 -0
- package/dist/dataParser/extended/templateLiteral.mjs +50 -4
- package/dist/dataParser/extended/transform.cjs +50 -4
- package/dist/dataParser/extended/transform.d.ts +3 -0
- package/dist/dataParser/extended/transform.mjs +50 -4
- package/dist/dataParser/extended/tuple.cjs +52 -6
- package/dist/dataParser/extended/tuple.d.ts +3 -0
- package/dist/dataParser/extended/tuple.mjs +52 -6
- package/dist/dataParser/extended/union.cjs +50 -4
- package/dist/dataParser/extended/union.d.ts +3 -0
- package/dist/dataParser/extended/union.mjs +50 -4
- package/dist/dataParser/extended/unknown.cjs +50 -4
- package/dist/dataParser/extended/unknown.d.ts +3 -0
- package/dist/dataParser/extended/unknown.mjs +50 -4
- package/dist/dataParser/identifier.cjs +3 -0
- package/dist/dataParser/identifier.d.ts +52 -10
- package/dist/dataParser/identifier.mjs +3 -0
- package/dist/dataParser/index.cjs +25 -18
- package/dist/dataParser/index.mjs +4 -1
- package/dist/dataParser/kind.cjs +25 -0
- package/dist/dataParser/kind.mjs +25 -0
- package/dist/dataParser/parsers/array/index.cjs +36 -1
- package/dist/dataParser/parsers/array/index.d.ts +3 -0
- package/dist/dataParser/parsers/array/index.mjs +32 -1
- package/dist/dataParser/parsers/bigint/index.cjs +36 -1
- package/dist/dataParser/parsers/bigint/index.d.ts +3 -0
- package/dist/dataParser/parsers/bigint/index.mjs +32 -1
- package/dist/dataParser/parsers/boolean.cjs +30 -1
- package/dist/dataParser/parsers/boolean.d.ts +3 -0
- package/dist/dataParser/parsers/boolean.mjs +30 -1
- package/dist/dataParser/parsers/coerce/bigint.cjs +21 -4
- package/dist/dataParser/parsers/coerce/bigint.mjs +21 -4
- package/dist/dataParser/parsers/coerce/boolean.cjs +21 -4
- package/dist/dataParser/parsers/coerce/boolean.mjs +21 -4
- package/dist/dataParser/parsers/coerce/date.cjs +33 -0
- package/dist/dataParser/parsers/coerce/date.d.ts +6 -0
- package/dist/dataParser/parsers/coerce/date.mjs +31 -0
- package/dist/dataParser/parsers/coerce/empty.cjs +21 -4
- package/dist/dataParser/parsers/coerce/empty.mjs +21 -4
- package/dist/dataParser/parsers/coerce/index.cjs +2 -0
- package/dist/dataParser/parsers/coerce/index.d.ts +1 -0
- package/dist/dataParser/parsers/coerce/index.mjs +1 -0
- package/dist/dataParser/parsers/coerce/nil.cjs +21 -4
- package/dist/dataParser/parsers/coerce/nil.mjs +21 -4
- package/dist/dataParser/parsers/coerce/number.cjs +21 -4
- package/dist/dataParser/parsers/coerce/number.mjs +21 -4
- package/dist/dataParser/parsers/coerce/string.cjs +21 -4
- package/dist/dataParser/parsers/coerce/string.mjs +21 -4
- package/dist/dataParser/parsers/date.cjs +79 -0
- package/dist/dataParser/parsers/date.d.ts +28 -0
- package/dist/dataParser/parsers/date.mjs +76 -0
- package/dist/dataParser/parsers/empty.cjs +30 -1
- package/dist/dataParser/parsers/empty.d.ts +3 -0
- package/dist/dataParser/parsers/empty.mjs +30 -1
- package/dist/dataParser/parsers/index.d.ts +1 -0
- package/dist/dataParser/parsers/lazy.cjs +34 -4
- package/dist/dataParser/parsers/lazy.d.ts +7 -4
- package/dist/dataParser/parsers/lazy.mjs +34 -4
- package/dist/dataParser/parsers/literal.cjs +31 -4
- package/dist/dataParser/parsers/literal.d.ts +3 -0
- package/dist/dataParser/parsers/literal.mjs +31 -4
- package/dist/dataParser/parsers/nil.cjs +30 -1
- package/dist/dataParser/parsers/nil.d.ts +3 -0
- package/dist/dataParser/parsers/nil.mjs +30 -1
- package/dist/dataParser/parsers/nullable.cjs +30 -1
- package/dist/dataParser/parsers/nullable.d.ts +3 -0
- package/dist/dataParser/parsers/nullable.mjs +30 -1
- package/dist/dataParser/parsers/number/index.cjs +40 -1
- package/dist/dataParser/parsers/number/index.d.ts +3 -0
- package/dist/dataParser/parsers/number/index.mjs +33 -1
- package/dist/dataParser/parsers/{object.cjs → object/index.cjs} +39 -12
- package/dist/dataParser/parsers/{object.d.ts → object/index.d.ts} +16 -12
- package/dist/dataParser/parsers/{object.mjs → object/index.mjs} +39 -12
- package/dist/dataParser/parsers/object/omit.cjs +42 -0
- package/dist/dataParser/parsers/object/omit.d.ts +6 -0
- package/dist/dataParser/parsers/object/omit.mjs +40 -0
- package/dist/dataParser/parsers/object/pick.cjs +42 -0
- package/dist/dataParser/parsers/object/pick.d.ts +6 -0
- package/dist/dataParser/parsers/object/pick.mjs +40 -0
- package/dist/dataParser/parsers/optional.cjs +30 -1
- package/dist/dataParser/parsers/optional.d.ts +3 -0
- package/dist/dataParser/parsers/optional.mjs +30 -1
- package/dist/dataParser/parsers/pipe.cjs +30 -1
- package/dist/dataParser/parsers/pipe.d.ts +3 -0
- package/dist/dataParser/parsers/pipe.mjs +30 -1
- package/dist/dataParser/parsers/record/findRecordRequiredKey.cjs +26 -0
- package/dist/dataParser/parsers/record/findRecordRequiredKey.mjs +26 -0
- package/dist/dataParser/parsers/record/index.cjs +30 -1
- package/dist/dataParser/parsers/record/index.d.ts +3 -0
- package/dist/dataParser/parsers/record/index.mjs +30 -1
- package/dist/dataParser/parsers/recover.cjs +30 -1
- package/dist/dataParser/parsers/recover.d.ts +3 -0
- package/dist/dataParser/parsers/recover.mjs +30 -1
- package/dist/dataParser/parsers/string/index.cjs +47 -1
- package/dist/dataParser/parsers/string/index.d.ts +3 -0
- package/dist/dataParser/parsers/string/index.mjs +35 -1
- package/dist/dataParser/parsers/templateLiteral/createTemplateLiteralPattern.cjs +26 -0
- package/dist/dataParser/parsers/templateLiteral/createTemplateLiteralPattern.mjs +26 -0
- package/dist/dataParser/parsers/templateLiteral/index.cjs +28 -1
- package/dist/dataParser/parsers/templateLiteral/index.d.ts +3 -0
- package/dist/dataParser/parsers/templateLiteral/index.mjs +28 -1
- package/dist/dataParser/parsers/transform.cjs +30 -1
- package/dist/dataParser/parsers/transform.d.ts +3 -0
- package/dist/dataParser/parsers/transform.mjs +30 -1
- package/dist/dataParser/parsers/tuple.cjs +30 -1
- package/dist/dataParser/parsers/tuple.d.ts +3 -0
- package/dist/dataParser/parsers/tuple.mjs +30 -1
- package/dist/dataParser/parsers/union.cjs +30 -1
- package/dist/dataParser/parsers/union.d.ts +3 -0
- package/dist/dataParser/parsers/union.mjs +30 -1
- package/dist/dataParser/parsers/unknown.cjs +30 -1
- package/dist/dataParser/parsers/unknown.d.ts +3 -0
- package/dist/dataParser/parsers/unknown.mjs +30 -1
- package/dist/dataParser/types/dataParsers.d.ts +2 -2
- package/dist/date/closestTo.cjs +32 -0
- package/dist/date/closestTo.d.ts +7 -0
- package/dist/date/closestTo.mjs +30 -0
- package/dist/date/constants.cjs +29 -0
- package/dist/date/constants.d.ts +13 -0
- package/dist/date/constants.mjs +15 -0
- package/dist/date/create.cjs +75 -0
- package/dist/date/create.d.ts +16 -0
- package/dist/date/create.mjs +73 -0
- package/dist/date/createOrThrow.cjs +52 -0
- package/dist/date/createOrThrow.d.ts +10 -0
- package/dist/date/createOrThrow.mjs +49 -0
- package/dist/date/each.cjs +47 -0
- package/dist/date/each.d.ts +5 -0
- package/dist/date/each.mjs +45 -0
- package/dist/date/getters/getDayOfMonth.cjs +47 -0
- package/dist/date/getters/getDayOfMonth.d.ts +2 -0
- package/dist/date/getters/getDayOfMonth.mjs +45 -0
- package/dist/date/getters/getDayOfWeek.cjs +57 -0
- package/dist/date/getters/getDayOfWeek.d.ts +2 -0
- package/dist/date/getters/getDayOfWeek.mjs +55 -0
- package/dist/date/getters/getDayOfYear.cjs +64 -0
- package/dist/date/getters/getDayOfYear.d.ts +2 -0
- package/dist/date/getters/getDayOfYear.mjs +62 -0
- package/dist/date/getters/getFirstDayOfMonth.cjs +14 -0
- package/dist/date/getters/getFirstDayOfMonth.d.ts +2 -0
- package/dist/date/getters/getFirstDayOfMonth.mjs +12 -0
- package/dist/date/getters/getFirstDayOfWeek.cjs +16 -0
- package/dist/date/getters/getFirstDayOfWeek.d.ts +2 -0
- package/dist/date/getters/getFirstDayOfWeek.mjs +14 -0
- package/dist/date/getters/getHour.cjs +48 -0
- package/dist/date/getters/getHour.d.ts +2 -0
- package/dist/date/getters/getHour.mjs +46 -0
- package/dist/date/getters/getLastDayOfMonth.cjs +14 -0
- package/dist/date/getters/getLastDayOfMonth.d.ts +2 -0
- package/dist/date/getters/getLastDayOfMonth.mjs +12 -0
- package/dist/date/getters/getLastDayOfWeek.cjs +16 -0
- package/dist/date/getters/getLastDayOfWeek.d.ts +2 -0
- package/dist/date/getters/getLastDayOfWeek.mjs +14 -0
- package/dist/date/getters/getMilliseconds.cjs +40 -0
- package/dist/date/getters/getMilliseconds.d.ts +2 -0
- package/dist/date/getters/getMilliseconds.mjs +38 -0
- package/dist/date/getters/getMinute.cjs +47 -0
- package/dist/date/getters/getMinute.d.ts +2 -0
- package/dist/date/getters/getMinute.mjs +45 -0
- package/dist/date/getters/getMonth.cjs +47 -0
- package/dist/date/getters/getMonth.d.ts +2 -0
- package/dist/date/getters/getMonth.mjs +45 -0
- package/dist/date/getters/getSecond.cjs +47 -0
- package/dist/date/getters/getSecond.d.ts +2 -0
- package/dist/date/getters/getSecond.mjs +45 -0
- package/dist/date/getters/getWeekOfYear.cjs +67 -0
- package/dist/date/getters/getWeekOfYear.d.ts +2 -0
- package/dist/date/getters/getWeekOfYear.mjs +65 -0
- package/dist/date/getters/getYear.cjs +47 -0
- package/dist/date/getters/getYear.d.ts +2 -0
- package/dist/date/getters/getYear.mjs +45 -0
- package/dist/date/getters/index.d.ts +15 -0
- package/dist/date/index.cjs +121 -0
- package/dist/date/index.d.ts +18 -0
- package/dist/date/index.mjs +51 -0
- package/dist/date/isSafeTimestamp.cjs +15 -0
- package/dist/date/isSafeTimestamp.d.ts +1 -0
- package/dist/date/isSafeTimestamp.mjs +13 -0
- package/dist/date/now.cjs +8 -0
- package/dist/date/now.d.ts +1 -0
- package/dist/date/now.mjs +6 -0
- package/dist/date/operators/addDays.cjs +20 -0
- package/dist/date/operators/addDays.d.ts +4 -0
- package/dist/date/operators/addDays.mjs +18 -0
- package/dist/date/operators/addHours.cjs +20 -0
- package/dist/date/operators/addHours.d.ts +4 -0
- package/dist/date/operators/addHours.mjs +18 -0
- package/dist/date/operators/addMilliseconds.cjs +19 -0
- package/dist/date/operators/addMilliseconds.d.ts +4 -0
- package/dist/date/operators/addMilliseconds.mjs +17 -0
- package/dist/date/operators/addMinutes.cjs +20 -0
- package/dist/date/operators/addMinutes.d.ts +4 -0
- package/dist/date/operators/addMinutes.mjs +18 -0
- package/dist/date/operators/addMonths.cjs +19 -0
- package/dist/date/operators/addMonths.d.ts +4 -0
- package/dist/date/operators/addMonths.mjs +17 -0
- package/dist/date/operators/addSeconds.cjs +20 -0
- package/dist/date/operators/addSeconds.d.ts +4 -0
- package/dist/date/operators/addSeconds.mjs +18 -0
- package/dist/date/operators/addWeeks.cjs +20 -0
- package/dist/date/operators/addWeeks.d.ts +4 -0
- package/dist/date/operators/addWeeks.mjs +18 -0
- package/dist/date/operators/addYears.cjs +19 -0
- package/dist/date/operators/addYears.d.ts +4 -0
- package/dist/date/operators/addYears.mjs +17 -0
- package/dist/date/operators/between.cjs +17 -0
- package/dist/date/operators/between.d.ts +3 -0
- package/dist/date/operators/between.mjs +15 -0
- package/dist/date/operators/betweenThan.cjs +17 -0
- package/dist/date/operators/betweenThan.d.ts +3 -0
- package/dist/date/operators/betweenThan.mjs +15 -0
- package/dist/date/operators/greater.cjs +16 -0
- package/dist/date/operators/greater.d.ts +3 -0
- package/dist/date/operators/greater.mjs +14 -0
- package/dist/date/operators/greaterThan.cjs +16 -0
- package/dist/date/operators/greaterThan.d.ts +3 -0
- package/dist/date/operators/greaterThan.mjs +14 -0
- package/dist/date/operators/index.d.ts +22 -0
- package/dist/date/operators/less.cjs +16 -0
- package/dist/date/operators/less.d.ts +3 -0
- package/dist/date/operators/less.mjs +14 -0
- package/dist/date/operators/lessThan.cjs +16 -0
- package/dist/date/operators/lessThan.d.ts +3 -0
- package/dist/date/operators/lessThan.mjs +14 -0
- package/dist/date/operators/subtractDays.cjs +20 -0
- package/dist/date/operators/subtractDays.d.ts +4 -0
- package/dist/date/operators/subtractDays.mjs +18 -0
- package/dist/date/operators/subtractHours.cjs +20 -0
- package/dist/date/operators/subtractHours.d.ts +4 -0
- package/dist/date/operators/subtractHours.mjs +18 -0
- package/dist/date/operators/subtractMilliseconds.cjs +19 -0
- package/dist/date/operators/subtractMilliseconds.d.ts +4 -0
- package/dist/date/operators/subtractMilliseconds.mjs +17 -0
- package/dist/date/operators/subtractMinutes.cjs +20 -0
- package/dist/date/operators/subtractMinutes.d.ts +4 -0
- package/dist/date/operators/subtractMinutes.mjs +18 -0
- package/dist/date/operators/subtractMonths.cjs +19 -0
- package/dist/date/operators/subtractMonths.d.ts +4 -0
- package/dist/date/operators/subtractMonths.mjs +17 -0
- package/dist/date/operators/subtractSeconds.cjs +20 -0
- package/dist/date/operators/subtractSeconds.d.ts +4 -0
- package/dist/date/operators/subtractSeconds.mjs +18 -0
- package/dist/date/operators/subtractWeeks.cjs +20 -0
- package/dist/date/operators/subtractWeeks.d.ts +4 -0
- package/dist/date/operators/subtractWeeks.mjs +18 -0
- package/dist/date/operators/subtractYears.cjs +19 -0
- package/dist/date/operators/subtractYears.d.ts +4 -0
- package/dist/date/operators/subtractYears.mjs +17 -0
- package/dist/date/round.cjs +23 -0
- package/dist/date/round.d.ts +3 -0
- package/dist/date/round.mjs +21 -0
- package/dist/date/toISOString.cjs +10 -0
- package/dist/date/toISOString.d.ts +2 -0
- package/dist/date/toISOString.mjs +8 -0
- package/dist/date/toNative.cjs +10 -0
- package/dist/date/toNative.d.ts +2 -0
- package/dist/date/toNative.mjs +8 -0
- package/dist/date/toTimestamp.cjs +58 -0
- package/dist/date/toTimestamp.d.ts +10 -0
- package/dist/date/toTimestamp.mjs +55 -0
- package/dist/date/today.cjs +8 -0
- package/dist/date/today.d.ts +1 -0
- package/dist/date/today.mjs +6 -0
- package/dist/date/tomorrow.cjs +10 -0
- package/dist/date/tomorrow.d.ts +1 -0
- package/dist/date/tomorrow.mjs +8 -0
- package/dist/date/types/index.d.ts +6 -0
- package/dist/date/types/isLeapYear.d.ts +8 -0
- package/dist/date/types/month.d.ts +9 -0
- package/dist/date/types/theDate.d.ts +1 -0
- package/dist/date/types/time.d.ts +5 -0
- package/dist/date/types/timezone.cjs +606 -0
- package/dist/date/types/timezone.d.ts +604 -0
- package/dist/date/types/timezone.mjs +604 -0
- package/dist/date/types/unit.d.ts +1 -0
- package/dist/date/yesterday.cjs +10 -0
- package/dist/date/yesterday.d.ts +1 -0
- package/dist/date/yesterday.mjs +8 -0
- package/dist/either/bool/falsy.cjs +22 -1
- package/dist/either/bool/falsy.mjs +22 -1
- package/dist/either/bool/truthy.cjs +23 -2
- package/dist/either/bool/truthy.mjs +23 -2
- package/dist/either/future/create.cjs +25 -2
- package/dist/either/future/create.mjs +25 -2
- package/dist/either/future/error.cjs +21 -0
- package/dist/either/future/error.mjs +21 -0
- package/dist/either/future/success.cjs +21 -0
- package/dist/either/future/success.mjs +21 -0
- package/dist/either/hasInformation.cjs +6 -1
- package/dist/either/hasInformation.d.ts +1 -0
- package/dist/either/hasInformation.mjs +6 -1
- package/dist/either/kind.cjs +24 -0
- package/dist/either/kind.mjs +24 -0
- package/dist/either/left/when.cjs +25 -0
- package/dist/either/left/when.mjs +25 -0
- package/dist/either/nullable/empty.cjs +22 -1
- package/dist/either/nullable/empty.mjs +22 -1
- package/dist/either/nullable/filled.cjs +23 -2
- package/dist/either/nullable/filled.mjs +23 -2
- package/dist/either/nullish/empty.cjs +22 -1
- package/dist/either/nullish/empty.mjs +22 -1
- package/dist/either/nullish/filled.cjs +23 -2
- package/dist/either/nullish/filled.mjs +23 -2
- package/dist/either/optional/empty.cjs +21 -0
- package/dist/either/optional/empty.mjs +21 -0
- package/dist/either/optional/filled.cjs +23 -2
- package/dist/either/optional/filled.mjs +23 -2
- package/dist/either/right/asyncPipe.cjs +25 -1
- package/dist/either/right/asyncPipe.d.ts +5 -0
- package/dist/either/right/asyncPipe.mjs +25 -1
- package/dist/either/right/pipe.cjs +25 -1
- package/dist/either/right/pipe.d.ts +5 -0
- package/dist/either/right/pipe.mjs +25 -1
- package/dist/either/right/when.cjs +25 -0
- package/dist/either/right/when.mjs +25 -0
- package/dist/either/whenHasInformation.cjs +25 -1
- package/dist/either/whenHasInformation.d.ts +2 -2
- package/dist/either/whenHasInformation.mjs +25 -1
- package/dist/generator/asyncReduce.cjs +25 -0
- package/dist/generator/asyncReduce.mjs +25 -0
- package/dist/generator/reduce.cjs +25 -0
- package/dist/generator/reduce.mjs +25 -0
- package/dist/index.cjs +9 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +6 -0
- package/dist/number/between.cjs +12 -0
- package/dist/number/between.d.ts +2 -0
- package/dist/number/between.mjs +10 -0
- package/dist/number/betweenThan.cjs +12 -0
- package/dist/number/betweenThan.d.ts +2 -0
- package/dist/number/betweenThan.mjs +10 -0
- package/dist/number/index.cjs +4 -0
- package/dist/number/index.d.ts +3 -0
- package/dist/number/index.mjs +2 -0
- package/dist/number/types/index.d.ts +1 -0
- package/dist/number/types/positiveNumber.d.ts +1 -0
- package/dist/object/deepDiscriminate.cjs +25 -0
- package/dist/object/deepDiscriminate.mjs +25 -0
- package/dist/object/discriminate.cjs +25 -0
- package/dist/object/discriminate.mjs +25 -0
- package/dist/object/entries.cjs +25 -0
- package/dist/object/entries.mjs +25 -0
- package/dist/object/entry.d.ts +2 -2
- package/dist/object/fromEntries.d.ts +5 -3
- package/dist/object/keys.cjs +25 -0
- package/dist/object/keys.mjs +25 -0
- package/dist/object/values.cjs +25 -0
- package/dist/object/values.mjs +25 -0
- package/dist/pattern/exhaustive.cjs +25 -0
- package/dist/pattern/exhaustive.mjs +25 -0
- package/dist/pattern/index.cjs +5 -2
- package/dist/pattern/index.mjs +2 -1
- package/dist/pattern/match/builder.cjs +82 -0
- package/dist/pattern/match/builder.d.ts +30 -0
- package/dist/pattern/match/builder.mjs +79 -0
- package/dist/pattern/match/index.cjs +28 -0
- package/dist/pattern/{match.d.ts → match/index.d.ts} +7 -4
- package/dist/pattern/match/index.mjs +25 -0
- package/dist/pattern/otherwise.cjs +25 -0
- package/dist/pattern/otherwise.mjs +25 -0
- package/dist/pattern/result.cjs +25 -0
- package/dist/pattern/result.mjs +25 -0
- package/dist/pattern/types/complexUnMatchedValue/array.d.ts +1 -1
- package/dist/string/replace.cjs +15 -0
- package/dist/string/replace.d.ts +10 -2
- package/dist/string/replace.mjs +15 -0
- package/package.json +6 -1
- package/dist/pattern/match.cjs +0 -18
- package/dist/pattern/match.mjs +0 -16
package/dist/object/values.mjs
CHANGED
|
@@ -1,7 +1,32 @@
|
|
|
1
1
|
import { isRuntimeKind } from '../common/kind.mjs';
|
|
2
|
+
import '../common/stringToBytes.mjs';
|
|
3
|
+
import '../common/stringToMillisecond.mjs';
|
|
2
4
|
import { isRuntimeWrappedValueKey } from '../common/wrapValue.mjs';
|
|
3
5
|
import '../common/globalStore.mjs';
|
|
4
6
|
import '../common/builder.mjs';
|
|
7
|
+
import '../either/bool/falsy.mjs';
|
|
8
|
+
import '../either/bool/truthy.mjs';
|
|
9
|
+
import '../either/bool/base.mjs';
|
|
10
|
+
import '../either/left/create.mjs';
|
|
11
|
+
import '../either/left/error.mjs';
|
|
12
|
+
import '../either/left/fail.mjs';
|
|
13
|
+
import '../either/kind.mjs';
|
|
14
|
+
import '../either/right/success.mjs';
|
|
15
|
+
import '../either/right/create.mjs';
|
|
16
|
+
import '../either/right/ok.mjs';
|
|
17
|
+
import '../either/future/success.mjs';
|
|
18
|
+
import '../either/future/error.mjs';
|
|
19
|
+
import '../either/future/base.mjs';
|
|
20
|
+
import '../either/nullable/empty.mjs';
|
|
21
|
+
import '../either/nullable/filled.mjs';
|
|
22
|
+
import '../either/nullable/base.mjs';
|
|
23
|
+
import '../either/nullish/empty.mjs';
|
|
24
|
+
import '../either/nullish/filled.mjs';
|
|
25
|
+
import '../either/nullish/base.mjs';
|
|
26
|
+
import '../either/optional/empty.mjs';
|
|
27
|
+
import '../either/optional/filled.mjs';
|
|
28
|
+
import '../either/optional/base.mjs';
|
|
29
|
+
import '../common/override.mjs';
|
|
5
30
|
|
|
6
31
|
function values(object) {
|
|
7
32
|
return Object.entries(object)
|
|
@@ -1,8 +1,33 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
require('../common/stringToBytes.cjs');
|
|
4
|
+
require('../common/stringToMillisecond.cjs');
|
|
3
5
|
var unwrap = require('../common/unwrap.cjs');
|
|
4
6
|
require('../common/globalStore.cjs');
|
|
5
7
|
require('../common/builder.cjs');
|
|
8
|
+
require('../either/bool/falsy.cjs');
|
|
9
|
+
require('../either/bool/truthy.cjs');
|
|
10
|
+
require('../either/bool/base.cjs');
|
|
11
|
+
require('../either/left/create.cjs');
|
|
12
|
+
require('../either/left/error.cjs');
|
|
13
|
+
require('../either/left/fail.cjs');
|
|
14
|
+
require('../either/kind.cjs');
|
|
15
|
+
require('../either/right/success.cjs');
|
|
16
|
+
require('../either/right/create.cjs');
|
|
17
|
+
require('../either/right/ok.cjs');
|
|
18
|
+
require('../either/future/success.cjs');
|
|
19
|
+
require('../either/future/error.cjs');
|
|
20
|
+
require('../either/future/base.cjs');
|
|
21
|
+
require('../either/nullable/empty.cjs');
|
|
22
|
+
require('../either/nullable/filled.cjs');
|
|
23
|
+
require('../either/nullable/base.cjs');
|
|
24
|
+
require('../either/nullish/empty.cjs');
|
|
25
|
+
require('../either/nullish/filled.cjs');
|
|
26
|
+
require('../either/nullish/base.cjs');
|
|
27
|
+
require('../either/optional/empty.cjs');
|
|
28
|
+
require('../either/optional/filled.cjs');
|
|
29
|
+
require('../either/optional/base.cjs');
|
|
30
|
+
require('../common/override.cjs');
|
|
6
31
|
|
|
7
32
|
function exhaustive(result) {
|
|
8
33
|
return unwrap.unwrap(result);
|
|
@@ -1,6 +1,31 @@
|
|
|
1
|
+
import '../common/stringToBytes.mjs';
|
|
2
|
+
import '../common/stringToMillisecond.mjs';
|
|
1
3
|
import { unwrap } from '../common/unwrap.mjs';
|
|
2
4
|
import '../common/globalStore.mjs';
|
|
3
5
|
import '../common/builder.mjs';
|
|
6
|
+
import '../either/bool/falsy.mjs';
|
|
7
|
+
import '../either/bool/truthy.mjs';
|
|
8
|
+
import '../either/bool/base.mjs';
|
|
9
|
+
import '../either/left/create.mjs';
|
|
10
|
+
import '../either/left/error.mjs';
|
|
11
|
+
import '../either/left/fail.mjs';
|
|
12
|
+
import '../either/kind.mjs';
|
|
13
|
+
import '../either/right/success.mjs';
|
|
14
|
+
import '../either/right/create.mjs';
|
|
15
|
+
import '../either/right/ok.mjs';
|
|
16
|
+
import '../either/future/success.mjs';
|
|
17
|
+
import '../either/future/error.mjs';
|
|
18
|
+
import '../either/future/base.mjs';
|
|
19
|
+
import '../either/nullable/empty.mjs';
|
|
20
|
+
import '../either/nullable/filled.mjs';
|
|
21
|
+
import '../either/nullable/base.mjs';
|
|
22
|
+
import '../either/nullish/empty.mjs';
|
|
23
|
+
import '../either/nullish/filled.mjs';
|
|
24
|
+
import '../either/nullish/base.mjs';
|
|
25
|
+
import '../either/optional/empty.mjs';
|
|
26
|
+
import '../either/optional/filled.mjs';
|
|
27
|
+
import '../either/optional/base.mjs';
|
|
28
|
+
import '../common/override.mjs';
|
|
4
29
|
|
|
5
30
|
function exhaustive(result) {
|
|
6
31
|
return unwrap(result);
|
package/dist/pattern/index.cjs
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
var result = require('./result.cjs');
|
|
4
4
|
var exhaustive = require('./exhaustive.cjs');
|
|
5
5
|
var otherwise = require('./otherwise.cjs');
|
|
6
|
-
var
|
|
6
|
+
var index = require('./match/index.cjs');
|
|
7
7
|
var isMatch = require('./isMatch.cjs');
|
|
8
8
|
var pattern = require('./types/pattern.cjs');
|
|
9
9
|
var union = require('./union.cjs');
|
|
10
10
|
var when = require('./when.cjs');
|
|
11
|
+
var builder = require('./match/builder.cjs');
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
|
|
@@ -15,8 +16,10 @@ exports.isResult = result.isResult;
|
|
|
15
16
|
exports.result = result.result;
|
|
16
17
|
exports.exhaustive = exhaustive.exhaustive;
|
|
17
18
|
exports.otherwise = otherwise.otherwise;
|
|
18
|
-
exports.match =
|
|
19
|
+
exports.match = index.match;
|
|
19
20
|
exports.isMatch = isMatch.isMatch;
|
|
20
21
|
exports.SymbolToolPatternFunctionLabel = pattern.SymbolToolPatternFunctionLabel;
|
|
21
22
|
exports.union = union.union;
|
|
22
23
|
exports.when = when.when;
|
|
24
|
+
exports.InvalidExhaustivePatternError = builder.InvalidExhaustivePatternError;
|
|
25
|
+
exports.matchBuilder = builder.matchBuilder;
|
package/dist/pattern/index.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export { isResult, result } from './result.mjs';
|
|
2
2
|
export { exhaustive } from './exhaustive.mjs';
|
|
3
3
|
export { otherwise } from './otherwise.mjs';
|
|
4
|
-
export { match } from './match.mjs';
|
|
4
|
+
export { match } from './match/index.mjs';
|
|
5
5
|
export { isMatch } from './isMatch.mjs';
|
|
6
6
|
export { SymbolToolPatternFunctionLabel } from './types/pattern.mjs';
|
|
7
7
|
export { union } from './union.mjs';
|
|
8
8
|
export { when } from './when.mjs';
|
|
9
|
+
export { InvalidExhaustivePatternError, matchBuilder } from './match/builder.mjs';
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var kind = require('../../common/kind.cjs');
|
|
4
|
+
require('../../common/stringToBytes.cjs');
|
|
5
|
+
require('../../common/stringToMillisecond.cjs');
|
|
6
|
+
require('../../common/globalStore.cjs');
|
|
7
|
+
var builder = require('../../common/builder.cjs');
|
|
8
|
+
require('../../either/bool/falsy.cjs');
|
|
9
|
+
require('../../either/bool/truthy.cjs');
|
|
10
|
+
require('../../either/bool/base.cjs');
|
|
11
|
+
require('../../either/left/create.cjs');
|
|
12
|
+
require('../../either/left/error.cjs');
|
|
13
|
+
require('../../either/left/fail.cjs');
|
|
14
|
+
require('../../either/kind.cjs');
|
|
15
|
+
require('../../either/right/success.cjs');
|
|
16
|
+
require('../../either/right/create.cjs');
|
|
17
|
+
require('../../either/right/ok.cjs');
|
|
18
|
+
require('../../either/future/success.cjs');
|
|
19
|
+
require('../../either/future/error.cjs');
|
|
20
|
+
require('../../either/future/base.cjs');
|
|
21
|
+
require('../../either/nullable/empty.cjs');
|
|
22
|
+
require('../../either/nullable/filled.cjs');
|
|
23
|
+
require('../../either/nullable/base.cjs');
|
|
24
|
+
require('../../either/nullish/empty.cjs');
|
|
25
|
+
require('../../either/nullish/filled.cjs');
|
|
26
|
+
require('../../either/nullish/base.cjs');
|
|
27
|
+
require('../../either/optional/empty.cjs');
|
|
28
|
+
require('../../either/optional/filled.cjs');
|
|
29
|
+
require('../../either/optional/base.cjs');
|
|
30
|
+
require('../../common/override.cjs');
|
|
31
|
+
var errorKindNamespace = require('../../common/errorKindNamespace.cjs');
|
|
32
|
+
var isMatch = require('../isMatch.cjs');
|
|
33
|
+
|
|
34
|
+
class InvalidExhaustivePatternError extends kind.kindHeritage("invalid-exhaustive-pattern-error", errorKindNamespace.createErrorKind("invalid-exhaustive-pattern-error"), Error) {
|
|
35
|
+
input;
|
|
36
|
+
constructor(input) {
|
|
37
|
+
super({}, ["Invalid exhaustive pattern. If typing is correct, report your situation on github."]);
|
|
38
|
+
this.input = input;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const matchBuilder = builder.createBuilder("@duplojs/utils/pattern/match");
|
|
42
|
+
matchBuilder.set("with", ({ args: [pattern, theFunction], accumulator, next, }) => next({
|
|
43
|
+
...accumulator,
|
|
44
|
+
matchers: [
|
|
45
|
+
...accumulator.matchers,
|
|
46
|
+
{
|
|
47
|
+
isMatch: isMatch.isMatch(pattern),
|
|
48
|
+
theFunction,
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
}));
|
|
52
|
+
matchBuilder.set("when", ({ args: [predicate, theFunction], accumulator, next, }) => next({
|
|
53
|
+
...accumulator,
|
|
54
|
+
matchers: [
|
|
55
|
+
...accumulator.matchers,
|
|
56
|
+
{
|
|
57
|
+
isMatch: predicate,
|
|
58
|
+
theFunction,
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
}));
|
|
62
|
+
matchBuilder.set("exhaustive", ({ accumulator: { input, matchers, }, }) => {
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
64
|
+
for (let index = 0; index < matchers.length; index++) {
|
|
65
|
+
if (matchers[index].isMatch(input)) {
|
|
66
|
+
return matchers[index].theFunction(input);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
throw new InvalidExhaustivePatternError(input);
|
|
70
|
+
});
|
|
71
|
+
matchBuilder.set("otherwise", ({ args: [theFunction], accumulator: { input, matchers, }, }) => {
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
73
|
+
for (let index = 0; index < matchers.length; index++) {
|
|
74
|
+
if (matchers[index].isMatch(input)) {
|
|
75
|
+
return matchers[index].theFunction(input);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return theFunction(input);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
exports.InvalidExhaustivePatternError = InvalidExhaustivePatternError;
|
|
82
|
+
exports.matchBuilder = matchBuilder;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type Builder, type FixDeepFunctionInfer, type IsEqual } from "../../common";
|
|
2
|
+
import { type ComplexMatchedValue, type ComplexUnMatchedValue, type Pattern, type PatternValue } from "../types";
|
|
3
|
+
export interface BuilderMatcher {
|
|
4
|
+
isMatch(value: unknown): boolean;
|
|
5
|
+
theFunction(value: unknown): unknown;
|
|
6
|
+
}
|
|
7
|
+
export interface MatchBuilderDefinition {
|
|
8
|
+
input: unknown;
|
|
9
|
+
matchers: BuilderMatcher[];
|
|
10
|
+
}
|
|
11
|
+
declare const SymbolErrorMatchExhaustive: unique symbol;
|
|
12
|
+
export interface MatchBuilder<GenericValue extends unknown = never, GenericResult extends unknown = never> extends Builder<MatchBuilderDefinition> {
|
|
13
|
+
with<const GenericPattern extends Pattern<GenericValue>, GenericOutput extends unknown>(pattern: FixDeepFunctionInfer<Pattern<GenericValue>, GenericPattern>, theFunction: (value: ComplexMatchedValue<GenericValue, PatternValue<GenericPattern>>) => GenericOutput): MatchBuilder<ComplexUnMatchedValue<GenericValue, PatternValue<GenericPattern>>, GenericOutput | GenericResult>;
|
|
14
|
+
when<GenericPredicatedInput extends GenericValue, GenericOutput extends unknown>(predicate: (input: GenericValue) => input is GenericPredicatedInput, theFunction: (predicatedInput: GenericPredicatedInput) => GenericOutput): MatchBuilder<Exclude<GenericValue, GenericPredicatedInput>, GenericOutput | GenericResult>;
|
|
15
|
+
when<GenericOutput extends unknown>(predicate: (input: GenericValue) => boolean, theFunction: (predicatedInput: GenericValue) => GenericOutput): MatchBuilder<GenericValue, GenericOutput | GenericResult>;
|
|
16
|
+
exhaustive: IsEqual<GenericValue, never> extends true ? () => GenericResult : {
|
|
17
|
+
[SymbolErrorMatchExhaustive]: "Pattern are not exhaustive.";
|
|
18
|
+
restValue: GenericValue;
|
|
19
|
+
};
|
|
20
|
+
otherwise<GenericOtherwiseResult extends unknown>(theFunction: (value: GenericValue) => GenericOtherwiseResult): GenericResult | GenericOtherwiseResult;
|
|
21
|
+
}
|
|
22
|
+
declare const InvalidExhaustivePatternError_base: new (params: {
|
|
23
|
+
"@DuplojsUtilsError/invalid-exhaustive-pattern-error"?: unknown;
|
|
24
|
+
}, parentParams: [message?: string | undefined, options?: ErrorOptions | undefined]) => Error & import("../../common").Kind<import("../../common").KindDefinition<"invalid-exhaustive-pattern-error", unknown>, unknown> & import("../../common").Kind<import("../../common").KindDefinition<"@DuplojsUtilsError/invalid-exhaustive-pattern-error", unknown>, unknown>;
|
|
25
|
+
export declare class InvalidExhaustivePatternError extends InvalidExhaustivePatternError_base {
|
|
26
|
+
input: unknown;
|
|
27
|
+
constructor(input: unknown);
|
|
28
|
+
}
|
|
29
|
+
export declare const matchBuilder: import("../../common").BuilderHandler<MatchBuilder<unknown, unknown> & Pick<MatchBuilder<never, unknown>, "exhaustive">>;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { kindHeritage } from '../../common/kind.mjs';
|
|
2
|
+
import '../../common/stringToBytes.mjs';
|
|
3
|
+
import '../../common/stringToMillisecond.mjs';
|
|
4
|
+
import '../../common/globalStore.mjs';
|
|
5
|
+
import { createBuilder } from '../../common/builder.mjs';
|
|
6
|
+
import '../../either/bool/falsy.mjs';
|
|
7
|
+
import '../../either/bool/truthy.mjs';
|
|
8
|
+
import '../../either/bool/base.mjs';
|
|
9
|
+
import '../../either/left/create.mjs';
|
|
10
|
+
import '../../either/left/error.mjs';
|
|
11
|
+
import '../../either/left/fail.mjs';
|
|
12
|
+
import '../../either/kind.mjs';
|
|
13
|
+
import '../../either/right/success.mjs';
|
|
14
|
+
import '../../either/right/create.mjs';
|
|
15
|
+
import '../../either/right/ok.mjs';
|
|
16
|
+
import '../../either/future/success.mjs';
|
|
17
|
+
import '../../either/future/error.mjs';
|
|
18
|
+
import '../../either/future/base.mjs';
|
|
19
|
+
import '../../either/nullable/empty.mjs';
|
|
20
|
+
import '../../either/nullable/filled.mjs';
|
|
21
|
+
import '../../either/nullable/base.mjs';
|
|
22
|
+
import '../../either/nullish/empty.mjs';
|
|
23
|
+
import '../../either/nullish/filled.mjs';
|
|
24
|
+
import '../../either/nullish/base.mjs';
|
|
25
|
+
import '../../either/optional/empty.mjs';
|
|
26
|
+
import '../../either/optional/filled.mjs';
|
|
27
|
+
import '../../either/optional/base.mjs';
|
|
28
|
+
import '../../common/override.mjs';
|
|
29
|
+
import { createErrorKind } from '../../common/errorKindNamespace.mjs';
|
|
30
|
+
import { isMatch } from '../isMatch.mjs';
|
|
31
|
+
|
|
32
|
+
class InvalidExhaustivePatternError extends kindHeritage("invalid-exhaustive-pattern-error", createErrorKind("invalid-exhaustive-pattern-error"), Error) {
|
|
33
|
+
input;
|
|
34
|
+
constructor(input) {
|
|
35
|
+
super({}, ["Invalid exhaustive pattern. If typing is correct, report your situation on github."]);
|
|
36
|
+
this.input = input;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const matchBuilder = createBuilder("@duplojs/utils/pattern/match");
|
|
40
|
+
matchBuilder.set("with", ({ args: [pattern, theFunction], accumulator, next, }) => next({
|
|
41
|
+
...accumulator,
|
|
42
|
+
matchers: [
|
|
43
|
+
...accumulator.matchers,
|
|
44
|
+
{
|
|
45
|
+
isMatch: isMatch(pattern),
|
|
46
|
+
theFunction,
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
}));
|
|
50
|
+
matchBuilder.set("when", ({ args: [predicate, theFunction], accumulator, next, }) => next({
|
|
51
|
+
...accumulator,
|
|
52
|
+
matchers: [
|
|
53
|
+
...accumulator.matchers,
|
|
54
|
+
{
|
|
55
|
+
isMatch: predicate,
|
|
56
|
+
theFunction,
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
}));
|
|
60
|
+
matchBuilder.set("exhaustive", ({ accumulator: { input, matchers, }, }) => {
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
62
|
+
for (let index = 0; index < matchers.length; index++) {
|
|
63
|
+
if (matchers[index].isMatch(input)) {
|
|
64
|
+
return matchers[index].theFunction(input);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
throw new InvalidExhaustivePatternError(input);
|
|
68
|
+
});
|
|
69
|
+
matchBuilder.set("otherwise", ({ args: [theFunction], accumulator: { input, matchers, }, }) => {
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
71
|
+
for (let index = 0; index < matchers.length; index++) {
|
|
72
|
+
if (matchers[index].isMatch(input)) {
|
|
73
|
+
return matchers[index].theFunction(input);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return theFunction(input);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
export { InvalidExhaustivePatternError, matchBuilder };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var result = require('../result.cjs');
|
|
4
|
+
var isMatch = require('../isMatch.cjs');
|
|
5
|
+
var builder = require('./builder.cjs');
|
|
6
|
+
|
|
7
|
+
function match(...args) {
|
|
8
|
+
if (args.length === 1) {
|
|
9
|
+
const [input] = args;
|
|
10
|
+
return builder.matchBuilder.use({
|
|
11
|
+
input,
|
|
12
|
+
matchers: [],
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
if (args.length === 2) {
|
|
16
|
+
const [pattern, theFunction] = args;
|
|
17
|
+
return (input) => match(input, pattern, theFunction);
|
|
18
|
+
}
|
|
19
|
+
const [input, pattern, theFunction] = args;
|
|
20
|
+
if (!result.isResult(input) && isMatch.isMatch(input, pattern)) {
|
|
21
|
+
return result.result(theFunction(input));
|
|
22
|
+
}
|
|
23
|
+
return input;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
exports.InvalidExhaustivePatternError = builder.InvalidExhaustivePatternError;
|
|
27
|
+
exports.matchBuilder = builder.matchBuilder;
|
|
28
|
+
exports.match = match;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { type IsEqual, type AnyValue, type EscapeVoid, type FixDeepFunctionInfer, type BreakGenericLink } from "
|
|
2
|
-
import { type PatternValue, type Pattern } from "
|
|
3
|
-
import { type PatternResult } from "
|
|
4
|
-
import { type ComplexMatchedValue, type ComplexUnMatchedValue } from "
|
|
1
|
+
import { type IsEqual, type AnyValue, type EscapeVoid, type FixDeepFunctionInfer, type BreakGenericLink } from "../../common";
|
|
2
|
+
import { type PatternValue, type Pattern } from "../types/pattern";
|
|
3
|
+
import { type PatternResult } from "../result";
|
|
4
|
+
import { type ComplexMatchedValue, type ComplexUnMatchedValue } from "../types";
|
|
5
|
+
import { type MatchBuilder } from "./builder";
|
|
6
|
+
export * from "./builder";
|
|
7
|
+
export declare function match<GenericInput extends AnyValue>(input: GenericInput): MatchBuilder<GenericInput>;
|
|
5
8
|
export declare function match<GenericInput extends AnyValue, GenericInputValue extends Exclude<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) => ((IsEqual<GenericMatchedValue, never> extends true ? never : PatternResult<GenericOutput>) | GenericInputPatternResult | (Extract<ComplexUnMatchedValue<GenericInputValue, GenericPatternValue>, any> extends infer InferredResult ? BreakGenericLink<InferredResult> : never));
|
|
6
9
|
export declare function match<GenericInput extends AnyValue, GenericInputValue extends Exclude<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): ((IsEqual<GenericMatchedValue, never> extends true ? never : PatternResult<GenericOutput>) | GenericInputPatternResult | Extract<ComplexUnMatchedValue<GenericInputValue, GenericPatternValue>, any>);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { isResult, result } from '../result.mjs';
|
|
2
|
+
import { isMatch } from '../isMatch.mjs';
|
|
3
|
+
import { matchBuilder } from './builder.mjs';
|
|
4
|
+
export { InvalidExhaustivePatternError } from './builder.mjs';
|
|
5
|
+
|
|
6
|
+
function match(...args) {
|
|
7
|
+
if (args.length === 1) {
|
|
8
|
+
const [input] = args;
|
|
9
|
+
return matchBuilder.use({
|
|
10
|
+
input,
|
|
11
|
+
matchers: [],
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
if (args.length === 2) {
|
|
15
|
+
const [pattern, theFunction] = args;
|
|
16
|
+
return (input) => match(input, pattern, theFunction);
|
|
17
|
+
}
|
|
18
|
+
const [input, pattern, theFunction] = args;
|
|
19
|
+
if (!isResult(input) && isMatch(input, pattern)) {
|
|
20
|
+
return result(theFunction(input));
|
|
21
|
+
}
|
|
22
|
+
return input;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { match, matchBuilder };
|
|
@@ -1,8 +1,33 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
require('../common/stringToBytes.cjs');
|
|
4
|
+
require('../common/stringToMillisecond.cjs');
|
|
3
5
|
var unwrap = require('../common/unwrap.cjs');
|
|
4
6
|
require('../common/globalStore.cjs');
|
|
5
7
|
require('../common/builder.cjs');
|
|
8
|
+
require('../either/bool/falsy.cjs');
|
|
9
|
+
require('../either/bool/truthy.cjs');
|
|
10
|
+
require('../either/bool/base.cjs');
|
|
11
|
+
require('../either/left/create.cjs');
|
|
12
|
+
require('../either/left/error.cjs');
|
|
13
|
+
require('../either/left/fail.cjs');
|
|
14
|
+
require('../either/kind.cjs');
|
|
15
|
+
require('../either/right/success.cjs');
|
|
16
|
+
require('../either/right/create.cjs');
|
|
17
|
+
require('../either/right/ok.cjs');
|
|
18
|
+
require('../either/future/success.cjs');
|
|
19
|
+
require('../either/future/error.cjs');
|
|
20
|
+
require('../either/future/base.cjs');
|
|
21
|
+
require('../either/nullable/empty.cjs');
|
|
22
|
+
require('../either/nullable/filled.cjs');
|
|
23
|
+
require('../either/nullable/base.cjs');
|
|
24
|
+
require('../either/nullish/empty.cjs');
|
|
25
|
+
require('../either/nullish/filled.cjs');
|
|
26
|
+
require('../either/nullish/base.cjs');
|
|
27
|
+
require('../either/optional/empty.cjs');
|
|
28
|
+
require('../either/optional/filled.cjs');
|
|
29
|
+
require('../either/optional/base.cjs');
|
|
30
|
+
require('../common/override.cjs');
|
|
6
31
|
var result = require('./result.cjs');
|
|
7
32
|
|
|
8
33
|
function otherwise(...args) {
|
|
@@ -1,6 +1,31 @@
|
|
|
1
|
+
import '../common/stringToBytes.mjs';
|
|
2
|
+
import '../common/stringToMillisecond.mjs';
|
|
1
3
|
import { unwrap } from '../common/unwrap.mjs';
|
|
2
4
|
import '../common/globalStore.mjs';
|
|
3
5
|
import '../common/builder.mjs';
|
|
6
|
+
import '../either/bool/falsy.mjs';
|
|
7
|
+
import '../either/bool/truthy.mjs';
|
|
8
|
+
import '../either/bool/base.mjs';
|
|
9
|
+
import '../either/left/create.mjs';
|
|
10
|
+
import '../either/left/error.mjs';
|
|
11
|
+
import '../either/left/fail.mjs';
|
|
12
|
+
import '../either/kind.mjs';
|
|
13
|
+
import '../either/right/success.mjs';
|
|
14
|
+
import '../either/right/create.mjs';
|
|
15
|
+
import '../either/right/ok.mjs';
|
|
16
|
+
import '../either/future/success.mjs';
|
|
17
|
+
import '../either/future/error.mjs';
|
|
18
|
+
import '../either/future/base.mjs';
|
|
19
|
+
import '../either/nullable/empty.mjs';
|
|
20
|
+
import '../either/nullable/filled.mjs';
|
|
21
|
+
import '../either/nullable/base.mjs';
|
|
22
|
+
import '../either/nullish/empty.mjs';
|
|
23
|
+
import '../either/nullish/filled.mjs';
|
|
24
|
+
import '../either/nullish/base.mjs';
|
|
25
|
+
import '../either/optional/empty.mjs';
|
|
26
|
+
import '../either/optional/filled.mjs';
|
|
27
|
+
import '../either/optional/base.mjs';
|
|
28
|
+
import '../common/override.mjs';
|
|
4
29
|
import { isResult } from './result.mjs';
|
|
5
30
|
|
|
6
31
|
function otherwise(...args) {
|
package/dist/pattern/result.cjs
CHANGED
|
@@ -1,9 +1,34 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var kind = require('../common/kind.cjs');
|
|
4
|
+
require('../common/stringToBytes.cjs');
|
|
5
|
+
require('../common/stringToMillisecond.cjs');
|
|
4
6
|
var wrapValue = require('../common/wrapValue.cjs');
|
|
5
7
|
require('../common/globalStore.cjs');
|
|
6
8
|
require('../common/builder.cjs');
|
|
9
|
+
require('../either/bool/falsy.cjs');
|
|
10
|
+
require('../either/bool/truthy.cjs');
|
|
11
|
+
require('../either/bool/base.cjs');
|
|
12
|
+
require('../either/left/create.cjs');
|
|
13
|
+
require('../either/left/error.cjs');
|
|
14
|
+
require('../either/left/fail.cjs');
|
|
15
|
+
require('../either/kind.cjs');
|
|
16
|
+
require('../either/right/success.cjs');
|
|
17
|
+
require('../either/right/create.cjs');
|
|
18
|
+
require('../either/right/ok.cjs');
|
|
19
|
+
require('../either/future/success.cjs');
|
|
20
|
+
require('../either/future/error.cjs');
|
|
21
|
+
require('../either/future/base.cjs');
|
|
22
|
+
require('../either/nullable/empty.cjs');
|
|
23
|
+
require('../either/nullable/filled.cjs');
|
|
24
|
+
require('../either/nullable/base.cjs');
|
|
25
|
+
require('../either/nullish/empty.cjs');
|
|
26
|
+
require('../either/nullish/filled.cjs');
|
|
27
|
+
require('../either/nullish/base.cjs');
|
|
28
|
+
require('../either/optional/empty.cjs');
|
|
29
|
+
require('../either/optional/filled.cjs');
|
|
30
|
+
require('../either/optional/base.cjs');
|
|
31
|
+
require('../common/override.cjs');
|
|
7
32
|
|
|
8
33
|
const patternResultKind = kind.createKind("pattern-result");
|
|
9
34
|
function result(value) {
|
package/dist/pattern/result.mjs
CHANGED
|
@@ -1,7 +1,32 @@
|
|
|
1
1
|
import { createKind } from '../common/kind.mjs';
|
|
2
|
+
import '../common/stringToBytes.mjs';
|
|
3
|
+
import '../common/stringToMillisecond.mjs';
|
|
2
4
|
import { wrapValue } from '../common/wrapValue.mjs';
|
|
3
5
|
import '../common/globalStore.mjs';
|
|
4
6
|
import '../common/builder.mjs';
|
|
7
|
+
import '../either/bool/falsy.mjs';
|
|
8
|
+
import '../either/bool/truthy.mjs';
|
|
9
|
+
import '../either/bool/base.mjs';
|
|
10
|
+
import '../either/left/create.mjs';
|
|
11
|
+
import '../either/left/error.mjs';
|
|
12
|
+
import '../either/left/fail.mjs';
|
|
13
|
+
import '../either/kind.mjs';
|
|
14
|
+
import '../either/right/success.mjs';
|
|
15
|
+
import '../either/right/create.mjs';
|
|
16
|
+
import '../either/right/ok.mjs';
|
|
17
|
+
import '../either/future/success.mjs';
|
|
18
|
+
import '../either/future/error.mjs';
|
|
19
|
+
import '../either/future/base.mjs';
|
|
20
|
+
import '../either/nullable/empty.mjs';
|
|
21
|
+
import '../either/nullable/filled.mjs';
|
|
22
|
+
import '../either/nullable/base.mjs';
|
|
23
|
+
import '../either/nullish/empty.mjs';
|
|
24
|
+
import '../either/nullish/filled.mjs';
|
|
25
|
+
import '../either/nullish/base.mjs';
|
|
26
|
+
import '../either/optional/empty.mjs';
|
|
27
|
+
import '../either/optional/filled.mjs';
|
|
28
|
+
import '../either/optional/base.mjs';
|
|
29
|
+
import '../common/override.mjs';
|
|
5
30
|
|
|
6
31
|
const patternResultKind = createKind("pattern-result");
|
|
7
32
|
function result(value) {
|
|
@@ -19,7 +19,7 @@ type ComplexUnMatchedTupleTuple<GenericInput extends unknown, GenericPatternValu
|
|
|
19
19
|
] extends [
|
|
20
20
|
readonly [infer InferredInputFirst, ...infer InferredInputRest],
|
|
21
21
|
readonly [infer InferredPatternValueFirst, ...infer InferredPatternValueRest]
|
|
22
|
-
] ? Extract<ComplexUnMatchedValue<InferredInputFirst, InferredPatternValueFirst>, any> extends infer InferredResultFirst ? InferredPatternValueRest extends readonly [] ? IsEqual<InferredResultFirst, never> extends true ? never : [InferredResultFirst, ...InferredInputRest] : ComplexUnMatchedValue<InferredInputRest, InferredPatternValueRest> extends infer InferredResultRest ? [
|
|
22
|
+
] ? Extract<ComplexUnMatchedValue<InferredInputFirst, InferredPatternValueFirst>, any> extends infer InferredResultFirst ? InferredPatternValueRest extends readonly [] ? IsEqual<InferredResultFirst, never> extends true ? never : [InferredResultFirst, ...InferredInputRest] : ComplexUnMatchedValue<InferredInputRest, InferredPatternValueRest> extends infer InferredResultRest ? IsEqual<InferredResultRest, never> extends true ? never : [
|
|
23
23
|
IsEqual<InferredResultFirst, never> extends true ? InferredInputFirst : InferredResultFirst,
|
|
24
24
|
...Adaptor<IsEqual<InferredResultRest, never> extends true ? InferredPatternValueRest : InferredResultRest, readonly any[]>
|
|
25
25
|
] : never : never : never : never);
|
package/dist/string/replace.cjs
CHANGED
|
@@ -6,6 +6,21 @@ function replace(...args) {
|
|
|
6
6
|
return (input) => replace(input, pattern, replacement);
|
|
7
7
|
}
|
|
8
8
|
const [input, pattern, replacement] = args;
|
|
9
|
+
if (typeof replacement === "function") {
|
|
10
|
+
return input.replace(pattern, (matchedValue, ...argsRest) => {
|
|
11
|
+
const namedGroups = typeof argsRest[argsRest.length - 1] === "object"
|
|
12
|
+
? argsRest.pop()
|
|
13
|
+
: undefined;
|
|
14
|
+
const [offset, self] = argsRest.splice(-2, 2);
|
|
15
|
+
return replacement({
|
|
16
|
+
matchedValue,
|
|
17
|
+
namedGroups,
|
|
18
|
+
offset,
|
|
19
|
+
self,
|
|
20
|
+
groups: argsRest,
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
}
|
|
9
24
|
return input.replace(pattern, replacement);
|
|
10
25
|
}
|
|
11
26
|
|
package/dist/string/replace.d.ts
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
1
|
+
export interface StringReplacerParams {
|
|
2
|
+
matchedValue: string;
|
|
3
|
+
groups: string[];
|
|
4
|
+
namedGroups?: Record<string, string>;
|
|
5
|
+
offset: number;
|
|
6
|
+
self: string;
|
|
7
|
+
}
|
|
8
|
+
export type StringReplacer = (params: StringReplacerParams) => string;
|
|
9
|
+
export declare function replace<GenericInput extends string>(pattern: string | RegExp, replacement: string | StringReplacer): (input: GenericInput) => string;
|
|
10
|
+
export declare function replace<GenericInput extends string>(input: GenericInput, pattern: string | RegExp, replacement: string | StringReplacer): string;
|
package/dist/string/replace.mjs
CHANGED
|
@@ -4,6 +4,21 @@ function replace(...args) {
|
|
|
4
4
|
return (input) => replace(input, pattern, replacement);
|
|
5
5
|
}
|
|
6
6
|
const [input, pattern, replacement] = args;
|
|
7
|
+
if (typeof replacement === "function") {
|
|
8
|
+
return input.replace(pattern, (matchedValue, ...argsRest) => {
|
|
9
|
+
const namedGroups = typeof argsRest[argsRest.length - 1] === "object"
|
|
10
|
+
? argsRest.pop()
|
|
11
|
+
: undefined;
|
|
12
|
+
const [offset, self] = argsRest.splice(-2, 2);
|
|
13
|
+
return replacement({
|
|
14
|
+
matchedValue,
|
|
15
|
+
namedGroups,
|
|
16
|
+
offset,
|
|
17
|
+
self,
|
|
18
|
+
groups: argsRest,
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
}
|
|
7
22
|
return input.replace(pattern, replacement);
|
|
8
23
|
}
|
|
9
24
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duplojs/utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.16",
|
|
4
4
|
"author": "mathcovax",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -80,6 +80,11 @@
|
|
|
80
80
|
"import": "./dist/string/index.mjs",
|
|
81
81
|
"require": "./dist/string/index.cjs",
|
|
82
82
|
"types": "./dist/string/index.d.ts"
|
|
83
|
+
},
|
|
84
|
+
"./date": {
|
|
85
|
+
"import": "./dist/date/index.mjs",
|
|
86
|
+
"require": "./dist/date/index.cjs",
|
|
87
|
+
"types": "./dist/date/index.d.ts"
|
|
83
88
|
}
|
|
84
89
|
},
|
|
85
90
|
"files": [
|