@pawells/typescript-common 2.0.0 → 2.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +370 -223
- package/{build → dist}/array/array-chunk.d.ts +1 -1
- package/{build → dist}/array/array-chunk.js +2 -3
- package/{build → dist}/array/array-compact.d.ts +1 -1
- package/{build → dist}/array/array-compact.js +1 -2
- package/{build → dist}/array/array-contains.d.ts +1 -1
- package/{build → dist}/array/array-contains.js +2 -3
- package/{build → dist}/array/array-count-by.d.ts +1 -1
- package/{build → dist}/array/array-count-by.js +2 -3
- package/{build → dist}/array/array-difference.d.ts +12 -5
- package/dist/array/array-difference.d.ts.map +1 -0
- package/dist/array/array-difference.js +70 -0
- package/dist/array/array-element.js +1 -0
- package/{build → dist}/array/array-filter.d.ts +1 -1
- package/{build → dist}/array/array-filter.js +1 -2
- package/{build → dist}/array/array-flatten.d.ts +2 -2
- package/{build → dist}/array/array-flatten.d.ts.map +1 -1
- package/{build → dist}/array/array-flatten.js +1 -2
- package/{build → dist}/array/array-group-by.d.ts +1 -1
- package/{build → dist}/array/array-group-by.d.ts.map +1 -1
- package/{build → dist}/array/array-group-by.js +10 -9
- package/{build → dist}/array/array-intersection.d.ts +12 -5
- package/dist/array/array-intersection.d.ts.map +1 -0
- package/dist/array/array-intersection.js +79 -0
- package/{build → dist}/array/array-partition.d.ts +1 -1
- package/{build → dist}/array/array-partition.js +2 -3
- package/{build → dist}/array/array-range.d.ts +1 -1
- package/{build → dist}/array/array-range.js +1 -2
- package/{build → dist}/array/array-sample.d.ts +2 -2
- package/{build → dist}/array/array-sample.js +3 -5
- package/{build → dist}/array/array-shuffle.d.ts +1 -1
- package/{build → dist}/array/array-shuffle.js +1 -2
- package/{build → dist}/array/array-sort-by.d.ts +1 -1
- package/{build → dist}/array/array-sort-by.js +1 -2
- package/{build → dist}/array/array-zip.d.ts +1 -1
- package/{build → dist}/array/array-zip.js +1 -2
- package/{build → dist}/array/assert.d.ts +5 -5
- package/{build → dist}/array/assert.d.ts.map +1 -1
- package/{build → dist}/array/assert.js +13 -14
- package/{build → dist}/array/index.d.ts +1 -0
- package/{build → dist}/array/index.d.ts.map +1 -1
- package/{build → dist}/array/index.js +1 -1
- package/dist/array/iterators.d.ts +40 -0
- package/dist/array/iterators.d.ts.map +1 -0
- package/dist/array/iterators.js +54 -0
- package/{build → dist}/array/types.d.ts +20 -2
- package/{build → dist}/array/types.d.ts.map +1 -1
- package/dist/array/types.js +1 -0
- package/{build → dist}/array/unique.d.ts +1 -1
- package/{build → dist}/array/unique.js +1 -2
- package/dist/asserts/errors.d.ts.map +1 -0
- package/{build → dist}/asserts/errors.js +5 -3
- package/{build → dist}/asserts/generic.d.ts +23 -3
- package/dist/asserts/generic.d.ts.map +1 -0
- package/{build → dist}/asserts/generic.js +39 -7
- package/dist/asserts/index.d.ts +47 -0
- package/dist/asserts/index.d.ts.map +1 -0
- package/dist/asserts/index.js +46 -0
- package/{build → dist}/asserts/internal-utils.d.ts.map +1 -1
- package/{build → dist}/asserts/internal-utils.js +0 -1
- package/{build → dist}/asserts/types.d.ts +56 -17
- package/dist/asserts/types.d.ts.map +1 -0
- package/dist/asserts/types.js +1 -0
- package/{build → dist}/asserts/utils.d.ts +5 -21
- package/dist/asserts/utils.d.ts.map +1 -0
- package/{build → dist}/asserts/utils.js +14 -39
- package/{build → dist}/boolean/assert.d.ts +1 -2
- package/{build → dist}/boolean/assert.d.ts.map +1 -1
- package/{build → dist}/boolean/assert.js +1 -3
- package/dist/boolean/index.d.ts +13 -0
- package/dist/boolean/index.d.ts.map +1 -0
- package/dist/boolean/index.js +12 -0
- package/{build → dist}/enum/enum-entries.d.ts +1 -1
- package/dist/enum/enum-entries.d.ts.map +1 -0
- package/{build → dist}/enum/enum-entries.js +0 -1
- package/{build → dist}/enum/enum-key-by-value.d.ts +1 -1
- package/dist/enum/enum-key-by-value.d.ts.map +1 -0
- package/{build → dist}/enum/enum-key-by-value.js +0 -1
- package/{build → dist}/enum/enum-keys.js +0 -1
- package/{build → dist}/enum/enum-safe-value.d.ts +1 -1
- package/dist/enum/enum-safe-value.d.ts.map +1 -0
- package/{build → dist}/enum/enum-safe-value.js +0 -1
- package/{build → dist}/enum/enum-values.js +0 -1
- package/{build → dist}/enum/index.d.ts +1 -1
- package/dist/enum/index.d.ts.map +1 -0
- package/{build → dist}/enum/index.js +1 -2
- package/dist/enum/types.js +1 -0
- package/{build → dist}/enum/validate-enum-value.d.ts +1 -1
- package/dist/enum/validate-enum-value.d.ts.map +1 -0
- package/{build → dist}/enum/validate-enum-value.js +0 -1
- package/{build → dist}/function/compose.d.ts +6 -0
- package/dist/function/compose.d.ts.map +1 -0
- package/{build → dist}/function/compose.js +0 -1
- package/{build → dist}/function/debounce.d.ts +6 -0
- package/dist/function/debounce.d.ts.map +1 -0
- package/{build → dist}/function/debounce.js +6 -1
- package/{build → dist}/function/index.js +0 -1
- package/dist/function/memoize.d.ts +56 -0
- package/dist/function/memoize.d.ts.map +1 -0
- package/dist/function/memoize.js +72 -0
- package/{build → dist}/function/once.d.ts.map +1 -1
- package/{build → dist}/function/once.js +1 -1
- package/{build → dist}/function/sleep.js +0 -1
- package/{build → dist}/function/throttle.d.ts +7 -0
- package/dist/function/throttle.d.ts.map +1 -0
- package/{build → dist}/function/throttle.js +7 -1
- package/dist/function/types.d.ts +18 -0
- package/dist/function/types.d.ts.map +1 -0
- package/dist/function/types.js +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/json.sanitization.d.ts +14 -0
- package/dist/json.sanitization.d.ts.map +1 -0
- package/dist/json.sanitization.js +37 -0
- package/{build → dist}/lru-cache.d.ts +19 -0
- package/dist/lru-cache.d.ts.map +1 -0
- package/{build → dist}/lru-cache.js +24 -2
- package/{build → dist}/number/assert.js +0 -1
- package/dist/number/index.d.ts +13 -0
- package/dist/number/index.d.ts.map +1 -0
- package/dist/number/index.js +12 -0
- package/{build → dist}/object/assert-object.d.ts +5 -1
- package/{build → dist}/object/assert-object.d.ts.map +1 -1
- package/{build → dist}/object/assert-object.js +4 -1
- package/{build → dist}/object/assert.d.ts +1 -1
- package/dist/object/assert.d.ts.map +1 -0
- package/{build → dist}/object/assert.js +7 -29
- package/{build → dist}/object/clone.d.ts +6 -0
- package/dist/object/clone.d.ts.map +1 -0
- package/{build → dist}/object/clone.js +14 -5
- package/{build → dist}/object/equals.d.ts.map +1 -1
- package/{build → dist}/object/equals.js +3 -7
- package/dist/object/filter-cached.d.ts +26 -0
- package/{build → dist}/object/filter-cached.d.ts.map +1 -1
- package/{build → dist}/object/filter-cached.js +27 -6
- package/{build → dist}/object/filter.d.ts.map +1 -1
- package/{build → dist}/object/filter.js +22 -6
- package/{build → dist}/object/has-circular-reference.d.ts.map +1 -1
- package/{build → dist}/object/has-circular-reference.js +4 -2
- package/{build → dist}/object/hash.d.ts +4 -0
- package/dist/object/hash.d.ts.map +1 -0
- package/{build → dist}/object/hash.js +20 -7
- package/{build → dist}/object/index.d.ts +2 -2
- package/{build → dist}/object/index.d.ts.map +1 -1
- package/{build → dist}/object/index.js +1 -2
- package/{build → dist}/object/json-circular-replacer.d.ts.map +1 -1
- package/{build → dist}/object/json-circular-replacer.js +0 -1
- package/{build → dist}/object/key-value-pairs.js +0 -1
- package/dist/object/map-cached.d.ts +31 -0
- package/dist/object/map-cached.d.ts.map +1 -0
- package/{build → dist}/object/map-cached.js +34 -6
- package/{build → dist}/object/map.js +0 -1
- package/{build → dist}/object/merge.d.ts.map +1 -1
- package/{build → dist}/object/merge.js +7 -7
- package/{build → dist}/object/object-diff.d.ts +2 -2
- package/{build → dist}/object/object-diff.d.ts.map +1 -1
- package/{build → dist}/object/object-diff.js +11 -5
- package/{build → dist}/object/object-flatten.d.ts +1 -1
- package/{build → dist}/object/object-flatten.d.ts.map +1 -1
- package/{build → dist}/object/object-flatten.js +10 -4
- package/{build → dist}/object/object-invert.js +0 -1
- package/{build → dist}/object/omit.js +0 -1
- package/{build → dist}/object/pick.js +0 -1
- package/{build → dist}/object/property-paths.d.ts +2 -0
- package/{build → dist}/object/property-paths.d.ts.map +1 -1
- package/{build → dist}/object/property-paths.js +8 -7
- package/dist/object/security-utils.d.ts +193 -0
- package/dist/object/security-utils.d.ts.map +1 -0
- package/dist/object/security-utils.js +304 -0
- package/{build → dist}/object/sort-keys.d.ts +15 -1
- package/dist/object/sort-keys.d.ts.map +1 -0
- package/dist/object/sort-keys.js +73 -0
- package/{build → dist}/object/types.d.ts +0 -61
- package/dist/object/types.d.ts.map +1 -0
- package/dist/object/types.js +1 -0
- package/{build → dist}/string/assert.d.ts +24 -0
- package/dist/string/assert.d.ts.map +1 -0
- package/{build → dist}/string/assert.js +30 -1
- package/{build → dist}/string/case-conversion.js +0 -1
- package/{build → dist}/string/comparison.d.ts.map +1 -1
- package/{build → dist}/string/comparison.js +3 -1
- package/{build → dist}/string/formatting.d.ts.map +1 -1
- package/{build → dist}/string/formatting.js +5 -3
- package/{build → dist}/string/index.js +0 -1
- package/{build → dist}/string/transformation.js +0 -1
- package/dist/string/types.d.ts +118 -0
- package/dist/string/types.d.ts.map +1 -0
- package/dist/string/types.js +1 -0
- package/{build → dist}/string/validation.js +0 -1
- package/dist/time/elapsed-time/constants.d.ts +36 -0
- package/{build → dist}/time/elapsed-time/constants.d.ts.map +1 -1
- package/{build → dist}/time/elapsed-time/constants.js +32 -3
- package/{build → dist}/time/elapsed-time/elapsed-time.d.ts +74 -22
- package/dist/time/elapsed-time/elapsed-time.d.ts.map +1 -0
- package/{build → dist}/time/elapsed-time/elapsed-time.js +183 -89
- package/dist/time/elapsed-time/types.d.ts +336 -0
- package/dist/time/elapsed-time/types.d.ts.map +1 -0
- package/dist/time/elapsed-time/types.js +1 -0
- package/{build → dist}/time/elapsed-time/utils.d.ts +1 -1
- package/dist/time/elapsed-time/utils.d.ts.map +1 -0
- package/{build → dist}/time/elapsed-time/utils.js +0 -1
- package/dist/time/index.d.ts +14 -0
- package/dist/time/index.d.ts.map +1 -0
- package/{build → dist}/time/index.js +0 -5
- package/{build → dist}/time/stopwatch/entry.d.ts +1 -1
- package/dist/time/stopwatch/entry.d.ts.map +1 -0
- package/{build → dist}/time/stopwatch/entry.js +0 -1
- package/{build → dist}/time/stopwatch/stopwatch.d.ts +27 -3
- package/dist/time/stopwatch/stopwatch.d.ts.map +1 -0
- package/{build → dist}/time/stopwatch/stopwatch.js +32 -4
- package/dist/zod-util.d.ts +145 -0
- package/dist/zod-util.d.ts.map +1 -0
- package/dist/zod-util.js +126 -0
- package/package.json +51 -67
- package/LICENSE +0 -21
- package/build/array/array-chunk.js.map +0 -1
- package/build/array/array-compact.js.map +0 -1
- package/build/array/array-contains.js.map +0 -1
- package/build/array/array-count-by.js.map +0 -1
- package/build/array/array-difference.d.ts.map +0 -1
- package/build/array/array-difference.js +0 -51
- package/build/array/array-difference.js.map +0 -1
- package/build/array/array-element.js +0 -2
- package/build/array/array-element.js.map +0 -1
- package/build/array/array-filter.js.map +0 -1
- package/build/array/array-flatten.js.map +0 -1
- package/build/array/array-group-by.js.map +0 -1
- package/build/array/array-intersection.d.ts.map +0 -1
- package/build/array/array-intersection.js +0 -57
- package/build/array/array-intersection.js.map +0 -1
- package/build/array/array-partition.js.map +0 -1
- package/build/array/array-range.js.map +0 -1
- package/build/array/array-sample.js.map +0 -1
- package/build/array/array-shuffle.js.map +0 -1
- package/build/array/array-sort-by.js.map +0 -1
- package/build/array/array-zip.js.map +0 -1
- package/build/array/assert.js.map +0 -1
- package/build/array/index.js.map +0 -1
- package/build/array/types.js +0 -2
- package/build/array/types.js.map +0 -1
- package/build/array/unique.js.map +0 -1
- package/build/asserts/errors.d.ts.map +0 -1
- package/build/asserts/errors.js.map +0 -1
- package/build/asserts/generic.d.ts.map +0 -1
- package/build/asserts/generic.js.map +0 -1
- package/build/asserts/index.d.ts +0 -41
- package/build/asserts/index.d.ts.map +0 -1
- package/build/asserts/index.js +0 -41
- package/build/asserts/index.js.map +0 -1
- package/build/asserts/internal-utils.js.map +0 -1
- package/build/asserts/types.d.ts.map +0 -1
- package/build/asserts/types.js +0 -2
- package/build/asserts/types.js.map +0 -1
- package/build/asserts/utils.d.ts.map +0 -1
- package/build/asserts/utils.js.map +0 -1
- package/build/boolean/assert.js.map +0 -1
- package/build/boolean/index.d.ts +0 -9
- package/build/boolean/index.d.ts.map +0 -1
- package/build/boolean/index.js +0 -9
- package/build/boolean/index.js.map +0 -1
- package/build/enum/enum-entries.d.ts.map +0 -1
- package/build/enum/enum-entries.js.map +0 -1
- package/build/enum/enum-key-by-value.d.ts.map +0 -1
- package/build/enum/enum-key-by-value.js.map +0 -1
- package/build/enum/enum-keys.js.map +0 -1
- package/build/enum/enum-safe-value.d.ts.map +0 -1
- package/build/enum/enum-safe-value.js.map +0 -1
- package/build/enum/enum-values.js.map +0 -1
- package/build/enum/index.d.ts.map +0 -1
- package/build/enum/index.js.map +0 -1
- package/build/enum/types.js +0 -2
- package/build/enum/types.js.map +0 -1
- package/build/enum/validate-enum-value.d.ts.map +0 -1
- package/build/enum/validate-enum-value.js.map +0 -1
- package/build/function/compose.d.ts.map +0 -1
- package/build/function/compose.js.map +0 -1
- package/build/function/debounce.d.ts.map +0 -1
- package/build/function/debounce.js.map +0 -1
- package/build/function/index.js.map +0 -1
- package/build/function/memoize.d.ts +0 -30
- package/build/function/memoize.d.ts.map +0 -1
- package/build/function/memoize.js +0 -44
- package/build/function/memoize.js.map +0 -1
- package/build/function/once.js.map +0 -1
- package/build/function/sleep.js.map +0 -1
- package/build/function/throttle.d.ts.map +0 -1
- package/build/function/throttle.js.map +0 -1
- package/build/function/types.d.ts +0 -5
- package/build/function/types.d.ts.map +0 -1
- package/build/function/types.js +0 -2
- package/build/function/types.js.map +0 -1
- package/build/index.d.ts +0 -38
- package/build/index.d.ts.map +0 -1
- package/build/index.js +0 -64
- package/build/index.js.map +0 -1
- package/build/lru-cache.d.ts.map +0 -1
- package/build/lru-cache.js.map +0 -1
- package/build/number/assert.js.map +0 -1
- package/build/number/index.d.ts +0 -9
- package/build/number/index.d.ts.map +0 -1
- package/build/number/index.js +0 -9
- package/build/number/index.js.map +0 -1
- package/build/object/assert-object.js.map +0 -1
- package/build/object/assert.d.ts.map +0 -1
- package/build/object/assert.js.map +0 -1
- package/build/object/clone.d.ts.map +0 -1
- package/build/object/clone.js.map +0 -1
- package/build/object/equals.js.map +0 -1
- package/build/object/filter-cached.d.ts +0 -21
- package/build/object/filter-cached.js.map +0 -1
- package/build/object/filter.js.map +0 -1
- package/build/object/has-circular-reference.js.map +0 -1
- package/build/object/hash.d.ts.map +0 -1
- package/build/object/hash.js.map +0 -1
- package/build/object/index.js.map +0 -1
- package/build/object/json-circular-replacer.js.map +0 -1
- package/build/object/key-value-pairs.js.map +0 -1
- package/build/object/map-cached.d.ts +0 -20
- package/build/object/map-cached.d.ts.map +0 -1
- package/build/object/map-cached.js.map +0 -1
- package/build/object/map.js.map +0 -1
- package/build/object/merge.js.map +0 -1
- package/build/object/object-diff.js.map +0 -1
- package/build/object/object-flatten.js.map +0 -1
- package/build/object/object-invert.js.map +0 -1
- package/build/object/omit.js.map +0 -1
- package/build/object/pick.js.map +0 -1
- package/build/object/property-paths.js.map +0 -1
- package/build/object/security-utils.d.ts +0 -59
- package/build/object/security-utils.d.ts.map +0 -1
- package/build/object/security-utils.js +0 -161
- package/build/object/security-utils.js.map +0 -1
- package/build/object/sort-keys.d.ts.map +0 -1
- package/build/object/sort-keys.js +0 -52
- package/build/object/sort-keys.js.map +0 -1
- package/build/object/types.d.ts.map +0 -1
- package/build/object/types.js +0 -6
- package/build/object/types.js.map +0 -1
- package/build/string/assert.d.ts.map +0 -1
- package/build/string/assert.js.map +0 -1
- package/build/string/case-conversion.js.map +0 -1
- package/build/string/comparison.js.map +0 -1
- package/build/string/formatting.js.map +0 -1
- package/build/string/index.js.map +0 -1
- package/build/string/transformation.js.map +0 -1
- package/build/string/types.d.ts +0 -44
- package/build/string/types.d.ts.map +0 -1
- package/build/string/types.js +0 -2
- package/build/string/types.js.map +0 -1
- package/build/string/validation.js.map +0 -1
- package/build/time/elapsed-time/constants.d.ts +0 -10
- package/build/time/elapsed-time/constants.js.map +0 -1
- package/build/time/elapsed-time/elapsed-time.d.ts.map +0 -1
- package/build/time/elapsed-time/elapsed-time.js.map +0 -1
- package/build/time/elapsed-time/types.d.ts +0 -150
- package/build/time/elapsed-time/types.d.ts.map +0 -1
- package/build/time/elapsed-time/types.js +0 -2
- package/build/time/elapsed-time/types.js.map +0 -1
- package/build/time/elapsed-time/utils.d.ts.map +0 -1
- package/build/time/elapsed-time/utils.js.map +0 -1
- package/build/time/index.d.ts +0 -18
- package/build/time/index.d.ts.map +0 -1
- package/build/time/index.js.map +0 -1
- package/build/time/stopwatch/entry-types.d.ts +0 -13
- package/build/time/stopwatch/entry-types.d.ts.map +0 -1
- package/build/time/stopwatch/entry-types.js +0 -2
- package/build/time/stopwatch/entry-types.js.map +0 -1
- package/build/time/stopwatch/entry.d.ts.map +0 -1
- package/build/time/stopwatch/entry.js.map +0 -1
- package/build/time/stopwatch/stopwatch.d.ts.map +0 -1
- package/build/time/stopwatch/stopwatch.js.map +0 -1
- /package/{build → dist}/array/array-chunk.d.ts.map +0 -0
- /package/{build → dist}/array/array-compact.d.ts.map +0 -0
- /package/{build → dist}/array/array-contains.d.ts.map +0 -0
- /package/{build → dist}/array/array-count-by.d.ts.map +0 -0
- /package/{build → dist}/array/array-element.d.ts +0 -0
- /package/{build → dist}/array/array-element.d.ts.map +0 -0
- /package/{build → dist}/array/array-filter.d.ts.map +0 -0
- /package/{build → dist}/array/array-partition.d.ts.map +0 -0
- /package/{build → dist}/array/array-range.d.ts.map +0 -0
- /package/{build → dist}/array/array-sample.d.ts.map +0 -0
- /package/{build → dist}/array/array-shuffle.d.ts.map +0 -0
- /package/{build → dist}/array/array-sort-by.d.ts.map +0 -0
- /package/{build → dist}/array/array-zip.d.ts.map +0 -0
- /package/{build → dist}/array/unique.d.ts.map +0 -0
- /package/{build → dist}/asserts/errors.d.ts +0 -0
- /package/{build → dist}/asserts/internal-utils.d.ts +0 -0
- /package/{build → dist}/enum/enum-keys.d.ts +0 -0
- /package/{build → dist}/enum/enum-keys.d.ts.map +0 -0
- /package/{build → dist}/enum/enum-values.d.ts +0 -0
- /package/{build → dist}/enum/enum-values.d.ts.map +0 -0
- /package/{build → dist}/enum/types.d.ts +0 -0
- /package/{build → dist}/enum/types.d.ts.map +0 -0
- /package/{build → dist}/function/index.d.ts +0 -0
- /package/{build → dist}/function/index.d.ts.map +0 -0
- /package/{build → dist}/function/once.d.ts +0 -0
- /package/{build → dist}/function/sleep.d.ts +0 -0
- /package/{build → dist}/function/sleep.d.ts.map +0 -0
- /package/{build → dist}/number/assert.d.ts +0 -0
- /package/{build → dist}/number/assert.d.ts.map +0 -0
- /package/{build → dist}/object/equals.d.ts +0 -0
- /package/{build → dist}/object/filter.d.ts +0 -0
- /package/{build → dist}/object/has-circular-reference.d.ts +0 -0
- /package/{build → dist}/object/json-circular-replacer.d.ts +0 -0
- /package/{build → dist}/object/key-value-pairs.d.ts +0 -0
- /package/{build → dist}/object/key-value-pairs.d.ts.map +0 -0
- /package/{build → dist}/object/map.d.ts +0 -0
- /package/{build → dist}/object/map.d.ts.map +0 -0
- /package/{build → dist}/object/merge.d.ts +0 -0
- /package/{build → dist}/object/object-invert.d.ts +0 -0
- /package/{build → dist}/object/object-invert.d.ts.map +0 -0
- /package/{build → dist}/object/omit.d.ts +0 -0
- /package/{build → dist}/object/omit.d.ts.map +0 -0
- /package/{build → dist}/object/pick.d.ts +0 -0
- /package/{build → dist}/object/pick.d.ts.map +0 -0
- /package/{build → dist}/string/case-conversion.d.ts +0 -0
- /package/{build → dist}/string/case-conversion.d.ts.map +0 -0
- /package/{build → dist}/string/comparison.d.ts +0 -0
- /package/{build → dist}/string/formatting.d.ts +0 -0
- /package/{build → dist}/string/index.d.ts +0 -0
- /package/{build → dist}/string/index.d.ts.map +0 -0
- /package/{build → dist}/string/transformation.d.ts +0 -0
- /package/{build → dist}/string/transformation.d.ts.map +0 -0
- /package/{build → dist}/string/validation.d.ts +0 -0
- /package/{build → dist}/string/validation.d.ts.map +0 -0
|
@@ -1,64 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A constructor function type for creating objects of type O.
|
|
3
|
-
* @template O The object type to construct.
|
|
4
|
-
*/
|
|
5
|
-
export type TConstructableObject<O extends object = object> = new (...args: any[]) => O;
|
|
6
|
-
/**
|
|
7
|
-
* Omits properties from B that are not in A.
|
|
8
|
-
* @template A Base type.
|
|
9
|
-
* @template B Type to filter.
|
|
10
|
-
*/
|
|
11
|
-
export type TObjectOmitExtraProperties<A, B> = {
|
|
12
|
-
[K in keyof B]: K extends A ? B[K] : never;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Extracts the property keys of an object type.
|
|
16
|
-
* @template O The object type.
|
|
17
|
-
*/
|
|
18
|
-
export type TObjectProperties<O extends object> = keyof O;
|
|
19
|
-
/**
|
|
20
|
-
* Extracts property keys of a specific type from an object.
|
|
21
|
-
* @template O Object type.
|
|
22
|
-
* @template PropertyType The type to match.
|
|
23
|
-
*/
|
|
24
|
-
export type TObjectPropertiesOfType<O extends object, PropertyType> = keyof {
|
|
25
|
-
[K in keyof O as O[K] extends PropertyType ? K : never]: any;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Omits properties of a specific type from an object.
|
|
29
|
-
* @template O Object type.
|
|
30
|
-
* @template PropertyType The type to omit.
|
|
31
|
-
*/
|
|
32
|
-
export type TObjectOmitPropertiesOfType<O extends object, PropertyType> = {
|
|
33
|
-
[K in keyof O as O[K] extends PropertyType ? never : K]: O[K];
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Represents the union of all property values in an object.
|
|
37
|
-
* @template T Object type.
|
|
38
|
-
*/
|
|
39
|
-
export type TObjectPropertyType<T extends object> = T[keyof T];
|
|
40
|
-
/**
|
|
41
|
-
* Extracts properties shared between two object types.
|
|
42
|
-
* @template A First object type.
|
|
43
|
-
* @template B Second object type.
|
|
44
|
-
*/
|
|
45
|
-
export type TObjectSharedProperties<A extends object, B extends object> = {
|
|
46
|
-
[K in keyof A & keyof B]: K extends keyof A ? A[K] : never;
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* Extracts keys of array properties from an object type.
|
|
50
|
-
* @template T Object type.
|
|
51
|
-
*/
|
|
52
|
-
export type TObjectArrayProperties<T extends object> = {
|
|
53
|
-
[K in keyof T]: T[K] extends Array<any> ? K : never;
|
|
54
|
-
}[keyof T];
|
|
55
|
-
/**
|
|
56
|
-
* Generates nested dot-notation keys for an object type.
|
|
57
|
-
* @template ObjectType The object type.
|
|
58
|
-
*/
|
|
59
|
-
export type TObjectNestedKeyOf<ObjectType extends object> = {
|
|
60
|
-
[Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object ? `${Key}` | `${Key}.${TObjectNestedKeyOf<ObjectType[Key]>}` : `${Key}`;
|
|
61
|
-
}[keyof ObjectType & (string | number)];
|
|
62
1
|
/**
|
|
63
2
|
* Options for object filtering behavior.
|
|
64
3
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/object/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC,4HAA4H;IAC5H,YAAY,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACnC,8EAA8E;IAC9E,sBAAsB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7C,iHAAiH;IACjH,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IAC1C,qGAAqG;IACrG,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,4HAA4H;IAC5H,YAAY,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACnC,8EAA8E;IAC9E,sBAAsB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7C,iHAAiH;IACjH,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACvC,0FAA0F;IAC1F,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAClC;AAED;;;GAGG;AACH,MAAM,MAAM,2BAA2B,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAEtI;;;GAGG;AACH,MAAM,MAAM,2BAA2B,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;AAE7J;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC;AAE9E;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM,EAAE,OAAO,SAAS,MAAM,GAAG,MAAM,IAAI,CACjG,KAAK,EAAE,MAAM,KACT,OAAO,CAAC;AAEb;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC;AAElF;;;;;;GAMG;AACH,MAAM,MAAM,yBAAyB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC;AAE3F;;;;;;;GAOG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CACrF,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,KACP,OAAO,CAAC;AAEb;;;;;;;GAOG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CACrF,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,KACP,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,8 +3,13 @@ import { SimpleError } from '../asserts/errors.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* Error thrown when a value is not a valid string or fails a string assertion.
|
|
5
5
|
*
|
|
6
|
+
* @returns A StringError instance with the provided message
|
|
7
|
+
* @throws N/A - This is an error class constructor
|
|
8
|
+
*
|
|
6
9
|
* @example
|
|
10
|
+
* ```typescript
|
|
7
11
|
* throw new StringError('Value is not a valid string');
|
|
12
|
+
* ```
|
|
8
13
|
*/
|
|
9
14
|
export declare class StringError extends SimpleError {
|
|
10
15
|
constructor(message?: string);
|
|
@@ -97,5 +102,24 @@ export declare function AssertStringNotEmpty(value: unknown, exception?: IAssert
|
|
|
97
102
|
* AssertStringMatches("user2@example.com", emailPattern); // Uses cached pattern
|
|
98
103
|
* ```
|
|
99
104
|
*/
|
|
105
|
+
/**
|
|
106
|
+
* Asserts that the provided value matches the specified regular expression pattern.
|
|
107
|
+
*
|
|
108
|
+
* Uses an LRU cache to store compiled RegExp objects for repeated pattern matching,
|
|
109
|
+
* improving performance for long-running processes with dynamic regex patterns.
|
|
110
|
+
*
|
|
111
|
+
* @remarks
|
|
112
|
+
* - Cache size: 100 entries
|
|
113
|
+
* - Cache is LRU-evicted (least recently used entry is removed when size is exceeded)
|
|
114
|
+
* - When to expect cache behavior: dynamic regex patterns with long-running processes
|
|
115
|
+
*
|
|
116
|
+
* @param value - The string to test against the pattern
|
|
117
|
+
* @param regex - The regular expression pattern to match
|
|
118
|
+
* @param exception - Optional exception configuration
|
|
119
|
+
* @throws StringError if the value does not match the pattern
|
|
120
|
+
* @example
|
|
121
|
+
* AssertStringMatches('test@example.com', /^[^@]+@[^@]+\.[^@]+$/); // passes
|
|
122
|
+
* AssertStringMatches('invalid-email', /^[^@]+@[^@]+\.[^@]+$/); // throws
|
|
123
|
+
*/
|
|
100
124
|
export declare function AssertStringMatches(value: string, regex: RegExp, exception?: IAssertException): void;
|
|
101
125
|
//# sourceMappingURL=assert.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../src/string/assert.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AA8CnD;;;;;;;;;;GAUG;AACH,qBAAa,WAAY,SAAQ,WAAW;gBAC/B,OAAO,CAAC,EAAE,MAAM;CAG5B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,GAAE,gBAAqB,GAAG,OAAO,CAAC,KAAK,IAAI,MAAM,CAGtG;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,GAAE,gBAAqB,GAAG,OAAO,CAAC,KAAK,IAAI,MAAM,CAY9G;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,GAAE,gBAAqB,GAAG,IAAI,CAsBxG"}
|
|
@@ -19,6 +19,12 @@ const REGEX_PATTERN_CACHE = new LRUCache(MAX_CACHE_SIZE);
|
|
|
19
19
|
* Gets a cached regex pattern or creates and caches a new one.
|
|
20
20
|
* This optimization improves performance when the same regex patterns are used repeatedly.
|
|
21
21
|
*
|
|
22
|
+
* The cache key format `${source}:::${flags}` is safe because:
|
|
23
|
+
* - The `source` parameter is validated by RegExp constructor (throws on invalid patterns)
|
|
24
|
+
* - The `flags` parameter is validated by RegExp constructor (throws on invalid flags)
|
|
25
|
+
* - No user-supplied input is included in the cache key beyond these validated components
|
|
26
|
+
* - The separator ':::' cannot appear in valid regex flags, preventing key collision
|
|
27
|
+
*
|
|
22
28
|
* @param source - The regex pattern source string
|
|
23
29
|
* @param flags - The regex flags string
|
|
24
30
|
* @returns The compiled RegExp object
|
|
@@ -37,8 +43,13 @@ function getCachedRegex(source, flags = '') {
|
|
|
37
43
|
/**
|
|
38
44
|
* Error thrown when a value is not a valid string or fails a string assertion.
|
|
39
45
|
*
|
|
46
|
+
* @returns A StringError instance with the provided message
|
|
47
|
+
* @throws N/A - This is an error class constructor
|
|
48
|
+
*
|
|
40
49
|
* @example
|
|
50
|
+
* ```typescript
|
|
41
51
|
* throw new StringError('Value is not a valid string');
|
|
52
|
+
* ```
|
|
42
53
|
*/
|
|
43
54
|
export class StringError extends SimpleError {
|
|
44
55
|
constructor(message) {
|
|
@@ -148,6 +159,25 @@ export function AssertStringNotEmpty(value, exception = {}) {
|
|
|
148
159
|
* AssertStringMatches("user2@example.com", emailPattern); // Uses cached pattern
|
|
149
160
|
* ```
|
|
150
161
|
*/
|
|
162
|
+
/**
|
|
163
|
+
* Asserts that the provided value matches the specified regular expression pattern.
|
|
164
|
+
*
|
|
165
|
+
* Uses an LRU cache to store compiled RegExp objects for repeated pattern matching,
|
|
166
|
+
* improving performance for long-running processes with dynamic regex patterns.
|
|
167
|
+
*
|
|
168
|
+
* @remarks
|
|
169
|
+
* - Cache size: 100 entries
|
|
170
|
+
* - Cache is LRU-evicted (least recently used entry is removed when size is exceeded)
|
|
171
|
+
* - When to expect cache behavior: dynamic regex patterns with long-running processes
|
|
172
|
+
*
|
|
173
|
+
* @param value - The string to test against the pattern
|
|
174
|
+
* @param regex - The regular expression pattern to match
|
|
175
|
+
* @param exception - Optional exception configuration
|
|
176
|
+
* @throws StringError if the value does not match the pattern
|
|
177
|
+
* @example
|
|
178
|
+
* AssertStringMatches('test@example.com', /^[^@]+@[^@]+\.[^@]+$/); // passes
|
|
179
|
+
* AssertStringMatches('invalid-email', /^[^@]+@[^@]+\.[^@]+$/); // throws
|
|
180
|
+
*/
|
|
151
181
|
export function AssertStringMatches(value, regex, exception = {}) {
|
|
152
182
|
SetExceptionClass(exception, StringError);
|
|
153
183
|
AssertString(value, exception); // Ensure value is a string before matching
|
|
@@ -169,4 +199,3 @@ export function AssertStringMatches(value, regex, exception = {}) {
|
|
|
169
199
|
ThrowException(exception);
|
|
170
200
|
}
|
|
171
201
|
}
|
|
172
|
-
//# sourceMappingURL=assert.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comparison.d.ts","sourceRoot":"","sources":["../../src/string/comparison.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"comparison.d.ts","sourceRoot":"","sources":["../../src/string/comparison.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,eAAe,UAAQ,GAAG,OAAO,CAQnF"}
|
|
@@ -18,8 +18,10 @@
|
|
|
18
18
|
*/
|
|
19
19
|
export function StringEquals(a, b, caseInsensitive = false) {
|
|
20
20
|
if (caseInsensitive) {
|
|
21
|
+
// Note: toLowerCase() allocates a new string per call.
|
|
22
|
+
// For performance-critical loops (>1000 calls/sec), consider:
|
|
23
|
+
// a.localeCompare(b, undefined, { sensitivity: 'accent' }) which avoids allocations.
|
|
21
24
|
return a.toLowerCase() === b.toLowerCase();
|
|
22
25
|
}
|
|
23
26
|
return a === b;
|
|
24
27
|
}
|
|
25
|
-
//# sourceMappingURL=comparison.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../../src/string/formatting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../../src/string/formatting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAM7D;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAW9C;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,YAAY,CAC3B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,aAAa,GAAG,WAAW,GACjC,MAAM,CAoBR;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,SAAQ,GAAG,MAAM,CAUvF;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,SAAM,EAAE,MAAM,UAAO,GAAG,MAAM,CASxF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG7C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAG9E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG7C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CASpE"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// Unicode flag (u) ensures consistent behavior with multi-byte characters (emoji, combining marks).
|
|
2
|
+
const INDEX_PLACEHOLDER_REGEX = /\{(\d+)\}/gu;
|
|
3
|
+
const KEY_PLACEHOLDER_REGEX = /\{(\w+)\}/gu;
|
|
1
4
|
/**
|
|
2
5
|
* Escapes a string for safe use in HTML by replacing special characters with
|
|
3
6
|
* their HTML entity equivalents.
|
|
@@ -49,12 +52,12 @@ export function FormatString(template, params) {
|
|
|
49
52
|
if (template && typeof template === 'string') {
|
|
50
53
|
if (params && (Array.isArray(params) || typeof params === 'object')) {
|
|
51
54
|
if (Array.isArray(params)) {
|
|
52
|
-
return template.replace(
|
|
55
|
+
return template.replace(INDEX_PLACEHOLDER_REGEX, (match, index) => {
|
|
53
56
|
const value = params[parseInt(index, 10)];
|
|
54
57
|
return value !== undefined && value !== null ? String(value) : match;
|
|
55
58
|
});
|
|
56
59
|
}
|
|
57
|
-
return template.replace(
|
|
60
|
+
return template.replace(KEY_PLACEHOLDER_REGEX, (match, key) => {
|
|
58
61
|
const value = params[key];
|
|
59
62
|
return value !== undefined && value !== null ? String(value) : match;
|
|
60
63
|
});
|
|
@@ -188,4 +191,3 @@ export function CountOccurrences(str, substr) {
|
|
|
188
191
|
}
|
|
189
192
|
return count;
|
|
190
193
|
}
|
|
191
|
-
//# sourceMappingURL=formatting.js.map
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* String validator function type.
|
|
3
|
+
*
|
|
4
|
+
* A validator function that tests if a string meets certain criteria.
|
|
5
|
+
*
|
|
6
|
+
* @param value - The string to validate
|
|
7
|
+
* @returns true if the string passes validation, false otherwise
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const isLong: TStringValidator = (s) => s.length > 10;
|
|
12
|
+
* isLong('hello'); // false
|
|
13
|
+
* isLong('hello world'); // true
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export type TStringValidator = (value: string) => boolean;
|
|
17
|
+
/**
|
|
18
|
+
* String formatter function type with optional parameters.
|
|
19
|
+
*
|
|
20
|
+
* A formatter function that transforms a string with optional formatting parameters.
|
|
21
|
+
*
|
|
22
|
+
* @param value - The string to format
|
|
23
|
+
* @param params - Optional formatting parameters
|
|
24
|
+
* @returns The formatted string
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const uppercase: TStringFormatter = (s) => s.toUpperCase();
|
|
29
|
+
* uppercase('hello'); // 'HELLO'
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export type TStringFormatter = (value: string, ...params: unknown[]) => string;
|
|
33
|
+
/**
|
|
34
|
+
* String transformer function type.
|
|
35
|
+
*
|
|
36
|
+
* A transformer function that converts input to a transformed string output.
|
|
37
|
+
*
|
|
38
|
+
* @param input - The input string
|
|
39
|
+
* @returns The transformed string
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const reverse: TStringTransformer = (s) => Array.from(s).reverse().join('');
|
|
44
|
+
* reverse('hello'); // 'olleh'
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export type TStringTransformer = (input: string) => string;
|
|
48
|
+
/**
|
|
49
|
+
* Case converter function type.
|
|
50
|
+
*
|
|
51
|
+
* A function that converts a string to a specific case format (camelCase, PascalCase, etc.).
|
|
52
|
+
*
|
|
53
|
+
* @param value - The string to convert
|
|
54
|
+
* @returns The string in the target case format
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* const toCamel: TCaseConverter = (s) => s.replace(/-(.)/g, (_, c) => c.toUpperCase());
|
|
59
|
+
* toCamel('hello-world'); // 'helloWorld'
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export type TCaseConverter = (value: string) => string;
|
|
63
|
+
/**
|
|
64
|
+
* String predicate function type.
|
|
65
|
+
*
|
|
66
|
+
* A predicate function that tests if a string meets a specific condition.
|
|
67
|
+
*
|
|
68
|
+
* @param value - The string to test
|
|
69
|
+
* @returns true if the string passes the predicate, false otherwise
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* const isEmail: TStringPredicate = (s) => s.includes('@');
|
|
74
|
+
* isEmail('user@example.com'); // true
|
|
75
|
+
* isEmail('invalid'); // false
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export type TStringPredicate = (value: string) => boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Format parameter value types.
|
|
81
|
+
*
|
|
82
|
+
* Supported types for placeholder values in string formatting operations.
|
|
83
|
+
*
|
|
84
|
+
* @returns N/A - This is a type alias
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* const values: TFormatValue[] = [42, 'hello', true, null, undefined];
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export type TFormatValue = string | number | boolean | null | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* Format parameters as key-value pairs.
|
|
94
|
+
*
|
|
95
|
+
* Object structure for named placeholder substitution in string formatting.
|
|
96
|
+
*
|
|
97
|
+
* @returns N/A - This is a type alias
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* const params: TFormatParams = { name: 'World', count: 42 };
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
export type TFormatParams = Record<string, TFormatValue>;
|
|
105
|
+
/**
|
|
106
|
+
* Format parameters as positional array.
|
|
107
|
+
*
|
|
108
|
+
* Array structure for positional placeholder substitution in string formatting.
|
|
109
|
+
*
|
|
110
|
+
* @returns N/A - This is a type alias
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* const args: TFormatArgs = ['World', 42, true];
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
export type TFormatArgs = TFormatValue[];
|
|
118
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/string/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;AAE1D;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,KAAK,MAAM,CAAC;AAE/E;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;AAE3D;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;AAEvD;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;AAE1D;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;AAExE;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAEzD;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,WAAW,GAAG,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { IDefaultUnitLabels, IFormats } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Default unit label sets for all predefined formatting styles.
|
|
4
|
+
* Provides pre-defined label configurations for concise, short, medium, and long time formats.
|
|
5
|
+
*
|
|
6
|
+
* Each style object maps time units (week, day, hour, minute, second, millisecond) to their labels.
|
|
7
|
+
* Labels can be static strings (concise, short, medium) or functions that handle pluralization (long).
|
|
8
|
+
* All label sets include a `style` property for runtime identification.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* // Using concise labels: single-character abbreviations
|
|
13
|
+
* const conciseLabel = DEFAULT_UNIT_LABELS.concise.hour; // "h"
|
|
14
|
+
*
|
|
15
|
+
* // Using long labels: function-based with pluralization
|
|
16
|
+
* const longLabel = DEFAULT_UNIT_LABELS.long.hour(1); // "hour"
|
|
17
|
+
* const longLabel2 = DEFAULT_UNIT_LABELS.long.hour(2); // "hours"
|
|
18
|
+
*
|
|
19
|
+
* // Using medium labels: readable abbreviations
|
|
20
|
+
* const mediumLabel = DEFAULT_UNIT_LABELS.medium.hour; // "hour"
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare const DEFAULT_UNIT_LABELS: IDefaultUnitLabels;
|
|
24
|
+
/**
|
|
25
|
+
* Predefined format configurations for elapsed time formatting.
|
|
26
|
+
* Each configuration provides unitLabels and optional display options for a specific format style.
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
* The `long` format configuration defines pluralization logic for unit labels (e.g., "hour" vs "hours").
|
|
30
|
+
* This logic is duplicated in the `ElapsedTime._FormatLong()` private method, which handles the special
|
|
31
|
+
* formatting requirements of the long format with its own pluralization. Both locations must be kept in
|
|
32
|
+
* sync when modifying singular/plural unit names. This duplication exists because the FORMATS constant
|
|
33
|
+
* provides label templates while _FormatLong() handles the actual runtime transformation.
|
|
34
|
+
*/
|
|
35
|
+
export declare const FORMATS: IFormats;
|
|
36
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/time/elapsed-time/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE/D
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/time/elapsed-time/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,mBAAmB,EAAE,kBAqCxB,CAAC;AAEX;;;;;;;;;;GAUG;AACH,eAAO,MAAM,OAAO,EAAE,QA4DZ,CAAC"}
|
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Default unit
|
|
2
|
+
* Default unit label sets for all predefined formatting styles.
|
|
3
|
+
* Provides pre-defined label configurations for concise, short, medium, and long time formats.
|
|
4
|
+
*
|
|
5
|
+
* Each style object maps time units (week, day, hour, minute, second, millisecond) to their labels.
|
|
6
|
+
* Labels can be static strings (concise, short, medium) or functions that handle pluralization (long).
|
|
7
|
+
* All label sets include a `style` property for runtime identification.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* // Using concise labels: single-character abbreviations
|
|
12
|
+
* const conciseLabel = DEFAULT_UNIT_LABELS.concise.hour; // "h"
|
|
13
|
+
*
|
|
14
|
+
* // Using long labels: function-based with pluralization
|
|
15
|
+
* const longLabel = DEFAULT_UNIT_LABELS.long.hour(1); // "hour"
|
|
16
|
+
* const longLabel2 = DEFAULT_UNIT_LABELS.long.hour(2); // "hours"
|
|
17
|
+
*
|
|
18
|
+
* // Using medium labels: readable abbreviations
|
|
19
|
+
* const mediumLabel = DEFAULT_UNIT_LABELS.medium.hour; // "hour"
|
|
20
|
+
* ```
|
|
3
21
|
*/
|
|
4
22
|
export const DEFAULT_UNIT_LABELS = {
|
|
5
23
|
concise: {
|
|
24
|
+
style: 'concise',
|
|
6
25
|
day: 'd',
|
|
7
26
|
hour: 'h',
|
|
8
27
|
millisecond: 'ms',
|
|
@@ -11,6 +30,7 @@ export const DEFAULT_UNIT_LABELS = {
|
|
|
11
30
|
week: 'w',
|
|
12
31
|
},
|
|
13
32
|
long: {
|
|
33
|
+
style: 'long',
|
|
14
34
|
day: (value) => `${value === 1 ? 'day' : 'days'}`,
|
|
15
35
|
hour: (value) => `${value === 1 ? 'hour' : 'hours'}`,
|
|
16
36
|
millisecond: (value) => `${value === 1 ? 'millisecond' : 'milliseconds'}`,
|
|
@@ -19,6 +39,7 @@ export const DEFAULT_UNIT_LABELS = {
|
|
|
19
39
|
week: (value) => `${value === 1 ? 'week' : 'weeks'}`,
|
|
20
40
|
},
|
|
21
41
|
medium: {
|
|
42
|
+
style: 'medium',
|
|
22
43
|
day: 'day',
|
|
23
44
|
hour: 'hour',
|
|
24
45
|
millisecond: 'ms',
|
|
@@ -27,6 +48,7 @@ export const DEFAULT_UNIT_LABELS = {
|
|
|
27
48
|
week: 'week',
|
|
28
49
|
},
|
|
29
50
|
short: {
|
|
51
|
+
style: 'short',
|
|
30
52
|
day: 'd',
|
|
31
53
|
hour: 'hr',
|
|
32
54
|
millisecond: 'ms',
|
|
@@ -36,7 +58,15 @@ export const DEFAULT_UNIT_LABELS = {
|
|
|
36
58
|
},
|
|
37
59
|
};
|
|
38
60
|
/**
|
|
39
|
-
* Predefined
|
|
61
|
+
* Predefined format configurations for elapsed time formatting.
|
|
62
|
+
* Each configuration provides unitLabels and optional display options for a specific format style.
|
|
63
|
+
*
|
|
64
|
+
* @remarks
|
|
65
|
+
* The `long` format configuration defines pluralization logic for unit labels (e.g., "hour" vs "hours").
|
|
66
|
+
* This logic is duplicated in the `ElapsedTime._FormatLong()` private method, which handles the special
|
|
67
|
+
* formatting requirements of the long format with its own pluralization. Both locations must be kept in
|
|
68
|
+
* sync when modifying singular/plural unit names. This duplication exists because the FORMATS constant
|
|
69
|
+
* provides label templates while _FormatLong() handles the actual runtime transformation.
|
|
40
70
|
*/
|
|
41
71
|
export const FORMATS = {
|
|
42
72
|
/**
|
|
@@ -93,4 +123,3 @@ export const FORMATS = {
|
|
|
93
123
|
},
|
|
94
124
|
},
|
|
95
125
|
};
|
|
96
|
-
//# sourceMappingURL=constants.js.map
|