@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
package/README.md
CHANGED
|
@@ -1,288 +1,435 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @pawells/typescript-common
|
|
2
2
|
|
|
3
|
-
[](https://github.com/PhillipAWells/typescript-common/releases)
|
|
5
|
-
[](https://github.com/PhillipAWells/typescript-common/actions/workflows/ci.yml)
|
|
3
|
+
[](https://github.com/PhillipAWells/common/actions/workflows/ci.yml)
|
|
6
4
|
[](https://nodejs.org)
|
|
5
|
+
[](https://www.npmjs.com/package/@pawells/typescript-common)
|
|
7
6
|
[](./LICENSE)
|
|
8
|
-
[](https://github.com/sponsors/PhillipAWells)
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
## Description
|
|
9
|
+
|
|
10
|
+
Shared TypeScript utility library providing strongly-typed, well-tested utility functions across eight domains: array, asserts, boolean, enum, function, lru-cache, object, string, and time. All functions are documented with JSDoc, fully typed, and tested to 80% coverage across all metrics.
|
|
11
|
+
|
|
12
|
+
## Requirements
|
|
13
|
+
|
|
14
|
+
- **Node.js**: 22.0.0 or later
|
|
15
|
+
- **TypeScript**: 6.0.0 or later (if consuming from source)
|
|
16
|
+
|
|
17
|
+
### Local Development
|
|
18
|
+
|
|
19
|
+
During local development, the package exports a `local` condition that resolves to TypeScript source directly without requiring a build step. This enables fast iteration when developing consuming packages.
|
|
20
|
+
|
|
21
|
+
To use the local condition in your `tsconfig.json`, ensure your resolver is configured to recognize the `@pawells/typescript-common-workspace` condition:
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
{
|
|
25
|
+
"compilerOptions": {
|
|
26
|
+
"moduleResolution": "bundler",
|
|
27
|
+
"customConditions": ["@pawells/typescript-common-workspace"]
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
11
31
|
|
|
12
32
|
## Installation
|
|
13
33
|
|
|
34
|
+
Install from npm:
|
|
35
|
+
|
|
14
36
|
```bash
|
|
15
37
|
npm install @pawells/typescript-common
|
|
16
|
-
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Or with yarn:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
17
43
|
yarn add @pawells/typescript-common
|
|
18
44
|
```
|
|
19
45
|
|
|
20
|
-
##
|
|
46
|
+
## Quick Start
|
|
21
47
|
|
|
22
|
-
All
|
|
48
|
+
All exports are available from the main entry point or from domain-specific entry points for tree-shaking.
|
|
49
|
+
|
|
50
|
+
### Array Domain
|
|
23
51
|
|
|
24
52
|
```typescript
|
|
25
|
-
|
|
26
|
-
import {
|
|
27
|
-
ArrayUtils, BooleanUtils, NumberUtils,
|
|
28
|
-
ObjectUtils, StringUtils, TimeUtils,
|
|
29
|
-
EnumUtils, FunctionUtils, AssertsUtils,
|
|
30
|
-
} from '@pawells/typescript-common';
|
|
53
|
+
import { ArrayChunk, ArrayFilter, ArrayShuffle, Unique } from '@pawells/typescript-common';
|
|
31
54
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
ObjectUtils.IsObject(value); // returns true/false (type-guard)
|
|
35
|
-
BooleanUtils.AssertBoolean(value); // throws if not a boolean
|
|
36
|
-
NumberUtils.AssertNumber(value, { gte: 0, integer: true });
|
|
55
|
+
const items = [1, 2, 3, 4, 5];
|
|
56
|
+
const chunked = ArrayChunk(items, 2); // [[1, 2], [3, 4], [5]]
|
|
37
57
|
|
|
38
|
-
|
|
39
|
-
import { ArrayChunk, ObjectPick, KebabCase, Sleep, AssertString, LRUCache } from '@pawells/typescript-common';
|
|
40
|
-
```
|
|
58
|
+
const filtered = ArrayFilter([1, 2, 3, 4], (x) => x > 2); // [3, 4]
|
|
41
59
|
|
|
42
|
-
|
|
60
|
+
const shuffled = ArrayShuffle([1, 2, 3]); // Random order
|
|
43
61
|
|
|
44
|
-
|
|
62
|
+
const unique = Unique([1, 2, 2, 3]); // [1, 2, 3]
|
|
63
|
+
```
|
|
45
64
|
|
|
46
|
-
|
|
65
|
+
### Asserts Domain
|
|
47
66
|
|
|
48
67
|
```typescript
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
68
|
+
import { AssertString, AssertNumber, AssertArray } from '@pawells/typescript-common';
|
|
69
|
+
|
|
70
|
+
AssertString(value); // Throws if value is not a string
|
|
71
|
+
AssertNumber(42); // Passes
|
|
72
|
+
AssertArray([1, 2, 3]); // Passes
|
|
52
73
|
```
|
|
53
74
|
|
|
54
|
-
###
|
|
75
|
+
### Boolean Domain
|
|
55
76
|
|
|
56
|
-
|
|
77
|
+
```typescript
|
|
78
|
+
import { AssertBoolean } from '@pawells/typescript-common';
|
|
79
|
+
|
|
80
|
+
AssertBoolean(true); // Passes
|
|
81
|
+
AssertBoolean('not a boolean'); // Throws
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Enum Domain
|
|
57
85
|
|
|
58
86
|
```typescript
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
87
|
+
import { EnumKeys, EnumValues, ValidateEnumValue, EnumSafeValue } from '@pawells/typescript-common';
|
|
88
|
+
|
|
89
|
+
enum Color {
|
|
90
|
+
Red = 'RED',
|
|
91
|
+
Green = 'GREEN',
|
|
92
|
+
Blue = 'BLUE',
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const keys = EnumKeys(Color); // ['Red', 'Green', 'Blue']
|
|
96
|
+
const values = EnumValues(Color); // ['RED', 'GREEN', 'BLUE']
|
|
97
|
+
const isValid = ValidateEnumValue(Color, 'RED'); // true
|
|
98
|
+
const safe = EnumSafeValue(Color, 'INVALID', Color.Red); // Color.Red
|
|
99
|
+
```
|
|
62
100
|
|
|
63
|
-
|
|
64
|
-
|
|
101
|
+
### Function Domain
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
import { Memoize, Debounce, Throttle, Once, Compose } from '@pawells/typescript-common';
|
|
105
|
+
|
|
106
|
+
// Memoization
|
|
107
|
+
const expensiveCalc = Memoize((n: number) => n * n);
|
|
108
|
+
expensiveCalc(4); // Computed: 16
|
|
109
|
+
expensiveCalc(4); // Cached: 16
|
|
110
|
+
|
|
111
|
+
// Debouncing
|
|
112
|
+
const handleSearch = Debounce((query: string) => console.log(query), 300);
|
|
113
|
+
handleSearch('a');
|
|
114
|
+
handleSearch('ab');
|
|
115
|
+
handleSearch('abc'); // Only this logs after 300ms
|
|
116
|
+
|
|
117
|
+
// Throttling
|
|
118
|
+
const handleResize = Throttle(() => console.log('resized'), 100);
|
|
119
|
+
|
|
120
|
+
// Single execution
|
|
121
|
+
const initialize = Once(() => console.log('init'));
|
|
122
|
+
initialize(); // logs
|
|
123
|
+
initialize(); // no-op
|
|
124
|
+
|
|
125
|
+
// Function composition
|
|
126
|
+
const add = (x: number) => x + 1;
|
|
127
|
+
const double = (x: number) => x * 2;
|
|
128
|
+
const composed = Compose(double, add);
|
|
129
|
+
composed(5); // (5 + 1) * 2 = 12
|
|
65
130
|
```
|
|
66
131
|
|
|
67
|
-
###
|
|
132
|
+
### LRU Cache Domain
|
|
68
133
|
|
|
69
|
-
|
|
134
|
+
```typescript
|
|
135
|
+
import { LRUCache } from '@pawells/typescript-common';
|
|
136
|
+
|
|
137
|
+
const cache = new LRUCache<string, number>(2);
|
|
138
|
+
cache.set('a', 1);
|
|
139
|
+
cache.set('b', 2);
|
|
140
|
+
cache.set('c', 3); // Evicts 'a' (least recently used)
|
|
141
|
+
|
|
142
|
+
console.log(cache.get('a')); // undefined
|
|
143
|
+
console.log(cache.get('b')); // 2
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Number Domain
|
|
70
147
|
|
|
71
148
|
```typescript
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
//
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
// Predicate functions as filter values
|
|
78
|
-
ObjectFilter(user, { age: (v) => v > 18 }); // true
|
|
79
|
-
ObjectFilter(user, { age: (v) => v < 18 }); // false
|
|
80
|
-
|
|
81
|
-
// Mix predicates and values
|
|
82
|
-
ObjectFilter(user, {
|
|
83
|
-
active: true,
|
|
84
|
-
age: (v) => v >= 21
|
|
85
|
-
}); // true
|
|
86
|
-
|
|
87
|
-
// Supports dot notation with predicates
|
|
88
|
-
const order = { user: { age: 25 }, total: 100 };
|
|
89
|
-
ObjectFilter(order, {
|
|
90
|
-
'user.age': (v) => v >= 21,
|
|
91
|
-
'total': (v) => v > 50
|
|
92
|
-
}); // true
|
|
149
|
+
import { AssertNumber, AssertFinite } from '@pawells/typescript-common';
|
|
150
|
+
|
|
151
|
+
AssertNumber(42); // Passes
|
|
152
|
+
AssertNumber('not a number'); // Throws
|
|
93
153
|
```
|
|
94
154
|
|
|
95
|
-
|
|
155
|
+
### Object Domain
|
|
156
|
+
|
|
157
|
+
```typescript
|
|
158
|
+
import {
|
|
159
|
+
ObjectClone,
|
|
160
|
+
ObjectEquals,
|
|
161
|
+
ObjectFilter,
|
|
162
|
+
ObjectPick,
|
|
163
|
+
ObjectOmit,
|
|
164
|
+
ObjectMerge,
|
|
165
|
+
ObjectHash,
|
|
166
|
+
} from '@pawells/typescript-common';
|
|
167
|
+
|
|
168
|
+
const original = { a: 1, b: { c: 2 } };
|
|
169
|
+
const cloned = ObjectClone(original);
|
|
96
170
|
|
|
97
|
-
|
|
171
|
+
const obj1 = { x: 1 };
|
|
172
|
+
const obj2 = { x: 1 };
|
|
173
|
+
console.log(ObjectEquals(obj1, obj2)); // true
|
|
98
174
|
|
|
99
|
-
|
|
100
|
-
|--------|-------------|
|
|
101
|
-
| `ArrayChunk(array, size)` | Split an array into chunks of a given size |
|
|
102
|
-
| `ArrayContains(array, predicate)` | Check if any element satisfies a predicate |
|
|
103
|
-
| `ArrayFilter(array, predicate)` | Type-safe array filter |
|
|
104
|
-
| `ArrayGroupBy(array, keyFn)` | Group array elements by a key function |
|
|
105
|
-
| `ArrayIntersection(a, b)` | Return elements present in both arrays |
|
|
106
|
-
| `ArrayShuffle(array, rng?)` | Return a shuffled copy of an array (optional custom RNG for deterministic results) |
|
|
107
|
-
| `ArraySample(array, n?, rng?)` | Random element or `n` random elements (optional custom RNG for deterministic results) |
|
|
108
|
-
| `Unique(array)` | Remove duplicate values |
|
|
109
|
-
| `ArrayDifference(a, b)` | Elements in `a` not present in `b` |
|
|
110
|
-
| `ArrayFlatten(array, depth?)` | Flatten a nested array to a given depth |
|
|
111
|
-
| `ArrayCompact(array)` | Remove `null`/`undefined`, narrowing the type |
|
|
112
|
-
| `ArrayPartition(array, predicate)` | Split into `[matches, rest]` |
|
|
113
|
-
| `ArrayZip(...arrays)` | Zip multiple arrays into tuples |
|
|
114
|
-
| `ArrayRange(start, end, step?)` | Generate a numeric sequence |
|
|
115
|
-
| `ArraySortBy(array, keyFn, direction?)` | Immutable sort by a computed key |
|
|
116
|
-
| `ArrayCountBy(array, keyFn)` | Count elements per group key |
|
|
117
|
-
| `AssertArray(value, args?, exception?)` | Assert value is an array (with optional size constraints) |
|
|
118
|
-
| `AssertArray2D(value, args?, exception?)` | Assert value is a rectangular 2D array |
|
|
119
|
-
| `AssertArrayNotEmpty(value, exception?)` | Assert array has at least one element |
|
|
120
|
-
| `AssertArrayAll(array, predicate, exception?)` | Assert every element satisfies a predicate |
|
|
121
|
-
| `AssertArrayAny(array, predicate, exception?)` | Assert at least one element satisfies a predicate |
|
|
122
|
-
|
|
123
|
-
### Boolean utilities — `BooleanUtils`
|
|
124
|
-
|
|
125
|
-
| Export | Description |
|
|
126
|
-
|--------|-------------|
|
|
127
|
-
| `AssertBoolean(value, exception?)` | Assert value is a boolean primitive |
|
|
175
|
+
const filtered = ObjectFilter({ a: 1, b: 2, c: 3 }, (v) => v > 1); // { b: 2, c: 3 }
|
|
128
176
|
|
|
129
|
-
|
|
177
|
+
const picked = ObjectPick({ a: 1, b: 2, c: 3 }, ['a', 'b']); // { a: 1, b: 2 }
|
|
130
178
|
|
|
131
|
-
|
|
132
|
-
|--------|-------------|
|
|
133
|
-
| `AssertNumber(value, args?, exception?)` | Assert value is a number with optional range/type constraints (`finite`, `integer`, `gt`, `gte`, `lt`, `lte`, `eq`) |
|
|
179
|
+
const omitted = ObjectOmit({ a: 1, b: 2, c: 3 }, ['c']); // { a: 1, b: 2 }
|
|
134
180
|
|
|
135
|
-
|
|
181
|
+
const merged = ObjectMerge({ a: 1 }, { b: 2 }); // { a: 1, b: 2 }
|
|
136
182
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
| `IsObject(value)` | Type-guard: returns `true` if value is a non-null, non-array object |
|
|
140
|
-
| `ObjectClone(obj)` | Deep-clone an object |
|
|
141
|
-
| `ObjectEquals(a, b)` | Deep equality check |
|
|
142
|
-
| `ObjectFilter(obj, filter, options?)` | Filter object by property values or predicate functions (supports dot notation, deep equality, case-insensitive matching, and predicate functions) |
|
|
143
|
-
| `ObjectFilterCached(options?)` | Returns a cached filter function for repeated filtering operations with optional deep equality and case-insensitive matching |
|
|
144
|
-
| `FilterObject(obj, keys)` | Keep only specified keys |
|
|
145
|
-
| `ObjectPick(obj, keys)` | Pick a subset of keys |
|
|
146
|
-
| `ObjectOmit(obj, keys)` | Omit specified keys |
|
|
147
|
-
| `ObjectMerge(target, ...sources)` | Deep merge objects |
|
|
148
|
-
| `MapObject(obj, fn)` | Map over object values |
|
|
149
|
-
| `MapObjectCached(options?)` | Returns a cached map function for repeated mapping operations with optional async support |
|
|
150
|
-
| `TransformObject(obj, fn)` | Transform object entries |
|
|
151
|
-
| `ObjectHash(obj)` | Compute a stable hash of an object |
|
|
152
|
-
| `ObjectSortKeys(obj)` | Return object with keys sorted |
|
|
153
|
-
| `ObjectFromKeyValuePairs(pairs)` | Build an object from `[key, value]` pairs |
|
|
154
|
-
| `ObjectToKeyValuePairs(obj)` | Convert an object to `[key, value]` pairs |
|
|
155
|
-
| `ObjectGetPropertyByPath(obj, path)` | Get a nested property by dot-path |
|
|
156
|
-
| `ObjectSetPropertyByPath(obj, path, value)` | Set a nested property by dot-path |
|
|
157
|
-
| `ObjectInvert(obj)` | Swap keys and values |
|
|
158
|
-
| `ObjectFlatten(obj, separator?)` | Flatten nested object to dot-separated keys |
|
|
159
|
-
| `ObjectDiff(objA, objB)` | Compute added/removed/changed keys between two objects |
|
|
160
|
-
| `ObjectHasCircularReference(obj)` | Detect circular references in an object |
|
|
161
|
-
| `CreateJsonCircularReplacer(placeholder?)` | Create a `JSON.stringify` replacer that handles circular refs |
|
|
162
|
-
| `AssertObject(value, exception?)` | Assert value is a plain object (not null, array, or function), narrowing to `Record<string, unknown>` |
|
|
163
|
-
| `AssertObjectHasProperty(value, property, exception?)` | Assert object has an inherited or own property |
|
|
164
|
-
| `AssertObjectHasOwnProperty(value, property, exception?)` | Assert object has a direct own property |
|
|
165
|
-
| `AssertObjectPropertyNotNull(value, property, exception?)` | Assert object property is not null/undefined |
|
|
166
|
-
|
|
167
|
-
### String utilities — `StringUtils`
|
|
168
|
-
|
|
169
|
-
| Export | Description |
|
|
170
|
-
|--------|-------------|
|
|
171
|
-
| `CamelCase(str)` | Convert a string to camelCase |
|
|
172
|
-
| `Capitalize(str)` | Capitalize the first letter of a string |
|
|
173
|
-
| `PascalCase(str)` | Convert a string to PascalCase |
|
|
174
|
-
| `KebabCase(str)` | Convert a string to kebab-case |
|
|
175
|
-
| `SnakeCase(str)` | Convert a string to snake_case |
|
|
176
|
-
| `ScreamingSnakeCase(str)` | Convert a string to SCREAMING_SNAKE_CASE |
|
|
177
|
-
| `FormatString(template, values)` | Simple string template formatting |
|
|
178
|
-
| `TruncateString(str, maxLength, ellipsis?)` | Truncate a string with ellipsis |
|
|
179
|
-
| `PadString(str, length, char?, padEnd?)` | Pad a string to a specified length |
|
|
180
|
-
| `EscapeHTML(str)` | Escape HTML special characters |
|
|
181
|
-
| `StripHTML(str)` | Remove all HTML tags from a string |
|
|
182
|
-
| `Pluralize(word, count, plural?)` | Return singular or plural form based on count |
|
|
183
|
-
| `WordCount(str)` | Count the number of words in a string |
|
|
184
|
-
| `CountOccurrences(str, substr)` | Count non-overlapping occurrences of a substring |
|
|
185
|
-
| `ReverseString(str)` | Reverse a string |
|
|
186
|
-
| `Slugify(str)` | Convert a string to a URL-friendly slug |
|
|
187
|
-
| `IsBlankString(str)` | Check if a string is empty or whitespace-only |
|
|
188
|
-
| `IsHexString(str)` | Check if a string is a valid hexadecimal value |
|
|
189
|
-
| `StringEquals(a, b, caseInsensitive?)` | Compare two strings with optional case-insensitive matching |
|
|
190
|
-
| `AssertString(value, exception?)` | Assert value is a string primitive |
|
|
191
|
-
| `AssertStringNotEmpty(value, exception?)` | Assert value is a non-empty, non-whitespace string |
|
|
192
|
-
| `AssertStringMatches(value, regex, exception?)` | Assert string matches a regular expression |
|
|
193
|
-
|
|
194
|
-
### Time utilities — `TimeUtils`
|
|
195
|
-
|
|
196
|
-
| Export | Description |
|
|
197
|
-
|--------|-------------|
|
|
198
|
-
| `ElapsedTime` | Class for measuring elapsed time with human-readable output |
|
|
199
|
-
| `FormatElapsedTime(ms, options?)` | Format milliseconds using concise format |
|
|
200
|
-
| `Stopwatch` | Lap-based stopwatch for benchmarking |
|
|
183
|
+
const hash = ObjectHash({ a: 1, b: 2 }); // 'e4f3...'
|
|
184
|
+
```
|
|
201
185
|
|
|
202
|
-
###
|
|
186
|
+
### String Domain
|
|
203
187
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
188
|
+
```typescript
|
|
189
|
+
import {
|
|
190
|
+
CamelCase,
|
|
191
|
+
PascalCase,
|
|
192
|
+
KebabCase,
|
|
193
|
+
SnakeCase,
|
|
194
|
+
EscapeHTML,
|
|
195
|
+
TruncateString,
|
|
196
|
+
StringEquals,
|
|
197
|
+
} from '@pawells/typescript-common';
|
|
212
198
|
|
|
213
|
-
|
|
199
|
+
console.log(CamelCase('hello-world')); // 'helloWorld'
|
|
200
|
+
console.log(PascalCase('hello-world')); // 'HelloWorld'
|
|
201
|
+
console.log(KebabCase('helloWorld')); // 'hello-world'
|
|
202
|
+
console.log(SnakeCase('helloWorld')); // 'hello_world'
|
|
214
203
|
|
|
215
|
-
|
|
216
|
-
|--------|-------------|
|
|
217
|
-
| `Debounce(fn, ms)` | Delay execution until `ms` ms after the last call |
|
|
218
|
-
| `Throttle(fn, ms)` | Limit execution to at most once per `ms` ms |
|
|
219
|
-
| `Memoize(fn, keyFn?)` | Cache results by serialised arguments |
|
|
220
|
-
| `Once(fn)` | Execute a function at most once, caching the result |
|
|
221
|
-
| `Pipe(...fns)` | Compose functions left-to-right |
|
|
222
|
-
| `Compose(...fns)` | Compose functions right-to-left |
|
|
223
|
-
| `Sleep(ms)` | Return a `Promise` that resolves after `ms` ms |
|
|
204
|
+
console.log(EscapeHTML('<script>alert("xss")</script>')); // '<script>...'
|
|
224
205
|
|
|
225
|
-
|
|
206
|
+
console.log(TruncateString('Hello World', 8)); // 'Hello...'
|
|
226
207
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
208
|
+
console.log(StringEquals('hello', 'HELLO', true)); // true (case-insensitive)
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Time Domain
|
|
230
212
|
|
|
231
213
|
```typescript
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
214
|
+
import { ElapsedTime, Stopwatch } from '@pawells/typescript-common';
|
|
215
|
+
|
|
216
|
+
// Elapsed time value object
|
|
217
|
+
const elapsed = new ElapsedTime(5000); // 5 seconds
|
|
218
|
+
console.log(elapsed.seconds()); // 5
|
|
219
|
+
console.log(elapsed.toString()); // '5.00s'
|
|
220
|
+
|
|
221
|
+
// Stopwatch for timing events
|
|
222
|
+
const stopwatch = new Stopwatch();
|
|
223
|
+
stopwatch.start();
|
|
224
|
+
// ... do work ...
|
|
225
|
+
stopwatch.stop();
|
|
226
|
+
console.log(stopwatch.elapsed().toString()); // Duration of work
|
|
237
227
|
```
|
|
238
228
|
|
|
239
|
-
|
|
229
|
+
## API Reference
|
|
240
230
|
|
|
241
|
-
|
|
231
|
+
### Array
|
|
242
232
|
|
|
243
|
-
|
|
|
233
|
+
| Symbol | Description |
|
|
244
234
|
|--------|-------------|
|
|
245
|
-
| `
|
|
246
|
-
| `
|
|
247
|
-
| `
|
|
248
|
-
| `
|
|
249
|
-
| `
|
|
250
|
-
| `
|
|
251
|
-
| `
|
|
252
|
-
| `
|
|
253
|
-
| `
|
|
254
|
-
| `
|
|
255
|
-
| `
|
|
256
|
-
| `
|
|
257
|
-
| `
|
|
235
|
+
| `ArrayChunk` | Splits an array into fixed-size chunks |
|
|
236
|
+
| `ArrayCompact` | Removes null and undefined values from an array |
|
|
237
|
+
| `ArrayContains` | Checks if array contains element matching predicate |
|
|
238
|
+
| `ArrayDifference` | Returns elements in first array but not in second |
|
|
239
|
+
| `ArrayFilter` | Filters array by object criteria or predicate function |
|
|
240
|
+
| `ArrayFlatten` | Flattens nested arrays to specified depth |
|
|
241
|
+
| `ArrayGroupBy` | Groups array elements by a key function |
|
|
242
|
+
| `ArrayIntersection` | Returns elements present in all arrays |
|
|
243
|
+
| `ArrayPartition` | Splits array into two based on predicate |
|
|
244
|
+
| `ArrayRange` | Generates array of numbers in range |
|
|
245
|
+
| `ArraySample` | Returns random element(s) from array |
|
|
246
|
+
| `ArrayShuffle` | Returns shuffled copy of array |
|
|
247
|
+
| `ArraySortBy` | Sorts array by key function with optional comparator |
|
|
248
|
+
| `ArrayCountBy` | Counts elements grouped by key function |
|
|
249
|
+
| `ArrayZip` | Combines multiple arrays element-wise |
|
|
250
|
+
| `Unique` | Returns array with duplicate elements removed |
|
|
251
|
+
| `TPredicate` | Type for predicate function: `(value: T) => boolean` |
|
|
252
|
+
| `TTransform` | Type for transform function: `(input: T) => U` |
|
|
253
|
+
| `TComparator` | Type for comparator: `(a: T, b: T) => number` |
|
|
254
|
+
| `TEqualityComparator` | Type for equality: `(a: T, b: T) => boolean` |
|
|
255
|
+
|
|
256
|
+
### Asserts
|
|
257
|
+
|
|
258
|
+
| Symbol | Description |
|
|
259
|
+
|--------|-------------|
|
|
260
|
+
| `AssertEquals` | Asserts two values are strictly equal |
|
|
261
|
+
| `AssertNotEquals` | Asserts two values are not strictly equal |
|
|
262
|
+
| `AssertNull` | Asserts value is null |
|
|
263
|
+
| `AssertNotNull` | Asserts value is not null |
|
|
264
|
+
| `AssertPredicate` | Asserts value satisfies predicate function |
|
|
265
|
+
| `AssertIsType` | Asserts value is of specific type |
|
|
266
|
+
| `AssertInstanceOf` | Asserts value is instance of class/constructor |
|
|
267
|
+
| `AssertFunction` | Asserts value is a function |
|
|
268
|
+
| `AssertSymbol` | Asserts value is a symbol |
|
|
269
|
+
| `AssertExtends` | Asserts value extends interface type |
|
|
270
|
+
| `AssertArray` | Asserts value is an array |
|
|
271
|
+
| `AssertBoolean` | Asserts value is a boolean |
|
|
272
|
+
| `AssertNumber` | Asserts value is a number |
|
|
273
|
+
| `AssertFinite` | Asserts value is a finite number |
|
|
274
|
+
| `AssertObject` | Asserts value is a plain object |
|
|
275
|
+
| `AssertString` | Asserts value is a string |
|
|
276
|
+
| `AssertStringNotEmpty` | Asserts value is non-empty string |
|
|
277
|
+
| `AssertObjectHasProperty` | Asserts object has property (including inherited) |
|
|
278
|
+
| `AssertObjectHasOwnProperty` | Asserts object has own property |
|
|
279
|
+
| `NullError` | Custom error for null assertion failure |
|
|
280
|
+
| `NotNullError` | Custom error for not-null assertion failure |
|
|
281
|
+
| `PredicateError` | Custom error for predicate assertion failure |
|
|
282
|
+
| `TypeGuardError` | Custom error for type guard assertion failure |
|
|
283
|
+
| `InstanceOfError` | Custom error for instanceof assertion failure |
|
|
284
|
+
| `ExtendsError` | Custom error for type extends assertion failure |
|
|
285
|
+
|
|
286
|
+
### Boolean
|
|
287
|
+
|
|
288
|
+
| Symbol | Description |
|
|
289
|
+
|--------|-------------|
|
|
290
|
+
| `AssertBoolean` | Asserts value is a boolean |
|
|
258
291
|
|
|
259
|
-
|
|
292
|
+
### Enum
|
|
260
293
|
|
|
261
|
-
|
|
294
|
+
| Symbol | Description |
|
|
295
|
+
|--------|-------------|
|
|
296
|
+
| `EnumKeys` | Returns array of enum keys |
|
|
297
|
+
| `EnumValues` | Returns array of enum values |
|
|
298
|
+
| `EnumEntries` | Returns array of [key, value] tuples |
|
|
299
|
+
| `EnumKeyByValue` | Looks up enum key by value |
|
|
300
|
+
| `ValidateEnumValue` | Checks if value is valid enum member |
|
|
301
|
+
| `EnumSafeValue` | Returns value if valid enum member, else fallback |
|
|
262
302
|
|
|
263
|
-
|
|
303
|
+
### Function
|
|
264
304
|
|
|
265
|
-
|
|
305
|
+
| Symbol | Description |
|
|
306
|
+
|--------|-------------|
|
|
307
|
+
| `Debounce` | Delays function execution until after time period with no calls |
|
|
308
|
+
| `Throttle` | Limits function execution to at most once per time period |
|
|
309
|
+
| `Memoize` | Caches function results by serialized arguments (LRU eviction) |
|
|
310
|
+
| `Once` | Returns wrapper that executes function at most once |
|
|
311
|
+
| `Compose` | Creates right-to-left function composition |
|
|
312
|
+
| `Sleep` | Returns promise that resolves after delay |
|
|
313
|
+
|
|
314
|
+
> **⚠️ Security Warning — Memoize**
|
|
315
|
+
>
|
|
316
|
+
> Do not memoize functions with sensitive parameters (passwords, tokens, API keys). The cache stores return values keyed by serialized arguments, which could expose sensitive data if the cache is inspected or if the key function inadvertently includes sensitive data.
|
|
317
|
+
>
|
|
318
|
+
> For functions handling sensitive data, consider:
|
|
319
|
+
> - Not memoizing at all
|
|
320
|
+
> - Using a custom key function that excludes sensitive parameters
|
|
321
|
+
> - Implementing manual cache invalidation after processing sensitive data
|
|
322
|
+
>
|
|
323
|
+
> See JSDoc `@warning` in source for full details.
|
|
324
|
+
|
|
325
|
+
### LRU Cache
|
|
326
|
+
|
|
327
|
+
| Symbol | Description |
|
|
328
|
+
|--------|-------------|
|
|
329
|
+
| `LRUCache` | Generic Least Recently Used cache with fixed capacity |
|
|
330
|
+
|
|
331
|
+
> **⚠️ Security Warning — LRU Cache**
|
|
332
|
+
>
|
|
333
|
+
> Do not cache sensitive objects (API keys, tokens, passwords, PII). Cache entries remain in memory until evicted or cleared. If the cache is inspected (via debugger, memory dump, or compromised process), sensitive values will be exposed.
|
|
334
|
+
>
|
|
335
|
+
> For sensitive data, prefer:
|
|
336
|
+
> - Ephemeral processing without caching
|
|
337
|
+
> - Implementing automatic expiration
|
|
338
|
+
> - Secure clearing (e.g., overwrite before eviction)
|
|
339
|
+
>
|
|
340
|
+
> See JSDoc `@warning` in source for full details.
|
|
341
|
+
|
|
342
|
+
### Number
|
|
343
|
+
|
|
344
|
+
| Symbol | Description |
|
|
345
|
+
|--------|-------------|
|
|
346
|
+
| `AssertNumber` | Asserts value is a number |
|
|
347
|
+
| `AssertFinite` | Asserts value is a finite number |
|
|
266
348
|
|
|
267
|
-
|
|
349
|
+
### Object
|
|
268
350
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
351
|
+
| Symbol | Description |
|
|
352
|
+
|--------|-------------|
|
|
353
|
+
| `ObjectClone` | Deep clones object with circular reference detection |
|
|
354
|
+
| `TransformObject` | Transforms object using visitor pattern |
|
|
355
|
+
| `ObjectEquals` | Deep equality comparison for objects |
|
|
356
|
+
| `ObjectFilter` | Filters object properties by predicate |
|
|
357
|
+
| `FilterObject` | Variant of ObjectFilter |
|
|
358
|
+
| `ObjectFilterCached` | Filters object with caching |
|
|
359
|
+
| `MapObject` | Maps object values by transform function |
|
|
360
|
+
| `MapObjectCached` | Maps object with caching |
|
|
361
|
+
| `ObjectHash` | Generates hash for object |
|
|
362
|
+
| `ObjectGetPropertyByPath` | Gets property value by dot-notation path |
|
|
363
|
+
| `ObjectSetPropertyByPath` | Sets property value by dot-notation path |
|
|
364
|
+
| `ObjectSortKeys` | Returns object with keys sorted |
|
|
365
|
+
| `ObjectFromKeyValuePairs` | Creates object from [key, value] tuples |
|
|
366
|
+
| `ObjectToKeyValuePairs` | Converts object to [key, value] tuples |
|
|
367
|
+
| `ObjectPick` | Returns new object with selected keys |
|
|
368
|
+
| `ObjectOmit` | Returns new object without selected keys |
|
|
369
|
+
| `ObjectMerge` | Shallowly merges objects |
|
|
370
|
+
| `IsObject` | Type guard for plain objects |
|
|
371
|
+
| `ObjectInvert` | Inverts object keys and values |
|
|
372
|
+
| `ObjectFlatten` | Flattens nested object to dot-notation keys |
|
|
373
|
+
| `ObjectDiff` | Computes differences between two objects |
|
|
374
|
+
| `ObjectHasCircularReference` | Detects circular references |
|
|
375
|
+
| `CreateJsonCircularReplacer` | Creates replacer for JSON.stringify with circular refs |
|
|
376
|
+
| `IsPropertyKeySafe` | Checks if property key is safe (not prototype-pollution) |
|
|
377
|
+
| `IsPropertyPathSafe` | Checks if property path is safe |
|
|
378
|
+
| `SanitizePropertyKey` | Removes dangerous characters from key |
|
|
379
|
+
| `FilterDangerousKeys` | Filters dangerous keys from object |
|
|
380
|
+
| `CreateCircularReferenceDetector` | Creates detector for circular references |
|
|
381
|
+
| `IsInputSafe` | Comprehensive input safety check |
|
|
382
|
+
|
|
383
|
+
### String
|
|
384
|
+
|
|
385
|
+
| Symbol | Description |
|
|
386
|
+
|--------|-------------|
|
|
387
|
+
| `CamelCase` | Converts string to camelCase |
|
|
388
|
+
| `PascalCase` | Converts string to PascalCase |
|
|
389
|
+
| `KebabCase` | Converts string to kebab-case |
|
|
390
|
+
| `SnakeCase` | Converts string to snake_case |
|
|
391
|
+
| `EscapeHTML` | Escapes HTML special characters |
|
|
392
|
+
| `StripHTML` | Removes HTML tags from string |
|
|
393
|
+
| `FormatString` | Formats string using template parameters |
|
|
394
|
+
| `TruncateString` | Truncates string to max length with ellipsis |
|
|
395
|
+
| `PadString` | Pads string to length with character |
|
|
396
|
+
| `Pluralize` | Returns plural form based on count |
|
|
397
|
+
| `WordCount` | Counts words in string |
|
|
398
|
+
| `CountOccurrences` | Counts occurrences of substring |
|
|
399
|
+
| `StringEquals` | Case-sensitive or case-insensitive equality |
|
|
400
|
+
| `IsEmpty` | Checks if string is empty or whitespace only |
|
|
401
|
+
| `AssertString` | Asserts value is a string |
|
|
402
|
+
| `AssertStringNotEmpty` | Asserts value is non-empty string |
|
|
403
|
+
|
|
404
|
+
### Time
|
|
405
|
+
|
|
406
|
+
| Symbol | Description |
|
|
407
|
+
|--------|-------------|
|
|
408
|
+
| `ElapsedTime` | Value object representing duration in milliseconds |
|
|
409
|
+
| `Stopwatch` | Utility for recording timestamped events and intervals |
|
|
410
|
+
| `StopwatchEntry` | Represents single stopwatch event (start, stop, lap, etc.) |
|
|
281
411
|
|
|
282
|
-
|
|
412
|
+
### Iterators
|
|
413
|
+
|
|
414
|
+
| Symbol | Description |
|
|
415
|
+
|--------|-------------|
|
|
416
|
+
| `FilteredIterator` | Async generator that filters array elements based on a predicate and optional filter criteria |
|
|
417
|
+
|
|
418
|
+
### Zod Utilities
|
|
283
419
|
|
|
284
|
-
-
|
|
420
|
+
Pre-built Zod schemas and types for common runtime validation scenarios.
|
|
421
|
+
|
|
422
|
+
| Symbol | Description |
|
|
423
|
+
|--------|-------------|
|
|
424
|
+
| `OBJECT_ID_SCHEMA` | Zod schema for MongoDB ObjectId validation (24-char hex string) |
|
|
425
|
+
| `TObjectId` | Type inferred from OBJECT_ID_SCHEMA; represents valid ObjectId string |
|
|
426
|
+
| `SEMVER_SCHEMA` | Zod schema for semantic version validation; transforms to SemVer instance |
|
|
427
|
+
| `TZodObjectSchema` | Type for Zod object schema instances; result of z.object() |
|
|
428
|
+
| `JSON_SERIALIZABLE_SCHEMA` | Zod schema for generic JSON-serializable values (primitives, arrays, objects) |
|
|
429
|
+
| `TJSONSerializable` | Recursive type for JSON-serializable values (excludes undefined and functions) |
|
|
430
|
+
| `JSON_OBJECT_SCHEMA` | Zod schema for JSON objects with string keys and serializable values |
|
|
431
|
+
| `JSON_DATE_SCHEMA` | Zod schema for date strings; transforms to Date instances |
|
|
285
432
|
|
|
286
433
|
## License
|
|
287
434
|
|
|
288
|
-
MIT — See [LICENSE](
|
|
435
|
+
MIT — See [LICENSE](../../LICENSE) for details.
|