@pawells/typescript-common 2.0.0 → 2.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +370 -223
- package/{build → dist}/array/array-chunk.d.ts +1 -1
- package/{build → dist}/array/array-chunk.js +2 -3
- package/{build → dist}/array/array-compact.d.ts +1 -1
- package/{build → dist}/array/array-compact.js +1 -2
- package/{build → dist}/array/array-contains.d.ts +1 -1
- package/{build → dist}/array/array-contains.js +2 -3
- package/{build → dist}/array/array-count-by.d.ts +1 -1
- package/{build → dist}/array/array-count-by.js +2 -3
- package/{build → dist}/array/array-difference.d.ts +12 -5
- package/dist/array/array-difference.d.ts.map +1 -0
- package/dist/array/array-difference.js +70 -0
- package/dist/array/array-element.js +1 -0
- package/{build → dist}/array/array-filter.d.ts +1 -1
- package/{build → dist}/array/array-filter.js +1 -2
- package/{build → dist}/array/array-flatten.d.ts +2 -2
- package/{build → dist}/array/array-flatten.d.ts.map +1 -1
- package/{build → dist}/array/array-flatten.js +1 -2
- package/{build → dist}/array/array-group-by.d.ts +1 -1
- package/{build → dist}/array/array-group-by.d.ts.map +1 -1
- package/{build → dist}/array/array-group-by.js +10 -9
- package/{build → dist}/array/array-intersection.d.ts +12 -5
- package/dist/array/array-intersection.d.ts.map +1 -0
- package/dist/array/array-intersection.js +79 -0
- package/{build → dist}/array/array-partition.d.ts +1 -1
- package/{build → dist}/array/array-partition.js +2 -3
- package/{build → dist}/array/array-range.d.ts +1 -1
- package/{build → dist}/array/array-range.js +1 -2
- package/{build → dist}/array/array-sample.d.ts +2 -2
- package/{build → dist}/array/array-sample.js +3 -5
- package/{build → dist}/array/array-shuffle.d.ts +1 -1
- package/{build → dist}/array/array-shuffle.js +1 -2
- package/{build → dist}/array/array-sort-by.d.ts +1 -1
- package/{build → dist}/array/array-sort-by.js +1 -2
- package/{build → dist}/array/array-zip.d.ts +1 -1
- package/{build → dist}/array/array-zip.js +1 -2
- package/{build → dist}/array/assert.d.ts +5 -5
- package/{build → dist}/array/assert.d.ts.map +1 -1
- package/{build → dist}/array/assert.js +13 -14
- package/{build → dist}/array/index.d.ts +1 -0
- package/{build → dist}/array/index.d.ts.map +1 -1
- package/{build → dist}/array/index.js +1 -1
- package/dist/array/iterators.d.ts +40 -0
- package/dist/array/iterators.d.ts.map +1 -0
- package/dist/array/iterators.js +54 -0
- package/{build → dist}/array/types.d.ts +20 -2
- package/{build → dist}/array/types.d.ts.map +1 -1
- package/dist/array/types.js +1 -0
- package/{build → dist}/array/unique.d.ts +1 -1
- package/{build → dist}/array/unique.js +1 -2
- package/dist/asserts/errors.d.ts.map +1 -0
- package/{build → dist}/asserts/errors.js +5 -3
- package/{build → dist}/asserts/generic.d.ts +23 -3
- package/dist/asserts/generic.d.ts.map +1 -0
- package/{build → dist}/asserts/generic.js +39 -7
- package/dist/asserts/index.d.ts +47 -0
- package/dist/asserts/index.d.ts.map +1 -0
- package/dist/asserts/index.js +46 -0
- package/{build → dist}/asserts/internal-utils.d.ts.map +1 -1
- package/{build → dist}/asserts/internal-utils.js +0 -1
- package/{build → dist}/asserts/types.d.ts +56 -17
- package/dist/asserts/types.d.ts.map +1 -0
- package/dist/asserts/types.js +1 -0
- package/{build → dist}/asserts/utils.d.ts +5 -21
- package/dist/asserts/utils.d.ts.map +1 -0
- package/{build → dist}/asserts/utils.js +14 -39
- package/{build → dist}/boolean/assert.d.ts +1 -2
- package/{build → dist}/boolean/assert.d.ts.map +1 -1
- package/{build → dist}/boolean/assert.js +1 -3
- package/dist/boolean/index.d.ts +13 -0
- package/dist/boolean/index.d.ts.map +1 -0
- package/dist/boolean/index.js +12 -0
- package/{build → dist}/enum/enum-entries.d.ts +1 -1
- package/dist/enum/enum-entries.d.ts.map +1 -0
- package/{build → dist}/enum/enum-entries.js +0 -1
- package/{build → dist}/enum/enum-key-by-value.d.ts +1 -1
- package/dist/enum/enum-key-by-value.d.ts.map +1 -0
- package/{build → dist}/enum/enum-key-by-value.js +0 -1
- package/{build → dist}/enum/enum-keys.js +0 -1
- package/{build → dist}/enum/enum-safe-value.d.ts +1 -1
- package/dist/enum/enum-safe-value.d.ts.map +1 -0
- package/{build → dist}/enum/enum-safe-value.js +0 -1
- package/{build → dist}/enum/enum-values.js +0 -1
- package/{build → dist}/enum/index.d.ts +1 -1
- package/dist/enum/index.d.ts.map +1 -0
- package/{build → dist}/enum/index.js +1 -2
- package/dist/enum/types.js +1 -0
- package/{build → dist}/enum/validate-enum-value.d.ts +1 -1
- package/dist/enum/validate-enum-value.d.ts.map +1 -0
- package/{build → dist}/enum/validate-enum-value.js +0 -1
- package/{build → dist}/function/compose.d.ts +6 -0
- package/dist/function/compose.d.ts.map +1 -0
- package/{build → dist}/function/compose.js +0 -1
- package/{build → dist}/function/debounce.d.ts +6 -0
- package/dist/function/debounce.d.ts.map +1 -0
- package/{build → dist}/function/debounce.js +6 -1
- package/{build → dist}/function/index.js +0 -1
- package/dist/function/memoize.d.ts +56 -0
- package/dist/function/memoize.d.ts.map +1 -0
- package/dist/function/memoize.js +72 -0
- package/{build → dist}/function/once.d.ts.map +1 -1
- package/{build → dist}/function/once.js +1 -1
- package/{build → dist}/function/sleep.js +0 -1
- package/{build → dist}/function/throttle.d.ts +7 -0
- package/dist/function/throttle.d.ts.map +1 -0
- package/{build → dist}/function/throttle.js +7 -1
- package/dist/function/types.d.ts +18 -0
- package/dist/function/types.d.ts.map +1 -0
- package/dist/function/types.js +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/json.sanitization.d.ts +14 -0
- package/dist/json.sanitization.d.ts.map +1 -0
- package/dist/json.sanitization.js +37 -0
- package/{build → dist}/lru-cache.d.ts +19 -0
- package/dist/lru-cache.d.ts.map +1 -0
- package/{build → dist}/lru-cache.js +24 -2
- package/{build → dist}/number/assert.js +0 -1
- package/dist/number/index.d.ts +13 -0
- package/dist/number/index.d.ts.map +1 -0
- package/dist/number/index.js +12 -0
- package/{build → dist}/object/assert-object.d.ts +5 -1
- package/{build → dist}/object/assert-object.d.ts.map +1 -1
- package/{build → dist}/object/assert-object.js +4 -1
- package/{build → dist}/object/assert.d.ts +1 -1
- package/dist/object/assert.d.ts.map +1 -0
- package/{build → dist}/object/assert.js +7 -29
- package/{build → dist}/object/clone.d.ts +6 -0
- package/dist/object/clone.d.ts.map +1 -0
- package/{build → dist}/object/clone.js +14 -5
- package/{build → dist}/object/equals.d.ts.map +1 -1
- package/{build → dist}/object/equals.js +3 -7
- package/dist/object/filter-cached.d.ts +26 -0
- package/{build → dist}/object/filter-cached.d.ts.map +1 -1
- package/{build → dist}/object/filter-cached.js +27 -6
- package/{build → dist}/object/filter.d.ts.map +1 -1
- package/{build → dist}/object/filter.js +22 -6
- package/{build → dist}/object/has-circular-reference.d.ts.map +1 -1
- package/{build → dist}/object/has-circular-reference.js +4 -2
- package/{build → dist}/object/hash.d.ts +4 -0
- package/dist/object/hash.d.ts.map +1 -0
- package/{build → dist}/object/hash.js +20 -7
- package/{build → dist}/object/index.d.ts +2 -2
- package/{build → dist}/object/index.d.ts.map +1 -1
- package/{build → dist}/object/index.js +1 -2
- package/{build → dist}/object/json-circular-replacer.d.ts.map +1 -1
- package/{build → dist}/object/json-circular-replacer.js +0 -1
- package/{build → dist}/object/key-value-pairs.js +0 -1
- package/dist/object/map-cached.d.ts +31 -0
- package/dist/object/map-cached.d.ts.map +1 -0
- package/{build → dist}/object/map-cached.js +34 -6
- package/{build → dist}/object/map.js +0 -1
- package/{build → dist}/object/merge.d.ts.map +1 -1
- package/{build → dist}/object/merge.js +7 -7
- package/{build → dist}/object/object-diff.d.ts +2 -2
- package/{build → dist}/object/object-diff.d.ts.map +1 -1
- package/{build → dist}/object/object-diff.js +11 -5
- package/{build → dist}/object/object-flatten.d.ts +1 -1
- package/{build → dist}/object/object-flatten.d.ts.map +1 -1
- package/{build → dist}/object/object-flatten.js +10 -4
- package/{build → dist}/object/object-invert.js +0 -1
- package/{build → dist}/object/omit.js +0 -1
- package/{build → dist}/object/pick.js +0 -1
- package/{build → dist}/object/property-paths.d.ts +2 -0
- package/{build → dist}/object/property-paths.d.ts.map +1 -1
- package/{build → dist}/object/property-paths.js +8 -7
- package/dist/object/security-utils.d.ts +193 -0
- package/dist/object/security-utils.d.ts.map +1 -0
- package/dist/object/security-utils.js +304 -0
- package/{build → dist}/object/sort-keys.d.ts +15 -1
- package/dist/object/sort-keys.d.ts.map +1 -0
- package/dist/object/sort-keys.js +73 -0
- package/{build → dist}/object/types.d.ts +0 -61
- package/dist/object/types.d.ts.map +1 -0
- package/dist/object/types.js +1 -0
- package/{build → dist}/string/assert.d.ts +24 -0
- package/dist/string/assert.d.ts.map +1 -0
- package/{build → dist}/string/assert.js +30 -1
- package/{build → dist}/string/case-conversion.js +0 -1
- package/{build → dist}/string/comparison.d.ts.map +1 -1
- package/{build → dist}/string/comparison.js +3 -1
- package/{build → dist}/string/formatting.d.ts.map +1 -1
- package/{build → dist}/string/formatting.js +5 -3
- package/{build → dist}/string/index.js +0 -1
- package/{build → dist}/string/transformation.js +0 -1
- package/dist/string/types.d.ts +118 -0
- package/dist/string/types.d.ts.map +1 -0
- package/dist/string/types.js +1 -0
- package/{build → dist}/string/validation.js +0 -1
- package/dist/time/elapsed-time/constants.d.ts +36 -0
- package/{build → dist}/time/elapsed-time/constants.d.ts.map +1 -1
- package/{build → dist}/time/elapsed-time/constants.js +32 -3
- package/{build → dist}/time/elapsed-time/elapsed-time.d.ts +74 -22
- package/dist/time/elapsed-time/elapsed-time.d.ts.map +1 -0
- package/{build → dist}/time/elapsed-time/elapsed-time.js +183 -89
- package/dist/time/elapsed-time/types.d.ts +336 -0
- package/dist/time/elapsed-time/types.d.ts.map +1 -0
- package/dist/time/elapsed-time/types.js +1 -0
- package/{build → dist}/time/elapsed-time/utils.d.ts +1 -1
- package/dist/time/elapsed-time/utils.d.ts.map +1 -0
- package/{build → dist}/time/elapsed-time/utils.js +0 -1
- package/dist/time/index.d.ts +14 -0
- package/dist/time/index.d.ts.map +1 -0
- package/{build → dist}/time/index.js +0 -5
- package/{build → dist}/time/stopwatch/entry.d.ts +1 -1
- package/dist/time/stopwatch/entry.d.ts.map +1 -0
- package/{build → dist}/time/stopwatch/entry.js +0 -1
- package/{build → dist}/time/stopwatch/stopwatch.d.ts +27 -3
- package/dist/time/stopwatch/stopwatch.d.ts.map +1 -0
- package/{build → dist}/time/stopwatch/stopwatch.js +32 -4
- package/dist/zod-util.d.ts +145 -0
- package/dist/zod-util.d.ts.map +1 -0
- package/dist/zod-util.js +126 -0
- package/package.json +51 -67
- package/LICENSE +0 -21
- package/build/array/array-chunk.js.map +0 -1
- package/build/array/array-compact.js.map +0 -1
- package/build/array/array-contains.js.map +0 -1
- package/build/array/array-count-by.js.map +0 -1
- package/build/array/array-difference.d.ts.map +0 -1
- package/build/array/array-difference.js +0 -51
- package/build/array/array-difference.js.map +0 -1
- package/build/array/array-element.js +0 -2
- package/build/array/array-element.js.map +0 -1
- package/build/array/array-filter.js.map +0 -1
- package/build/array/array-flatten.js.map +0 -1
- package/build/array/array-group-by.js.map +0 -1
- package/build/array/array-intersection.d.ts.map +0 -1
- package/build/array/array-intersection.js +0 -57
- package/build/array/array-intersection.js.map +0 -1
- package/build/array/array-partition.js.map +0 -1
- package/build/array/array-range.js.map +0 -1
- package/build/array/array-sample.js.map +0 -1
- package/build/array/array-shuffle.js.map +0 -1
- package/build/array/array-sort-by.js.map +0 -1
- package/build/array/array-zip.js.map +0 -1
- package/build/array/assert.js.map +0 -1
- package/build/array/index.js.map +0 -1
- package/build/array/types.js +0 -2
- package/build/array/types.js.map +0 -1
- package/build/array/unique.js.map +0 -1
- package/build/asserts/errors.d.ts.map +0 -1
- package/build/asserts/errors.js.map +0 -1
- package/build/asserts/generic.d.ts.map +0 -1
- package/build/asserts/generic.js.map +0 -1
- package/build/asserts/index.d.ts +0 -41
- package/build/asserts/index.d.ts.map +0 -1
- package/build/asserts/index.js +0 -41
- package/build/asserts/index.js.map +0 -1
- package/build/asserts/internal-utils.js.map +0 -1
- package/build/asserts/types.d.ts.map +0 -1
- package/build/asserts/types.js +0 -2
- package/build/asserts/types.js.map +0 -1
- package/build/asserts/utils.d.ts.map +0 -1
- package/build/asserts/utils.js.map +0 -1
- package/build/boolean/assert.js.map +0 -1
- package/build/boolean/index.d.ts +0 -9
- package/build/boolean/index.d.ts.map +0 -1
- package/build/boolean/index.js +0 -9
- package/build/boolean/index.js.map +0 -1
- package/build/enum/enum-entries.d.ts.map +0 -1
- package/build/enum/enum-entries.js.map +0 -1
- package/build/enum/enum-key-by-value.d.ts.map +0 -1
- package/build/enum/enum-key-by-value.js.map +0 -1
- package/build/enum/enum-keys.js.map +0 -1
- package/build/enum/enum-safe-value.d.ts.map +0 -1
- package/build/enum/enum-safe-value.js.map +0 -1
- package/build/enum/enum-values.js.map +0 -1
- package/build/enum/index.d.ts.map +0 -1
- package/build/enum/index.js.map +0 -1
- package/build/enum/types.js +0 -2
- package/build/enum/types.js.map +0 -1
- package/build/enum/validate-enum-value.d.ts.map +0 -1
- package/build/enum/validate-enum-value.js.map +0 -1
- package/build/function/compose.d.ts.map +0 -1
- package/build/function/compose.js.map +0 -1
- package/build/function/debounce.d.ts.map +0 -1
- package/build/function/debounce.js.map +0 -1
- package/build/function/index.js.map +0 -1
- package/build/function/memoize.d.ts +0 -30
- package/build/function/memoize.d.ts.map +0 -1
- package/build/function/memoize.js +0 -44
- package/build/function/memoize.js.map +0 -1
- package/build/function/once.js.map +0 -1
- package/build/function/sleep.js.map +0 -1
- package/build/function/throttle.d.ts.map +0 -1
- package/build/function/throttle.js.map +0 -1
- package/build/function/types.d.ts +0 -5
- package/build/function/types.d.ts.map +0 -1
- package/build/function/types.js +0 -2
- package/build/function/types.js.map +0 -1
- package/build/index.d.ts +0 -38
- package/build/index.d.ts.map +0 -1
- package/build/index.js +0 -64
- package/build/index.js.map +0 -1
- package/build/lru-cache.d.ts.map +0 -1
- package/build/lru-cache.js.map +0 -1
- package/build/number/assert.js.map +0 -1
- package/build/number/index.d.ts +0 -9
- package/build/number/index.d.ts.map +0 -1
- package/build/number/index.js +0 -9
- package/build/number/index.js.map +0 -1
- package/build/object/assert-object.js.map +0 -1
- package/build/object/assert.d.ts.map +0 -1
- package/build/object/assert.js.map +0 -1
- package/build/object/clone.d.ts.map +0 -1
- package/build/object/clone.js.map +0 -1
- package/build/object/equals.js.map +0 -1
- package/build/object/filter-cached.d.ts +0 -21
- package/build/object/filter-cached.js.map +0 -1
- package/build/object/filter.js.map +0 -1
- package/build/object/has-circular-reference.js.map +0 -1
- package/build/object/hash.d.ts.map +0 -1
- package/build/object/hash.js.map +0 -1
- package/build/object/index.js.map +0 -1
- package/build/object/json-circular-replacer.js.map +0 -1
- package/build/object/key-value-pairs.js.map +0 -1
- package/build/object/map-cached.d.ts +0 -20
- package/build/object/map-cached.d.ts.map +0 -1
- package/build/object/map-cached.js.map +0 -1
- package/build/object/map.js.map +0 -1
- package/build/object/merge.js.map +0 -1
- package/build/object/object-diff.js.map +0 -1
- package/build/object/object-flatten.js.map +0 -1
- package/build/object/object-invert.js.map +0 -1
- package/build/object/omit.js.map +0 -1
- package/build/object/pick.js.map +0 -1
- package/build/object/property-paths.js.map +0 -1
- package/build/object/security-utils.d.ts +0 -59
- package/build/object/security-utils.d.ts.map +0 -1
- package/build/object/security-utils.js +0 -161
- package/build/object/security-utils.js.map +0 -1
- package/build/object/sort-keys.d.ts.map +0 -1
- package/build/object/sort-keys.js +0 -52
- package/build/object/sort-keys.js.map +0 -1
- package/build/object/types.d.ts.map +0 -1
- package/build/object/types.js +0 -6
- package/build/object/types.js.map +0 -1
- package/build/string/assert.d.ts.map +0 -1
- package/build/string/assert.js.map +0 -1
- package/build/string/case-conversion.js.map +0 -1
- package/build/string/comparison.js.map +0 -1
- package/build/string/formatting.js.map +0 -1
- package/build/string/index.js.map +0 -1
- package/build/string/transformation.js.map +0 -1
- package/build/string/types.d.ts +0 -44
- package/build/string/types.d.ts.map +0 -1
- package/build/string/types.js +0 -2
- package/build/string/types.js.map +0 -1
- package/build/string/validation.js.map +0 -1
- package/build/time/elapsed-time/constants.d.ts +0 -10
- package/build/time/elapsed-time/constants.js.map +0 -1
- package/build/time/elapsed-time/elapsed-time.d.ts.map +0 -1
- package/build/time/elapsed-time/elapsed-time.js.map +0 -1
- package/build/time/elapsed-time/types.d.ts +0 -150
- package/build/time/elapsed-time/types.d.ts.map +0 -1
- package/build/time/elapsed-time/types.js +0 -2
- package/build/time/elapsed-time/types.js.map +0 -1
- package/build/time/elapsed-time/utils.d.ts.map +0 -1
- package/build/time/elapsed-time/utils.js.map +0 -1
- package/build/time/index.d.ts +0 -18
- package/build/time/index.d.ts.map +0 -1
- package/build/time/index.js.map +0 -1
- package/build/time/stopwatch/entry-types.d.ts +0 -13
- package/build/time/stopwatch/entry-types.d.ts.map +0 -1
- package/build/time/stopwatch/entry-types.js +0 -2
- package/build/time/stopwatch/entry-types.js.map +0 -1
- package/build/time/stopwatch/entry.d.ts.map +0 -1
- package/build/time/stopwatch/entry.js.map +0 -1
- package/build/time/stopwatch/stopwatch.d.ts.map +0 -1
- package/build/time/stopwatch/stopwatch.js.map +0 -1
- /package/{build → dist}/array/array-chunk.d.ts.map +0 -0
- /package/{build → dist}/array/array-compact.d.ts.map +0 -0
- /package/{build → dist}/array/array-contains.d.ts.map +0 -0
- /package/{build → dist}/array/array-count-by.d.ts.map +0 -0
- /package/{build → dist}/array/array-element.d.ts +0 -0
- /package/{build → dist}/array/array-element.d.ts.map +0 -0
- /package/{build → dist}/array/array-filter.d.ts.map +0 -0
- /package/{build → dist}/array/array-partition.d.ts.map +0 -0
- /package/{build → dist}/array/array-range.d.ts.map +0 -0
- /package/{build → dist}/array/array-sample.d.ts.map +0 -0
- /package/{build → dist}/array/array-shuffle.d.ts.map +0 -0
- /package/{build → dist}/array/array-sort-by.d.ts.map +0 -0
- /package/{build → dist}/array/array-zip.d.ts.map +0 -0
- /package/{build → dist}/array/unique.d.ts.map +0 -0
- /package/{build → dist}/asserts/errors.d.ts +0 -0
- /package/{build → dist}/asserts/internal-utils.d.ts +0 -0
- /package/{build → dist}/enum/enum-keys.d.ts +0 -0
- /package/{build → dist}/enum/enum-keys.d.ts.map +0 -0
- /package/{build → dist}/enum/enum-values.d.ts +0 -0
- /package/{build → dist}/enum/enum-values.d.ts.map +0 -0
- /package/{build → dist}/enum/types.d.ts +0 -0
- /package/{build → dist}/enum/types.d.ts.map +0 -0
- /package/{build → dist}/function/index.d.ts +0 -0
- /package/{build → dist}/function/index.d.ts.map +0 -0
- /package/{build → dist}/function/once.d.ts +0 -0
- /package/{build → dist}/function/sleep.d.ts +0 -0
- /package/{build → dist}/function/sleep.d.ts.map +0 -0
- /package/{build → dist}/number/assert.d.ts +0 -0
- /package/{build → dist}/number/assert.d.ts.map +0 -0
- /package/{build → dist}/object/equals.d.ts +0 -0
- /package/{build → dist}/object/filter.d.ts +0 -0
- /package/{build → dist}/object/has-circular-reference.d.ts +0 -0
- /package/{build → dist}/object/json-circular-replacer.d.ts +0 -0
- /package/{build → dist}/object/key-value-pairs.d.ts +0 -0
- /package/{build → dist}/object/key-value-pairs.d.ts.map +0 -0
- /package/{build → dist}/object/map.d.ts +0 -0
- /package/{build → dist}/object/map.d.ts.map +0 -0
- /package/{build → dist}/object/merge.d.ts +0 -0
- /package/{build → dist}/object/object-invert.d.ts +0 -0
- /package/{build → dist}/object/object-invert.d.ts.map +0 -0
- /package/{build → dist}/object/omit.d.ts +0 -0
- /package/{build → dist}/object/omit.d.ts.map +0 -0
- /package/{build → dist}/object/pick.d.ts +0 -0
- /package/{build → dist}/object/pick.d.ts.map +0 -0
- /package/{build → dist}/string/case-conversion.d.ts +0 -0
- /package/{build → dist}/string/case-conversion.d.ts.map +0 -0
- /package/{build → dist}/string/comparison.d.ts +0 -0
- /package/{build → dist}/string/formatting.d.ts +0 -0
- /package/{build → dist}/string/index.d.ts +0 -0
- /package/{build → dist}/string/index.d.ts.map +0 -0
- /package/{build → dist}/string/transformation.d.ts +0 -0
- /package/{build → dist}/string/transformation.d.ts.map +0 -0
- /package/{build → dist}/string/validation.d.ts +0 -0
- /package/{build → dist}/string/validation.d.ts.map +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter-cached.d.ts","sourceRoot":"","sources":["../../src/object/filter-cached.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,2BAA2B,EAAwB,MAAM,YAAY,CAAC;AAMhH
|
|
1
|
+
{"version":3,"file":"filter-cached.d.ts","sourceRoot":"","sources":["../../src/object/filter-cached.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,2BAA2B,EAAwB,MAAM,YAAY,CAAC;AAMhH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,EAAE,OAAO,GAAE,0BAA+B,GAAG,2BAA2B,CAAC,CAAC,CAAC,CAmI7H"}
|
|
@@ -11,10 +11,15 @@ const CACHE_EVICTION_PERCENTAGE = 0.2; // 20%
|
|
|
11
11
|
* exceeds `maxCacheSize`, approximately 20% of the entries in the largest
|
|
12
12
|
* per-filter bucket are evicted.
|
|
13
13
|
*
|
|
14
|
-
* @template T
|
|
15
|
-
* @param options
|
|
16
|
-
* @returns A cached filter function `(cursor, filter) => Promise<boolean>`
|
|
17
|
-
*
|
|
14
|
+
* @template T — The object type being filtered
|
|
15
|
+
* @param options — Configuration for both the cache and the underlying filter
|
|
16
|
+
* @returns — A cached filter function `(cursor, filter) => Promise<boolean>` that returns
|
|
17
|
+
* `true` if the object matches the filter criteria, or `false` if it does not. An empty
|
|
18
|
+
* filter argument (no properties) matches all objects.
|
|
19
|
+
* @warning Filter objects with function-valued properties are not safely cacheable because
|
|
20
|
+
* {@link ObjectHash} cannot deterministically hash function references. Two different function
|
|
21
|
+
* instances with identical behavior will hash to different values, bypassing the cache and
|
|
22
|
+
* potentially causing unexpected behavior. Avoid passing filters with methods or callbacks.
|
|
18
23
|
* @example
|
|
19
24
|
* ```typescript
|
|
20
25
|
* const cachedFilter = ObjectFilterCached<User>({ maxCacheSize: 500 });
|
|
@@ -31,6 +36,11 @@ export function ObjectFilterCached(options = {}) {
|
|
|
31
36
|
*
|
|
32
37
|
* The eviction strategy targets the most-populated bucket to reclaim the most
|
|
33
38
|
* memory in a single pass while preserving results for other active filters.
|
|
39
|
+
*
|
|
40
|
+
* PERFORMANCE NOTE: For distributed filter load, eviction triggers too frequently.
|
|
41
|
+
* A true global LRU across all filters would be more efficient but would require
|
|
42
|
+
* tracking access order globally. Refactoring to use the library's own LRUCache
|
|
43
|
+
* (if available) instead of per-filter Maps would improve this further.
|
|
34
44
|
*/
|
|
35
45
|
const clearOldestEntries = () => {
|
|
36
46
|
if (cache.size === 0)
|
|
@@ -47,6 +57,8 @@ export function ObjectFilterCached(options = {}) {
|
|
|
47
57
|
}
|
|
48
58
|
}
|
|
49
59
|
if (largestCache) {
|
|
60
|
+
// Capture the original bucket size before eviction
|
|
61
|
+
const originalBucketSize = largestCache.size;
|
|
50
62
|
// Remove approximately 20% of entries from the largest cache
|
|
51
63
|
const entriesToRemove = Math.ceil(largestSize * CACHE_EVICTION_PERCENTAGE);
|
|
52
64
|
let removed = 0;
|
|
@@ -59,8 +71,18 @@ export function ObjectFilterCached(options = {}) {
|
|
|
59
71
|
// If the cache is now empty, remove it completely
|
|
60
72
|
if (largestCache.size === 0) {
|
|
61
73
|
cache.delete(largestCacheKey);
|
|
74
|
+
// Account for all entries that were in the bucket (not just the ones we explicitly removed)
|
|
75
|
+
totalCachedEntries -= originalBucketSize;
|
|
62
76
|
}
|
|
63
|
-
|
|
77
|
+
else {
|
|
78
|
+
// Only remove the entries we explicitly deleted
|
|
79
|
+
totalCachedEntries -= removed;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Recompute counter to eliminate drift
|
|
83
|
+
totalCachedEntries = 0;
|
|
84
|
+
for (const bucket of cache.values()) {
|
|
85
|
+
totalCachedEntries += bucket.size;
|
|
64
86
|
}
|
|
65
87
|
};
|
|
66
88
|
return (cursor, filter) => {
|
|
@@ -115,4 +137,3 @@ export function ObjectFilterCached(options = {}) {
|
|
|
115
137
|
return Promise.resolve(result);
|
|
116
138
|
};
|
|
117
139
|
}
|
|
118
|
-
//# sourceMappingURL=filter-cached.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/object/filter.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/object/filter.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAmGxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAyCvH;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAiBhG"}
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { ObjectEquals } from './equals.js';
|
|
2
|
-
import {
|
|
2
|
+
import { IsPropertyPathSafe } from './security-utils.js';
|
|
3
3
|
import { ObjectGetPropertyByPath } from './property-paths.js';
|
|
4
4
|
import { StringEquals } from '../string/comparison.js';
|
|
5
|
+
/**
|
|
6
|
+
* Type guard to safely identify a filter predicate function.
|
|
7
|
+
*
|
|
8
|
+
* @param v - The value to check
|
|
9
|
+
* @returns True if the value is a function that can be used as a filter predicate
|
|
10
|
+
*/
|
|
11
|
+
function isFilterPredicate(v) {
|
|
12
|
+
return typeof v === 'function';
|
|
13
|
+
}
|
|
5
14
|
/**
|
|
6
15
|
* Compares two values for ObjectFilter with support for predicates, case-insensitive strings,
|
|
7
16
|
* and deep equality via ObjectEquals.
|
|
@@ -14,7 +23,7 @@ import { StringEquals } from '../string/comparison.js';
|
|
|
14
23
|
*/
|
|
15
24
|
function compareValuesForFilter(objValue, filterValue, caseInsensitiveStrings = false, useDeepEqual = false) {
|
|
16
25
|
// Handle function as predicate
|
|
17
|
-
if (
|
|
26
|
+
if (isFilterPredicate(filterValue)) {
|
|
18
27
|
return filterValue(objValue);
|
|
19
28
|
}
|
|
20
29
|
// Handle case-insensitive string comparison (filter-specific feature)
|
|
@@ -60,6 +69,14 @@ function objectHandleArrayComparison(objValue, filterValue, caseInsensitiveStrin
|
|
|
60
69
|
}
|
|
61
70
|
// If filterValue is also an array, check if it's a subset
|
|
62
71
|
if (Array.isArray(filterValue)) {
|
|
72
|
+
// PERFORMANCE: For arrays of primitives without deep equality or case-insensitive matching,
|
|
73
|
+
// use a Set-based approach for O(n+m) performance instead of nested loops.
|
|
74
|
+
if (!useDeepEqual && !caseInsensitiveStrings && filterValue.every((item) => typeof item !== 'object' || item === null)) {
|
|
75
|
+
const objSet = new Set(objValue);
|
|
76
|
+
return filterValue.every((item) => objSet.has(item));
|
|
77
|
+
}
|
|
78
|
+
// For object arrays or when deep equality is enabled, fall back to nested loop comparison
|
|
79
|
+
// (reference equality for objects, deep equality if requested)
|
|
63
80
|
return filterValue.every((item) => objValue.some((objItem) => compareValuesForFilter(objItem, item, caseInsensitiveStrings, useDeepEqual)));
|
|
64
81
|
}
|
|
65
82
|
// For non-string, non-array filter values, check direct inclusion
|
|
@@ -134,12 +151,12 @@ export function ObjectFilter(object, filter, options = {}) {
|
|
|
134
151
|
// Default options
|
|
135
152
|
const { useDeepEqual = false, caseInsensitiveStrings = false, validatePaths = false } = options;
|
|
136
153
|
for (const key in filter) {
|
|
137
|
-
|
|
138
|
-
if (!Object.hasOwn(filter, key))
|
|
154
|
+
if (!Object.hasOwn(filter, key)) {
|
|
139
155
|
continue;
|
|
156
|
+
}
|
|
140
157
|
// Handle dot notation paths
|
|
141
158
|
if (key.includes('.')) {
|
|
142
|
-
if (validatePaths && !
|
|
159
|
+
if (validatePaths && !IsPropertyPathSafe(key)) {
|
|
143
160
|
return false;
|
|
144
161
|
}
|
|
145
162
|
const objValue = ObjectGetPropertyByPath(object, key);
|
|
@@ -203,4 +220,3 @@ export function FilterObject(obj, predicate) {
|
|
|
203
220
|
}
|
|
204
221
|
return result;
|
|
205
222
|
}
|
|
206
|
-
//# sourceMappingURL=filter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"has-circular-reference.d.ts","sourceRoot":"","sources":["../../src/object/has-circular-reference.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"has-circular-reference.d.ts","sourceRoot":"","sources":["../../src/object/has-circular-reference.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAiDhE"}
|
|
@@ -45,10 +45,12 @@ export function ObjectHasCircularReference(obj) {
|
|
|
45
45
|
return true;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
// Backtrack:
|
|
48
|
+
// Backtrack: remove from visited set after traversal to allow the same object
|
|
49
|
+
// to appear via multiple non-circular paths. This correctly distinguishes shared
|
|
50
|
+
// references (allowed) from circular references (detected). Note: this assumes
|
|
51
|
+
// single-threaded synchronous traversal.
|
|
49
52
|
seen.delete(value);
|
|
50
53
|
return false;
|
|
51
54
|
};
|
|
52
55
|
return detectCircular(obj);
|
|
53
56
|
}
|
|
54
|
-
//# sourceMappingURL=has-circular-reference.js.map
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* SECURITY WARNING: This hash is NON-CRYPTOGRAPHIC (cyrb53, 64-bit).
|
|
3
|
+
* Do NOT use for passwords, tokens, signatures, or any security-sensitive operation.
|
|
4
|
+
* For cryptographic hashing, use `crypto.subtle.digest('SHA-256', ...)` instead.
|
|
5
|
+
*
|
|
2
6
|
* Creates a hash of an object.
|
|
3
7
|
*
|
|
4
8
|
* By default a fast, non-cryptographic 64-bit hash is used that works in all
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/object/hash.ts"],"names":[],"mappings":"AAqCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,EAAE,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,MAAM,CAkBxF"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ObjectHasCircularReference } from './has-circular-reference.js';
|
|
2
1
|
// cyrb53-style hash mixing constants (chosen for good avalanche properties)
|
|
3
2
|
const HASH_SEED_1 = 0xdeadbeef;
|
|
4
3
|
const HASH_SEED_2 = 0x41c6ce57;
|
|
@@ -15,6 +14,13 @@ const HEXADECIMAL_RADIX = 16;
|
|
|
15
14
|
* Browser-compatible and synchronous — no Node.js APIs required.
|
|
16
15
|
* Returns a 16-character lowercase hex string.
|
|
17
16
|
*/
|
|
17
|
+
/**
|
|
18
|
+
* 64-bit cyrb53 hash function.
|
|
19
|
+
*
|
|
20
|
+
* PERFORMANCE NOTE: This hash has 2^64 output space; collisions are theoretically
|
|
21
|
+
* possible with large datasets. For cryptographic applications requiring collision
|
|
22
|
+
* resistance, use crypto.subtle.digest instead.
|
|
23
|
+
*/
|
|
18
24
|
function defaultHash(data) {
|
|
19
25
|
let h1 = HASH_SEED_1;
|
|
20
26
|
let h2 = HASH_SEED_2;
|
|
@@ -28,6 +34,10 @@ function defaultHash(data) {
|
|
|
28
34
|
return h1.toString(HEXADECIMAL_RADIX).padStart(HASH_PAD_WIDTH, '0') + h2.toString(HEXADECIMAL_RADIX).padStart(HASH_PAD_WIDTH, '0');
|
|
29
35
|
}
|
|
30
36
|
/**
|
|
37
|
+
* SECURITY WARNING: This hash is NON-CRYPTOGRAPHIC (cyrb53, 64-bit).
|
|
38
|
+
* Do NOT use for passwords, tokens, signatures, or any security-sensitive operation.
|
|
39
|
+
* For cryptographic hashing, use `crypto.subtle.digest('SHA-256', ...)` instead.
|
|
40
|
+
*
|
|
31
41
|
* Creates a hash of an object.
|
|
32
42
|
*
|
|
33
43
|
* By default a fast, non-cryptographic 64-bit hash is used that works in all
|
|
@@ -53,16 +63,19 @@ function defaultHash(data) {
|
|
|
53
63
|
* ```
|
|
54
64
|
*/
|
|
55
65
|
export function ObjectHash(obj, hashFunction) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
66
|
+
let jsonString;
|
|
67
|
+
try {
|
|
68
|
+
jsonString = JSON.stringify(obj);
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
if (e instanceof TypeError && e.message.includes('circular')) {
|
|
72
|
+
throw new Error('Cannot hash object with circular references', { cause: e });
|
|
73
|
+
}
|
|
74
|
+
throw new Error('Cannot hash object: JSON.stringify failed', { cause: e });
|
|
60
75
|
}
|
|
61
|
-
const jsonString = JSON.stringify(obj);
|
|
62
76
|
// Handle cases where JSON.stringify returns undefined
|
|
63
77
|
if (jsonString === undefined) {
|
|
64
78
|
throw new Error('Cannot hash object: JSON.stringify returned undefined');
|
|
65
79
|
}
|
|
66
80
|
return hashFunction ? hashFunction(jsonString) : defaultHash(jsonString);
|
|
67
81
|
}
|
|
68
|
-
//# sourceMappingURL=hash.js.map
|
|
@@ -23,12 +23,12 @@ export { ObjectPick } from './pick.js';
|
|
|
23
23
|
export { ObjectOmit } from './omit.js';
|
|
24
24
|
export { ObjectMerge } from './merge.js';
|
|
25
25
|
export { IsObject } from './assert-object.js';
|
|
26
|
-
export {
|
|
26
|
+
export { IsPropertyKeySafe, IsPropertyPathSafe, SanitizePropertyKey, FilterDangerousKeys, CreateCircularReferenceDetector, IsInputSafe } from './security-utils.js';
|
|
27
27
|
export { ObjectInvert } from './object-invert.js';
|
|
28
28
|
export { ObjectFlatten } from './object-flatten.js';
|
|
29
29
|
export { ObjectDiff } from './object-diff.js';
|
|
30
30
|
export { AssertObject, ObjectError, ObjectPropertyError, AssertObjectHasProperty, AssertObjectHasOwnProperty, AssertObjectPropertyNotNull } from './assert.js';
|
|
31
31
|
export type { IObjectDiffResult } from './object-diff.js';
|
|
32
|
-
export type {
|
|
32
|
+
export type { TCachedObjectFilterFunction, TCachedObjectMapperFunction, TObjectPredicate, TObjectTransformer, TObjectComparator, TObjectEqualityComparator, TPropertyMapper, TPropertyFilter } from './types.js';
|
|
33
33
|
export type { IObjectFilterOptions, ICachedObjectFilterOptions, ICachedObjectMapOptions } from './types.js';
|
|
34
34
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/object/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AACvF,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,+BAA+B,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACpK,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAC/J,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAG1D,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/object/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AACvF,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,+BAA+B,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACpK,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAC/J,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAG1D,YAAY,EAAE,2BAA2B,EAAE,2BAA2B,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGjN,YAAY,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -24,9 +24,8 @@ export { ObjectPick } from './pick.js';
|
|
|
24
24
|
export { ObjectOmit } from './omit.js';
|
|
25
25
|
export { ObjectMerge } from './merge.js';
|
|
26
26
|
export { IsObject } from './assert-object.js';
|
|
27
|
-
export {
|
|
27
|
+
export { IsPropertyKeySafe, IsPropertyPathSafe, SanitizePropertyKey, FilterDangerousKeys, CreateCircularReferenceDetector, IsInputSafe } from './security-utils.js';
|
|
28
28
|
export { ObjectInvert } from './object-invert.js';
|
|
29
29
|
export { ObjectFlatten } from './object-flatten.js';
|
|
30
30
|
export { ObjectDiff } from './object-diff.js';
|
|
31
31
|
export { AssertObject, ObjectError, ObjectPropertyError, AssertObjectHasProperty, AssertObjectHasOwnProperty, AssertObjectPropertyNotNull } from './assert.js';
|
|
32
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-circular-replacer.d.ts","sourceRoot":"","sources":["../../src/object/json-circular-replacer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,0BAA0B,CACzC,WAAW,
|
|
1
|
+
{"version":3,"file":"json-circular-replacer.d.ts","sourceRoot":"","sources":["../../src/object/json-circular-replacer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,0BAA0B,CACzC,WAAW,SAAe,GACxB,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,OAAO,CA0BzD"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { TPropertyMapper, ICachedObjectMapOptions } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a cached version of {@link MapObject} for improved performance
|
|
4
|
+
* when mapping the same objects repeatedly.
|
|
5
|
+
*
|
|
6
|
+
* Results are cached by hashing the object. Cache entries are evicted in
|
|
7
|
+
* approximately 20% batches when the limit is reached.
|
|
8
|
+
*
|
|
9
|
+
* @template T - The object type being mapped
|
|
10
|
+
* @param options - Configuration options for cache behaviour
|
|
11
|
+
* @returns A cached map function with parameters:
|
|
12
|
+
* - `cursor` - The object to be mapped
|
|
13
|
+
* - `mapper` - Function to map each property value
|
|
14
|
+
* - `mapperKey` - Optional stable string identifier for the mapper. When omitted,
|
|
15
|
+
* `Function.toString()` is used as the cache key, which may cause cache collisions
|
|
16
|
+
* for closures with identical source text but different captured variables.
|
|
17
|
+
* Always provide an explicit `mapperKey` when the mapper captures mutable state.
|
|
18
|
+
*
|
|
19
|
+
* @warning When `mapperKey` is not provided, the function uses `Function.toString()` as
|
|
20
|
+
* the cache key. This approach is expensive for large functions and causes cache collisions
|
|
21
|
+
* for closures with identical source code but different captured values. Always supply an
|
|
22
|
+
* explicit `mapperKey` to avoid unexpected cache behavior.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const cachedMap = MapObjectCached<User>();
|
|
27
|
+
* const display = await cachedMap(user, (key, value) => String(value));
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function MapObjectCached<T extends object>(options?: ICachedObjectMapOptions): (cursor: T, mapper: TPropertyMapper<T>, mapperKey?: string) => Promise<Record<keyof T, unknown>>;
|
|
31
|
+
//# sourceMappingURL=map-cached.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-cached.d.ts","sourceRoot":"","sources":["../../src/object/map-cached.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAM3E;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,EAAE,OAAO,GAAE,uBAA4B,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC,CAmHzL"}
|
|
@@ -12,7 +12,18 @@ const CACHE_EVICTION_PERCENTAGE = 0.2; // 20%
|
|
|
12
12
|
*
|
|
13
13
|
* @template T - The object type being mapped
|
|
14
14
|
* @param options - Configuration options for cache behaviour
|
|
15
|
-
* @returns A cached map function
|
|
15
|
+
* @returns A cached map function with parameters:
|
|
16
|
+
* - `cursor` - The object to be mapped
|
|
17
|
+
* - `mapper` - Function to map each property value
|
|
18
|
+
* - `mapperKey` - Optional stable string identifier for the mapper. When omitted,
|
|
19
|
+
* `Function.toString()` is used as the cache key, which may cause cache collisions
|
|
20
|
+
* for closures with identical source text but different captured variables.
|
|
21
|
+
* Always provide an explicit `mapperKey` when the mapper captures mutable state.
|
|
22
|
+
*
|
|
23
|
+
* @warning When `mapperKey` is not provided, the function uses `Function.toString()` as
|
|
24
|
+
* the cache key. This approach is expensive for large functions and causes cache collisions
|
|
25
|
+
* for closures with identical source code but different captured values. Always supply an
|
|
26
|
+
* explicit `mapperKey` to avoid unexpected cache behavior.
|
|
16
27
|
*
|
|
17
28
|
* @example
|
|
18
29
|
* ```typescript
|
|
@@ -30,6 +41,11 @@ export function MapObjectCached(options = {}) {
|
|
|
30
41
|
*
|
|
31
42
|
* The eviction strategy targets the most-populated bucket to reclaim the most
|
|
32
43
|
* memory in a single pass while preserving results for other active mappers.
|
|
44
|
+
*
|
|
45
|
+
* PERFORMANCE NOTE: For distributed mapper load, eviction triggers too frequently.
|
|
46
|
+
* A true global LRU across all mappers would be more efficient but would require
|
|
47
|
+
* tracking access order globally. Refactoring to use the library's own LRUCache
|
|
48
|
+
* (if available) instead of per-mapper Maps would improve this further.
|
|
33
49
|
*/
|
|
34
50
|
const clearOldestEntries = () => {
|
|
35
51
|
if (cache.size === 0)
|
|
@@ -46,6 +62,8 @@ export function MapObjectCached(options = {}) {
|
|
|
46
62
|
}
|
|
47
63
|
}
|
|
48
64
|
if (largestCache) {
|
|
65
|
+
// Capture the original bucket size before eviction
|
|
66
|
+
const originalBucketSize = largestCache.size;
|
|
49
67
|
// Remove approximately 20% of entries from the largest cache
|
|
50
68
|
const entriesToRemove = Math.ceil(largestSize * CACHE_EVICTION_PERCENTAGE);
|
|
51
69
|
let removed = 0;
|
|
@@ -58,8 +76,13 @@ export function MapObjectCached(options = {}) {
|
|
|
58
76
|
// If the cache is now empty, remove it completely
|
|
59
77
|
if (largestCache.size === 0) {
|
|
60
78
|
cache.delete(largestCacheKey);
|
|
79
|
+
// Account for all entries that were in the bucket (not just the ones we explicitly removed)
|
|
80
|
+
totalCachedEntries -= originalBucketSize;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
// Only remove the entries we explicitly deleted
|
|
84
|
+
totalCachedEntries -= removed;
|
|
61
85
|
}
|
|
62
|
-
totalCachedEntries -= removed;
|
|
63
86
|
}
|
|
64
87
|
};
|
|
65
88
|
return (cursor, mapper, mapperKey) => {
|
|
@@ -68,9 +91,10 @@ export function MapObjectCached(options = {}) {
|
|
|
68
91
|
return Promise.resolve({});
|
|
69
92
|
}
|
|
70
93
|
// Use the explicitly provided mapperKey when available.
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
//
|
|
94
|
+
// NOTE: When mapperKey is not provided, uses Function.toString() as cache key.
|
|
95
|
+
// This is expensive for large functions and causes cache collisions for closures
|
|
96
|
+
// with identical source code but different captured values.
|
|
97
|
+
// Always provide explicit mapperKey for correct behavior.
|
|
74
98
|
const resolvedMapperKey = mapperKey ?? mapper.toString();
|
|
75
99
|
// Try to get the object cache for this mapper
|
|
76
100
|
let objectCache = cache.get(resolvedMapperKey);
|
|
@@ -100,8 +124,12 @@ export function MapObjectCached(options = {}) {
|
|
|
100
124
|
// Ensure the cache size does not exceed the limit
|
|
101
125
|
if (totalCachedEntries > maxCacheSize) {
|
|
102
126
|
clearOldestEntries();
|
|
127
|
+
// Recompute counter to eliminate drift
|
|
128
|
+
totalCachedEntries = 0;
|
|
129
|
+
for (const bucket of cache.values()) {
|
|
130
|
+
totalCachedEntries += bucket.size;
|
|
131
|
+
}
|
|
103
132
|
}
|
|
104
133
|
return Promise.resolve(result);
|
|
105
134
|
};
|
|
106
135
|
}
|
|
107
|
-
//# sourceMappingURL=map-cached.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../src/object/merge.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../src/object/merge.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CA0BvF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FilterDangerousKeys } from './security-utils.js';
|
|
2
2
|
/**
|
|
3
3
|
* Merges two objects deeply with security protections.
|
|
4
4
|
*
|
|
@@ -28,22 +28,22 @@ export function ObjectMerge(target, source) {
|
|
|
28
28
|
if (!source || typeof source !== 'object')
|
|
29
29
|
return target;
|
|
30
30
|
// Security: Filter out dangerous keys from source object
|
|
31
|
-
const safeSource =
|
|
31
|
+
const safeSource = FilterDangerousKeys(source);
|
|
32
32
|
const output = { ...target };
|
|
33
33
|
// Object.keys() returns only own enumerable properties — no further guard needed.
|
|
34
34
|
for (const key of Object.keys(safeSource)) {
|
|
35
|
-
const
|
|
35
|
+
const outputRecord = output;
|
|
36
|
+
const targetValue = outputRecord[key];
|
|
36
37
|
const sourceValue = safeSource[key];
|
|
37
38
|
if (Array.isArray(targetValue) && Array.isArray(sourceValue)) {
|
|
38
|
-
|
|
39
|
+
outputRecord[key] = [...targetValue, ...sourceValue];
|
|
39
40
|
}
|
|
40
41
|
else if (targetValue && typeof targetValue === 'object' && sourceValue && typeof sourceValue === 'object') {
|
|
41
|
-
|
|
42
|
+
outputRecord[key] = ObjectMerge(targetValue, sourceValue);
|
|
42
43
|
}
|
|
43
44
|
else {
|
|
44
|
-
|
|
45
|
+
outputRecord[key] = sourceValue;
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
return output;
|
|
48
49
|
}
|
|
49
|
-
//# sourceMappingURL=merge.js.map
|
|
@@ -16,8 +16,8 @@ export interface IObjectDiffResult {
|
|
|
16
16
|
* Returns three groups:
|
|
17
17
|
* - **added** — keys in `objB` that are absent from `objA`
|
|
18
18
|
* - **removed** — keys in `objA` that are absent from `objB`
|
|
19
|
-
* - **changed** — keys present in both whose values
|
|
20
|
-
* (compared via `
|
|
19
|
+
* - **changed** — keys present in both whose values differ
|
|
20
|
+
* (compared via `ObjectEquals` for deep value equality)
|
|
21
21
|
*
|
|
22
22
|
* **Important**: Comparison is performed with deep equality (`ObjectEquals`),
|
|
23
23
|
* which correctly handles nested objects regardless of key insertion order,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-diff.d.ts","sourceRoot":"","sources":["../../src/object/object-diff.ts"],"names":[],"mappings":"AAEA,sEAAsE;AACtE,MAAM,WAAW,iBAAiB;IACjC,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,wDAAwD;IACxD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,EAAE,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACxD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,UAAU,CACzB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC3B,iBAAiB,
|
|
1
|
+
{"version":3,"file":"object-diff.d.ts","sourceRoot":"","sources":["../../src/object/object-diff.ts"],"names":[],"mappings":"AAEA,sEAAsE;AACtE,MAAM,WAAW,iBAAiB;IACjC,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,wDAAwD;IACxD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,EAAE,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACxD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,UAAU,CACzB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC3B,iBAAiB,CA0BnB"}
|
|
@@ -5,8 +5,8 @@ import { ObjectEquals } from './equals.js';
|
|
|
5
5
|
* Returns three groups:
|
|
6
6
|
* - **added** — keys in `objB` that are absent from `objA`
|
|
7
7
|
* - **removed** — keys in `objA` that are absent from `objB`
|
|
8
|
-
* - **changed** — keys present in both whose values
|
|
9
|
-
* (compared via `
|
|
8
|
+
* - **changed** — keys present in both whose values differ
|
|
9
|
+
* (compared via `ObjectEquals` for deep value equality)
|
|
10
10
|
*
|
|
11
11
|
* **Important**: Comparison is performed with deep equality (`ObjectEquals`),
|
|
12
12
|
* which correctly handles nested objects regardless of key insertion order,
|
|
@@ -32,8 +32,15 @@ import { ObjectEquals } from './equals.js';
|
|
|
32
32
|
*/
|
|
33
33
|
export function ObjectDiff(objA, objB) {
|
|
34
34
|
const result = { added: {}, removed: {}, changed: {} };
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
// Combine keys from both objects efficiently
|
|
36
|
+
const allKeys = new Map();
|
|
37
|
+
for (const key of Object.keys(objA)) {
|
|
38
|
+
allKeys.set(key, true);
|
|
39
|
+
}
|
|
40
|
+
for (const key of Object.keys(objB)) {
|
|
41
|
+
allKeys.set(key, true);
|
|
42
|
+
}
|
|
43
|
+
for (const key of allKeys.keys()) {
|
|
37
44
|
const inA = Object.hasOwn(objA, key);
|
|
38
45
|
const inB = Object.hasOwn(objB, key);
|
|
39
46
|
if (inA && !inB) {
|
|
@@ -48,4 +55,3 @@ export function ObjectDiff(objA, objB) {
|
|
|
48
55
|
}
|
|
49
56
|
return result;
|
|
50
57
|
}
|
|
51
|
-
//# sourceMappingURL=object-diff.js.map
|
|
@@ -18,5 +18,5 @@
|
|
|
18
18
|
* // { 'a/b': 1 }
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
|
-
export declare function ObjectFlatten(obj: Record<string, unknown>, separator?: string
|
|
21
|
+
export declare function ObjectFlatten(obj: Record<string, unknown>, separator?: string): Record<string, unknown>;
|
|
22
22
|
//# sourceMappingURL=object-flatten.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-flatten.d.ts","sourceRoot":"","sources":["../../src/object/object-flatten.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,aAAa,CAC5B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,SAAS,SAAM,
|
|
1
|
+
{"version":3,"file":"object-flatten.d.ts","sourceRoot":"","sources":["../../src/object/object-flatten.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,aAAa,CAC5B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,SAAS,SAAM,GACb,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzB"}
|
|
@@ -18,16 +18,23 @@
|
|
|
18
18
|
* // { 'a/b': 1 }
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
|
-
export function ObjectFlatten(obj, separator = '.'
|
|
21
|
+
export function ObjectFlatten(obj, separator = '.') {
|
|
22
|
+
return flattenRecursive(obj, separator, '');
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @internal Recursion helper; not part of the public API.
|
|
26
|
+
* @param prefix - Accumulated key prefix from parent recursion level
|
|
27
|
+
*/
|
|
28
|
+
function flattenRecursive(obj, separator, prefix) {
|
|
22
29
|
const result = {};
|
|
23
30
|
for (const key of Object.keys(obj)) {
|
|
24
31
|
const value = obj[key];
|
|
25
|
-
const newKey =
|
|
32
|
+
const newKey = prefix ? `${prefix}${separator}${key}` : key;
|
|
26
33
|
if (value !== null &&
|
|
27
34
|
typeof value === 'object' &&
|
|
28
35
|
!Array.isArray(value) &&
|
|
29
36
|
!(value instanceof Date)) {
|
|
30
|
-
Object.assign(result,
|
|
37
|
+
Object.assign(result, flattenRecursive(value, separator, newKey));
|
|
31
38
|
}
|
|
32
39
|
else {
|
|
33
40
|
result[newKey] = value;
|
|
@@ -35,4 +42,3 @@ export function ObjectFlatten(obj, separator = '.', _prefix = '') {
|
|
|
35
42
|
}
|
|
36
43
|
return result;
|
|
37
44
|
}
|
|
38
|
-
//# sourceMappingURL=object-flatten.js.map
|
|
@@ -68,6 +68,8 @@ export declare function ObjectGetPropertyByPath<T = unknown>(obj: unknown, path:
|
|
|
68
68
|
* @param obj - Target object to modify
|
|
69
69
|
* @param path - Path to the property using dot notation (e.g., 'user.address.street')
|
|
70
70
|
* @param value - Value to set at the specified path
|
|
71
|
+
* @throws Throws if `path` contains dangerous keys (`__proto__`, `constructor`, `prototype`)
|
|
72
|
+
* @throws Throws if `path` is invalid or contains non-string segments
|
|
71
73
|
*
|
|
72
74
|
* @example
|
|
73
75
|
* ```typescript
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"property-paths.d.ts","sourceRoot":"","sources":["../../src/object/property-paths.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS,CAiChH;AAED
|
|
1
|
+
{"version":3,"file":"property-paths.d.ts","sourceRoot":"","sources":["../../src/object/property-paths.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS,CAiChH;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAyC/F"}
|