@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
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { LRUCache } from '../lru-cache.js';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a memoized version of `fn` that caches results by serialising its
|
|
4
|
+
* arguments with `JSON.stringify` (or a custom `keyFn`).
|
|
5
|
+
*
|
|
6
|
+
* Only suitable for **pure functions** with serialisable arguments.
|
|
7
|
+
*
|
|
8
|
+
* Uses an LRU (Least Recently Used) eviction policy: when the cache reaches
|
|
9
|
+
* `maxCacheSize`, the entry that was accessed least recently is evicted.
|
|
10
|
+
*
|
|
11
|
+
* @template T - The function type to memoize
|
|
12
|
+
* @param fn - The function to memoize
|
|
13
|
+
* @param keyFn - Optional custom cache key function. If not provided, arguments are serialized with JSON.stringify
|
|
14
|
+
* @param maxCacheSize - Maximum number of cached results before LRU eviction (default: 1000)
|
|
15
|
+
* @returns A memoized function with the same signature as `fn`
|
|
16
|
+
*
|
|
17
|
+
* @warning Do not memoize functions with sensitive parameters (passwords, tokens, API keys).
|
|
18
|
+
* The cache stores return values keyed by serialized arguments, which could expose sensitive
|
|
19
|
+
* data if the cache is inspected or if the keyFn inadvertently includes sensitive data
|
|
20
|
+
* in the cache key. For functions handling sensitive data, consider:
|
|
21
|
+
* - Not memoizing at all
|
|
22
|
+
* - Using a custom keyFn that excludes sensitive parameters
|
|
23
|
+
* - Implementing manual cache invalidation after processing sensitive data
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* const expensiveCalc = Memoize((n: number) => n * n);
|
|
28
|
+
* expensiveCalc(4); // computed
|
|
29
|
+
* expensiveCalc(4); // cached → same value returned immediately
|
|
30
|
+
*
|
|
31
|
+
* // Custom key function:
|
|
32
|
+
* const getUser = Memoize(fetchUser, (id) => `user:${id}`);
|
|
33
|
+
*
|
|
34
|
+
* // With custom cache size:
|
|
35
|
+
* const cached = Memoize(fn, undefined, 500);
|
|
36
|
+
*
|
|
37
|
+
* const add = (a: number, b: number) => a + b;
|
|
38
|
+
* const cachedAdd = Memoize(add);
|
|
39
|
+
* console.log(cachedAdd(1, 2)); // Computes: 3
|
|
40
|
+
* console.log(cachedAdd(1, 2)); // Returns cached result: 3
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
/**
|
|
44
|
+
* Memoizes a function using an LRU cache.
|
|
45
|
+
*
|
|
46
|
+
* @remarks
|
|
47
|
+
* - Default key function uses JSON.stringify(args)
|
|
48
|
+
* - Non-serializable arguments (functions, symbols, circular refs) will produce incorrect cache behavior
|
|
49
|
+
* - Supply a custom `keyFn` for non-serializable arguments or for content-addressed keys
|
|
50
|
+
*
|
|
51
|
+
* @param fn - The function to memoize
|
|
52
|
+
* @param keyFn - Optional custom cache key function; defaults to JSON.stringify(args)
|
|
53
|
+
* @param maxCacheSize - Maximum number of entries in the cache; defaults to 1000
|
|
54
|
+
* @returns Memoized version of the function
|
|
55
|
+
*/
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
|
+
export function Memoize(fn, keyFn, maxCacheSize = 1000) {
|
|
58
|
+
const cache = new LRUCache(maxCacheSize);
|
|
59
|
+
return function memoized(...args) {
|
|
60
|
+
const key = keyFn ? keyFn(...args) : JSON.stringify(args);
|
|
61
|
+
if (cache.has(key)) {
|
|
62
|
+
// PERFORMANCE NOTE: LRUCache.get() calls Map.delete() + Map.set() on every cache hit.
|
|
63
|
+
// For read-heavy workloads, tracking access timestamps would be faster than
|
|
64
|
+
// the delete/reinsert pattern. This is correct for LRU semantics but can be slow
|
|
65
|
+
// for hot cache entries accessed thousands of times per second.
|
|
66
|
+
return cache.get(key);
|
|
67
|
+
}
|
|
68
|
+
const result = fn(...args);
|
|
69
|
+
cache.set(key, result);
|
|
70
|
+
return result;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"once.d.ts","sourceRoot":"","sources":["../../src/function/once.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;
|
|
1
|
+
{"version":3,"file":"once.d.ts","sourceRoot":"","sources":["../../src/function/once.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,wBAAgB,IAAI,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAsBhE"}
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* init(); // no-op — returns cached result
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
18
|
export function Once(fn) {
|
|
18
19
|
let called = false;
|
|
19
20
|
let result;
|
|
@@ -37,4 +38,3 @@ export function Once(fn) {
|
|
|
37
38
|
return result;
|
|
38
39
|
};
|
|
39
40
|
}
|
|
40
|
-
//# sourceMappingURL=once.js.map
|
|
@@ -3,6 +3,13 @@ import type { TAnyFunction } from './types.js';
|
|
|
3
3
|
* Creates a throttled version of `fn` that invokes at most once per `ms`
|
|
4
4
|
* milliseconds, guaranteeing the final call in a burst is also executed.
|
|
5
5
|
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Throttle differs from debounce in that it **rate-limits execution** to at most
|
|
8
|
+
* once per `ms` milliseconds. The function executes immediately on the first call,
|
|
9
|
+
* and subsequent calls are batched; the final pending call always executes. Debounce,
|
|
10
|
+
* by contrast, **delays execution** until `ms` milliseconds of silence have elapsed
|
|
11
|
+
* and resets the timer on each call.
|
|
12
|
+
*
|
|
6
13
|
* @template T - The wrapped function type
|
|
7
14
|
* @param fn - The function to throttle
|
|
8
15
|
* @param ms - Minimum interval in milliseconds between invocations
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"throttle.d.ts","sourceRoot":"","sources":["../../src/function/throttle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,YAAY,EAC9C,EAAE,EAAE,CAAC,EACL,EAAE,EAAE,MAAM,GACR,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAuBlC"}
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
* Creates a throttled version of `fn` that invokes at most once per `ms`
|
|
3
3
|
* milliseconds, guaranteeing the final call in a burst is also executed.
|
|
4
4
|
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Throttle differs from debounce in that it **rate-limits execution** to at most
|
|
7
|
+
* once per `ms` milliseconds. The function executes immediately on the first call,
|
|
8
|
+
* and subsequent calls are batched; the final pending call always executes. Debounce,
|
|
9
|
+
* by contrast, **delays execution** until `ms` milliseconds of silence have elapsed
|
|
10
|
+
* and resets the timer on each call.
|
|
11
|
+
*
|
|
5
12
|
* @template T - The wrapped function type
|
|
6
13
|
* @param fn - The function to throttle
|
|
7
14
|
* @param ms - Minimum interval in milliseconds between invocations
|
|
@@ -36,4 +43,3 @@ export function Throttle(fn, ms) {
|
|
|
36
43
|
}
|
|
37
44
|
};
|
|
38
45
|
}
|
|
39
|
-
//# sourceMappingURL=throttle.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Any function signature.
|
|
3
|
+
*
|
|
4
|
+
* A type alias for functions accepting any arguments and returning any type.
|
|
5
|
+
* Used throughout the function domain for function wrappers and utilities
|
|
6
|
+
* that operate on generic functions without type-specific constraints.
|
|
7
|
+
*/
|
|
8
|
+
export type TAnyFunction = (...args: any[]) => any;
|
|
9
|
+
/**
|
|
10
|
+
* Any async function signature.
|
|
11
|
+
*
|
|
12
|
+
* A type alias for async functions accepting any arguments and returning
|
|
13
|
+
* a Promise of the specified generic type (default `void`).
|
|
14
|
+
*
|
|
15
|
+
* @template T - The resolved value type of the returned Promise (default `void`)
|
|
16
|
+
*/
|
|
17
|
+
export type TAsyncFunction<T = void> = (...args: any[]) => Promise<T>;
|
|
18
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/function/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AAEnD;;;;;;;GAOG;AAEH,MAAM,MAAM,cAAc,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from './lru-cache.js';
|
|
2
|
+
export * from './array/index.js';
|
|
3
|
+
export * from './asserts/index.js';
|
|
4
|
+
export * from './boolean/index.js';
|
|
5
|
+
export * from './enum/index.js';
|
|
6
|
+
export * from './function/index.js';
|
|
7
|
+
export * from './number/index.js';
|
|
8
|
+
export * from './object/index.js';
|
|
9
|
+
export * from './string/index.js';
|
|
10
|
+
export * from './time/index.js';
|
|
11
|
+
export * from './array/iterators.js';
|
|
12
|
+
export * from './json.sanitization.js';
|
|
13
|
+
export * from './zod-util.js';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './lru-cache.js';
|
|
2
|
+
export * from './array/index.js';
|
|
3
|
+
export * from './asserts/index.js';
|
|
4
|
+
export * from './boolean/index.js';
|
|
5
|
+
export * from './enum/index.js';
|
|
6
|
+
export * from './function/index.js';
|
|
7
|
+
export * from './number/index.js';
|
|
8
|
+
export * from './object/index.js';
|
|
9
|
+
export * from './string/index.js';
|
|
10
|
+
export * from './time/index.js';
|
|
11
|
+
export * from './array/iterators.js';
|
|
12
|
+
export * from './json.sanitization.js';
|
|
13
|
+
export * from './zod-util.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sanitizes a JSON Schema object by recursively removing all keys that start with "$".
|
|
3
|
+
* This prevents Mongoose Map field errors when storing JSON Schema definitions with
|
|
4
|
+
* metadata properties like $schema, $id, $defs, etc.
|
|
5
|
+
*
|
|
6
|
+
* @param schema - The JSON Schema object to sanitize
|
|
7
|
+
* @returns The sanitized schema object with all "$"-prefixed keys removed
|
|
8
|
+
* @example
|
|
9
|
+
* const schema = { type: 'object', $schema: 'http://...', properties: { ... } };
|
|
10
|
+
* const clean = SanitizeJsonSchema(schema);
|
|
11
|
+
* // Result: { type: 'object', properties: { ... } }
|
|
12
|
+
*/
|
|
13
|
+
export declare function SanitizeJsonSchema(schema: unknown): Record<string, unknown>;
|
|
14
|
+
//# sourceMappingURL=json.sanitization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.sanitization.d.ts","sourceRoot":"","sources":["../src/json.sanitization.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAM3E"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sanitizes a JSON Schema object by recursively removing all keys that start with "$".
|
|
3
|
+
* This prevents Mongoose Map field errors when storing JSON Schema definitions with
|
|
4
|
+
* metadata properties like $schema, $id, $defs, etc.
|
|
5
|
+
*
|
|
6
|
+
* @param schema - The JSON Schema object to sanitize
|
|
7
|
+
* @returns The sanitized schema object with all "$"-prefixed keys removed
|
|
8
|
+
* @example
|
|
9
|
+
* const schema = { type: 'object', $schema: 'http://...', properties: { ... } };
|
|
10
|
+
* const clean = SanitizeJsonSchema(schema);
|
|
11
|
+
* // Result: { type: 'object', properties: { ... } }
|
|
12
|
+
*/
|
|
13
|
+
export function SanitizeJsonSchema(schema) {
|
|
14
|
+
const result = sanitizeJsonSchemaInternal(schema);
|
|
15
|
+
if (typeof result === 'object' && result !== null && !Array.isArray(result)) {
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
function sanitizeJsonSchemaInternal(schema) {
|
|
21
|
+
if (schema === null || schema === undefined) {
|
|
22
|
+
return schema;
|
|
23
|
+
}
|
|
24
|
+
if (Array.isArray(schema)) {
|
|
25
|
+
return schema.map((item) => sanitizeJsonSchemaInternal(item));
|
|
26
|
+
}
|
|
27
|
+
if (typeof schema !== 'object') {
|
|
28
|
+
return schema;
|
|
29
|
+
}
|
|
30
|
+
const cleanSchema = {};
|
|
31
|
+
for (const [key, value] of Object.entries(schema)) {
|
|
32
|
+
if (!key.startsWith('$')) {
|
|
33
|
+
cleanSchema[key] = sanitizeJsonSchemaInternal(value);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return cleanSchema;
|
|
37
|
+
}
|
|
@@ -8,6 +8,12 @@
|
|
|
8
8
|
* @typeParam K - Key type
|
|
9
9
|
* @typeParam V - Value type
|
|
10
10
|
*
|
|
11
|
+
* @warning Do not cache sensitive objects (API keys, tokens, passwords, PII).
|
|
12
|
+
* Cache entries remain in memory until evicted or cleared. If cache is inspected
|
|
13
|
+
* (via debugger, memory dump, or compromised process), sensitive values will be exposed.
|
|
14
|
+
* For sensitive data, prefer ephemeral processing without caching, or implement
|
|
15
|
+
* automatic expiration and secure clearing (e.g., overwrite before eviction).
|
|
16
|
+
*
|
|
11
17
|
* @example
|
|
12
18
|
* ```typescript
|
|
13
19
|
* const cache = new LRUCache<string, number>(2);
|
|
@@ -46,6 +52,12 @@ export declare class LRUCache<K, V> {
|
|
|
46
52
|
* @param key - The key to look up
|
|
47
53
|
* @returns The cached value, or `undefined` if not found
|
|
48
54
|
*
|
|
55
|
+
* @remarks
|
|
56
|
+
* Each cache hit triggers an internal Map delete and re-insert operation to maintain
|
|
57
|
+
* LRU order. This is O(1) amortized, but introduces per-access overhead.
|
|
58
|
+
* For read-heavy workloads, consider a timestamp-based LRU approach to reduce
|
|
59
|
+
* per-access cost, though it adds space overhead for timestamp storage.
|
|
60
|
+
*
|
|
49
61
|
* @example
|
|
50
62
|
* ```typescript
|
|
51
63
|
* const cache = new LRUCache<string, number>(2);
|
|
@@ -101,5 +113,12 @@ export declare class LRUCache<K, V> {
|
|
|
101
113
|
* ```
|
|
102
114
|
*/
|
|
103
115
|
clear(): void;
|
|
116
|
+
/**
|
|
117
|
+
* Removes a specific key from the cache.
|
|
118
|
+
*
|
|
119
|
+
* @param key - The key to delete
|
|
120
|
+
* @returns `true` if the key existed and was deleted, `false` otherwise
|
|
121
|
+
*/
|
|
122
|
+
delete(key: K): boolean;
|
|
104
123
|
}
|
|
105
124
|
//# sourceMappingURL=lru-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lru-cache.d.ts","sourceRoot":"","sources":["../src/lru-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,QAAQ,CAAC,CAAC,EAAE,CAAC;IACzB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAmB;IAExC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAElC;;;;;;;;;;OAUG;gBACS,OAAO,EAAE,MAAM;IAO3B;;OAEG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACI,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS;IAajC;;;;;;;;;;;;;OAaG;IACI,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO;IAI3B;;;;;;;;;;;;;;;;;OAiBG;IACI,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAgBlC;;;;;;;;;;OAUG;IACI,KAAK,IAAI,IAAI;IAIpB;;;;;OAKG;IACI,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO;CAG9B"}
|
|
@@ -8,6 +8,12 @@
|
|
|
8
8
|
* @typeParam K - Key type
|
|
9
9
|
* @typeParam V - Value type
|
|
10
10
|
*
|
|
11
|
+
* @warning Do not cache sensitive objects (API keys, tokens, passwords, PII).
|
|
12
|
+
* Cache entries remain in memory until evicted or cleared. If cache is inspected
|
|
13
|
+
* (via debugger, memory dump, or compromised process), sensitive values will be exposed.
|
|
14
|
+
* For sensitive data, prefer ephemeral processing without caching, or implement
|
|
15
|
+
* automatic expiration and secure clearing (e.g., overwrite before eviction).
|
|
16
|
+
*
|
|
11
17
|
* @example
|
|
12
18
|
* ```typescript
|
|
13
19
|
* const cache = new LRUCache<string, number>(2);
|
|
@@ -53,6 +59,12 @@ export class LRUCache {
|
|
|
53
59
|
* @param key - The key to look up
|
|
54
60
|
* @returns The cached value, or `undefined` if not found
|
|
55
61
|
*
|
|
62
|
+
* @remarks
|
|
63
|
+
* Each cache hit triggers an internal Map delete and re-insert operation to maintain
|
|
64
|
+
* LRU order. This is O(1) amortized, but introduces per-access overhead.
|
|
65
|
+
* For read-heavy workloads, consider a timestamp-based LRU approach to reduce
|
|
66
|
+
* per-access cost, though it adds space overhead for timestamp storage.
|
|
67
|
+
*
|
|
56
68
|
* @example
|
|
57
69
|
* ```typescript
|
|
58
70
|
* const cache = new LRUCache<string, number>(2);
|
|
@@ -66,7 +78,9 @@ export class LRUCache {
|
|
|
66
78
|
return undefined;
|
|
67
79
|
}
|
|
68
80
|
const value = this._map.get(key);
|
|
69
|
-
//
|
|
81
|
+
// LRU maintenance: re-insert at map tail on every read hit.
|
|
82
|
+
// This is O(1) but involves Map.delete + Map.set per call.
|
|
83
|
+
// For read-heavy workloads, consider a timestamp-based LRU alternative.
|
|
70
84
|
this._map.delete(key);
|
|
71
85
|
this._map.set(key, value);
|
|
72
86
|
return value;
|
|
@@ -135,5 +149,13 @@ export class LRUCache {
|
|
|
135
149
|
clear() {
|
|
136
150
|
this._map.clear();
|
|
137
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* Removes a specific key from the cache.
|
|
154
|
+
*
|
|
155
|
+
* @param key - The key to delete
|
|
156
|
+
* @returns `true` if the key existed and was deleted, `false` otherwise
|
|
157
|
+
*/
|
|
158
|
+
delete(key) {
|
|
159
|
+
return this._map.delete(key);
|
|
160
|
+
}
|
|
138
161
|
}
|
|
139
|
-
//# sourceMappingURL=lru-cache.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Number assertion functions and types.
|
|
3
|
+
*
|
|
4
|
+
* Provides assertion helpers for validating numeric values and ranges at runtime.
|
|
5
|
+
*
|
|
6
|
+
* Currently contains only assertion utilities. This module structure is designed
|
|
7
|
+
* to accommodate additional number utilities in the future (e.g., formatting,
|
|
8
|
+
* conversion functions).
|
|
9
|
+
*
|
|
10
|
+
* @module number
|
|
11
|
+
*/
|
|
12
|
+
export * from './assert.js';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/number/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Number assertion functions and types.
|
|
3
|
+
*
|
|
4
|
+
* Provides assertion helpers for validating numeric values and ranges at runtime.
|
|
5
|
+
*
|
|
6
|
+
* Currently contains only assertion utilities. This module structure is designed
|
|
7
|
+
* to accommodate additional number utilities in the future (e.g., formatting,
|
|
8
|
+
* conversion functions).
|
|
9
|
+
*
|
|
10
|
+
* @module number
|
|
11
|
+
*/
|
|
12
|
+
export * from './assert.js';
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Type guard that checks if the provided value is a non-null, non-array object.
|
|
3
3
|
*
|
|
4
|
+
* NOTE: Despite the `assert-` prefix, this file exports a type guard predicate (`IsObject`),
|
|
5
|
+
* not an assertion function that throws. Type narrowing predicates are grouped here by
|
|
6
|
+
* convention alongside related assertion functions (see `AssertObject` in the asserts module).
|
|
7
|
+
*
|
|
4
8
|
* Use this for type narrowing in conditionals. For runtime assertions that
|
|
5
9
|
* throw on failure, use {@link AssertObject} from the asserts module.
|
|
6
10
|
*
|
|
@@ -15,5 +19,5 @@
|
|
|
15
19
|
* }
|
|
16
20
|
* ```
|
|
17
21
|
*/
|
|
18
|
-
export declare function IsObject(item: unknown): item is Record<string,
|
|
22
|
+
export declare function IsObject(item: unknown): item is Record<string, unknown>;
|
|
19
23
|
//# sourceMappingURL=assert-object.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert-object.d.ts","sourceRoot":"","sources":["../../src/object/assert-object.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"assert-object.d.ts","sourceRoot":"","sources":["../../src/object/assert-object.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEvE"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Type guard that checks if the provided value is a non-null, non-array object.
|
|
3
3
|
*
|
|
4
|
+
* NOTE: Despite the `assert-` prefix, this file exports a type guard predicate (`IsObject`),
|
|
5
|
+
* not an assertion function that throws. Type narrowing predicates are grouped here by
|
|
6
|
+
* convention alongside related assertion functions (see `AssertObject` in the asserts module).
|
|
7
|
+
*
|
|
4
8
|
* Use this for type narrowing in conditionals. For runtime assertions that
|
|
5
9
|
* throw on failure, use {@link AssertObject} from the asserts module.
|
|
6
10
|
*
|
|
@@ -18,4 +22,3 @@
|
|
|
18
22
|
export function IsObject(item) {
|
|
19
23
|
return item !== null && typeof item === 'object' && !Array.isArray(item);
|
|
20
24
|
}
|
|
21
|
-
//# sourceMappingURL=assert-object.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../src/object/assert.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGnD;;;;;GAKG;AACH,qBAAa,WAAY,SAAQ,WAAW;gBAC/B,OAAO,CAAC,EAAE,MAAM;CAG5B;AAED;;;;;GAKG;AACH,qBAAa,mBAAoB,SAAQ,WAAW;gBACvC,OAAO,CAAC,EAAE,MAAM;CAG5B;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,GAAE,gBAAqB,GAAG,OAAO,CAAC,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CASvH;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,WAAW,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,SAAS,GAAE,gBAAqB,GAAG,IAAI,CAU9I;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,WAAW,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,SAAS,GAAE,gBAAqB,GAAG,IAAI,CAUjJ;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,2BAA2B,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,SAAS,GAAE,gBAAqB,GAAG,IAAI,CAW9I"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { SetExceptionClass, SetExceptionMessage, ThrowException } from '../asserts/utils.js';
|
|
2
2
|
import { SimpleError } from '../asserts/errors.js';
|
|
3
|
-
|
|
4
|
-
const MAX_VALUE_DISPLAY_LENGTH = 100;
|
|
3
|
+
import { safeDisplay } from '../asserts/generic.js';
|
|
5
4
|
/**
|
|
6
5
|
* Error thrown when a value is not a valid object or fails an object assertion.
|
|
7
6
|
*
|
|
@@ -52,28 +51,8 @@ export function AssertObject(value, exception = {}) {
|
|
|
52
51
|
SetExceptionClass(exception, ObjectError);
|
|
53
52
|
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
54
53
|
const actualType = value === null ? 'null' : Array.isArray(value) ? 'array' : typeof value;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (typeof value === 'function') {
|
|
58
|
-
valueStr = '[Function]';
|
|
59
|
-
}
|
|
60
|
-
else if (value === null) {
|
|
61
|
-
valueStr = 'null';
|
|
62
|
-
}
|
|
63
|
-
else if (value === undefined) {
|
|
64
|
-
valueStr = 'undefined';
|
|
65
|
-
}
|
|
66
|
-
else if (typeof value === 'symbol') {
|
|
67
|
-
valueStr = `[Symbol: ${String(value)}]`;
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
valueStr = JSON.stringify(value);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
catch {
|
|
74
|
-
valueStr = String(value);
|
|
75
|
-
}
|
|
76
|
-
SetExceptionMessage(exception, `Expected object but received ${actualType}: ${valueStr.slice(0, MAX_VALUE_DISPLAY_LENGTH)}`);
|
|
54
|
+
const valueStr = safeDisplay(value);
|
|
55
|
+
SetExceptionMessage(exception, `Expected object but received ${actualType}: ${valueStr}`);
|
|
77
56
|
ThrowException(exception);
|
|
78
57
|
}
|
|
79
58
|
}
|
|
@@ -109,8 +88,8 @@ export function AssertObject(value, exception = {}) {
|
|
|
109
88
|
* ```
|
|
110
89
|
*/
|
|
111
90
|
export function AssertObjectHasProperty(value, property, exception = {}) {
|
|
112
|
-
// First check if value is an object, using ObjectError
|
|
113
|
-
AssertObject(value, { class: ObjectError });
|
|
91
|
+
// First check if value is an object, using the configured exception class or ObjectError
|
|
92
|
+
AssertObject(value, { class: exception?.class ?? ObjectError });
|
|
114
93
|
// Then check for property existence, using the configured exception class or default
|
|
115
94
|
SetExceptionClass(exception, ObjectPropertyError);
|
|
116
95
|
if (!(property in value)) {
|
|
@@ -149,8 +128,8 @@ export function AssertObjectHasProperty(value, property, exception = {}) {
|
|
|
149
128
|
* ```
|
|
150
129
|
*/
|
|
151
130
|
export function AssertObjectHasOwnProperty(value, property, exception = {}) {
|
|
152
|
-
// First check if value is an object, using ObjectError
|
|
153
|
-
AssertObject(value, { class: ObjectError });
|
|
131
|
+
// First check if value is an object, using the configured exception class or ObjectError
|
|
132
|
+
AssertObject(value, { class: exception?.class ?? ObjectError });
|
|
154
133
|
// Then check for own property existence, using the configured exception class or default
|
|
155
134
|
SetExceptionClass(exception, ObjectPropertyError);
|
|
156
135
|
if (!Object.hasOwn(value, property)) {
|
|
@@ -198,4 +177,3 @@ export function AssertObjectPropertyNotNull(value, property, exception = {}) {
|
|
|
198
177
|
ThrowException(exception);
|
|
199
178
|
}
|
|
200
179
|
}
|
|
201
|
-
//# sourceMappingURL=assert.js.map
|
|
@@ -21,6 +21,12 @@ import type { TObjectTransformer } from './types.js';
|
|
|
21
21
|
* clone.b.c = 99;
|
|
22
22
|
* console.log(original.b.c); // 2 (original is not affected)
|
|
23
23
|
* ```
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const nullProtoObj = Object.create(null);
|
|
27
|
+
* nullProtoObj.x = 1;
|
|
28
|
+
* const cloned = ObjectClone(nullProtoObj); // Works correctly even for null-prototype objects
|
|
29
|
+
* ```
|
|
24
30
|
*/
|
|
25
31
|
export declare function ObjectClone<T>(obj: T, visitedInput?: WeakSet<object>): T;
|
|
26
32
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clone.d.ts","sourceRoot":"","sources":["../../src/object/clone.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,YAAY,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAkExE;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,eAAe,CAAC,MAAM,SAAS,MAAM,EAAE,OAAO,SAAS,MAAM,EAC5E,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9C,OAAO,CAMT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FilterDangerousKeys } from './security-utils.js';
|
|
2
2
|
/**
|
|
3
3
|
* Creates a deep clone of an object with security protections.
|
|
4
4
|
*
|
|
@@ -21,6 +21,12 @@ import { filterDangerousKeys } from './security-utils.js';
|
|
|
21
21
|
* clone.b.c = 99;
|
|
22
22
|
* console.log(original.b.c); // 2 (original is not affected)
|
|
23
23
|
* ```
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const nullProtoObj = Object.create(null);
|
|
27
|
+
* nullProtoObj.x = 1;
|
|
28
|
+
* const cloned = ObjectClone(nullProtoObj); // Works correctly even for null-prototype objects
|
|
29
|
+
* ```
|
|
24
30
|
*/
|
|
25
31
|
export function ObjectClone(obj, visitedInput) {
|
|
26
32
|
if (obj === null || obj === undefined) {
|
|
@@ -37,6 +43,10 @@ export function ObjectClone(obj, visitedInput) {
|
|
|
37
43
|
// Mark this object as visited
|
|
38
44
|
visited.add(obj);
|
|
39
45
|
}
|
|
46
|
+
// PERFORMANCE NOTE: The backtrack pattern (visited.delete() after processing composite types)
|
|
47
|
+
// uses delete/add operations on WeakSet for each Date, Array, and Object. For deeply nested
|
|
48
|
+
// structures (100+ levels), this delete/add cost accumulates. Depth tracking would optimize
|
|
49
|
+
// this, but the current implementation is correct for circular reference handling.
|
|
40
50
|
// Handle Date
|
|
41
51
|
if (obj instanceof Date) {
|
|
42
52
|
const result = new Date(obj.getTime());
|
|
@@ -52,9 +62,9 @@ export function ObjectClone(obj, visitedInput) {
|
|
|
52
62
|
return result;
|
|
53
63
|
}
|
|
54
64
|
// Handle plain objects only
|
|
55
|
-
if (obj.constructor === Object) {
|
|
65
|
+
if (Object.getPrototypeOf(obj) === null || obj.constructor === Object) {
|
|
56
66
|
// Security: Filter out dangerous keys
|
|
57
|
-
const safeObj =
|
|
67
|
+
const safeObj = FilterDangerousKeys(obj);
|
|
58
68
|
const copy = {};
|
|
59
69
|
// Object.keys() returns only own enumerable properties — no further guard needed.
|
|
60
70
|
for (const key of Object.keys(safeObj)) {
|
|
@@ -72,7 +82,7 @@ export function ObjectClone(obj, visitedInput) {
|
|
|
72
82
|
}
|
|
73
83
|
// Provide detailed error message for unsupported types
|
|
74
84
|
const typeName = typeof obj === 'object'
|
|
75
|
-
? obj
|
|
85
|
+
? Object.getPrototypeOf(obj)?.constructor?.name ?? 'Object'
|
|
76
86
|
: typeof obj;
|
|
77
87
|
throw new Error(`ObjectClone: ${typeName} objects are not supported. Create a new ${typeName} instance manually.`);
|
|
78
88
|
}
|
|
@@ -105,4 +115,3 @@ export function TransformObject(obj, transformer) {
|
|
|
105
115
|
}
|
|
106
116
|
return transformer(obj);
|
|
107
117
|
}
|
|
108
|
-
//# sourceMappingURL=clone.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"equals.d.ts","sourceRoot":"","sources":["../../src/object/equals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"equals.d.ts","sourceRoot":"","sources":["../../src/object/equals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAqE5D"}
|
|
@@ -48,18 +48,13 @@ export function ObjectEquals(a, b) {
|
|
|
48
48
|
if (typeof a === 'number' && typeof b === 'number' && isNaN(a) && isNaN(b)) {
|
|
49
49
|
return true;
|
|
50
50
|
}
|
|
51
|
-
//
|
|
51
|
+
// Null/undefined guards — all subsequent branches assume non-null objects.
|
|
52
52
|
if (a === null || b === null || a === undefined || b === undefined)
|
|
53
53
|
return false;
|
|
54
54
|
if (typeof a !== typeof b)
|
|
55
55
|
return false;
|
|
56
56
|
if (typeof a !== 'object')
|
|
57
57
|
return false;
|
|
58
|
-
// Type guards for object types after typeof check
|
|
59
|
-
if (a === null || b === null)
|
|
60
|
-
return false;
|
|
61
|
-
if (a === undefined || b === undefined)
|
|
62
|
-
return false;
|
|
63
58
|
const aObj = a;
|
|
64
59
|
const bObj = b;
|
|
65
60
|
// Handle Date objects
|
|
@@ -92,6 +87,8 @@ export function ObjectEquals(a, b) {
|
|
|
92
87
|
// Also compare symbol properties
|
|
93
88
|
const symbolsA = Object.getOwnPropertySymbols(aObj);
|
|
94
89
|
const symbolsB = Object.getOwnPropertySymbols(bObj);
|
|
90
|
+
// Early exit if neither object has symbols — REMOVED: this skips property value comparison
|
|
91
|
+
// if (symbolsA.length === 0 && symbolsB.length === 0) return true;
|
|
95
92
|
if (symbolsA.length !== symbolsB.length)
|
|
96
93
|
return false;
|
|
97
94
|
for (const key of keysA) {
|
|
@@ -108,4 +105,3 @@ export function ObjectEquals(a, b) {
|
|
|
108
105
|
}
|
|
109
106
|
return true;
|
|
110
107
|
}
|
|
111
|
-
//# sourceMappingURL=equals.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ICachedObjectFilterOptions, TCachedObjectFilterFunction } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a cached version of {@link ObjectFilter} for improved performance
|
|
4
|
+
* when filtering the same objects repeatedly.
|
|
5
|
+
*
|
|
6
|
+
* Results are cached by hashing the filter and object together. When the cache
|
|
7
|
+
* exceeds `maxCacheSize`, approximately 20% of the entries in the largest
|
|
8
|
+
* per-filter bucket are evicted.
|
|
9
|
+
*
|
|
10
|
+
* @template T — The object type being filtered
|
|
11
|
+
* @param options — Configuration for both the cache and the underlying filter
|
|
12
|
+
* @returns — A cached filter function `(cursor, filter) => Promise<boolean>` that returns
|
|
13
|
+
* `true` if the object matches the filter criteria, or `false` if it does not. An empty
|
|
14
|
+
* filter argument (no properties) matches all objects.
|
|
15
|
+
* @warning Filter objects with function-valued properties are not safely cacheable because
|
|
16
|
+
* {@link ObjectHash} cannot deterministically hash function references. Two different function
|
|
17
|
+
* instances with identical behavior will hash to different values, bypassing the cache and
|
|
18
|
+
* potentially causing unexpected behavior. Avoid passing filters with methods or callbacks.
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const cachedFilter = ObjectFilterCached<User>({ maxCacheSize: 500 });
|
|
22
|
+
* const isAdmin = await cachedFilter(user, { role: 'admin' });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function ObjectFilterCached<T extends object>(options?: ICachedObjectFilterOptions): TCachedObjectFilterFunction<T>;
|
|
26
|
+
//# sourceMappingURL=filter-cached.d.ts.map
|