@pawells/typescript-common 1.4.1 → 2.1.5
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 +350 -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 +4 -1
- package/{build → dist}/array/array-contains.d.ts.map +1 -1
- package/{build → dist}/array/array-contains.js +6 -3
- package/{build → dist}/array/array-count-by.d.ts +3 -1
- package/dist/array/array-count-by.d.ts.map +1 -0
- package/{build → dist}/array/array-count-by.js +4 -2
- package/dist/array/array-difference.d.ts +43 -0
- 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 +3 -1
- package/{build → dist}/array/array-filter.d.ts.map +1 -1
- package/{build → dist}/array/array-filter.js +5 -3
- 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 +3 -1
- package/dist/array/array-group-by.d.ts.map +1 -0
- package/{build → dist}/array/array-group-by.js +12 -8
- package/dist/array/array-intersection.d.ts +43 -0
- 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 +3 -1
- package/{build → dist}/array/array-partition.d.ts.map +1 -1
- package/{build → dist}/array/array-partition.js +4 -2
- 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 +4 -4
- package/dist/array/array-sample.d.ts.map +1 -0
- package/{build → dist}/array/array-sample.js +4 -14
- 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 +27 -23
- package/dist/array/assert.d.ts.map +1 -0
- package/{build → dist}/array/assert.js +40 -37
- package/{build → dist}/array/index.js +0 -1
- package/{build → dist}/array/types.d.ts +29 -0
- package/dist/array/types.d.ts.map +1 -0
- package/dist/array/types.js +1 -0
- package/{build → dist}/array/unique.d.ts +3 -1
- package/{build → dist}/array/unique.d.ts.map +1 -1
- package/{build → dist}/array/unique.js +5 -3
- package/dist/asserts/errors.d.ts.map +1 -0
- package/{build → dist}/asserts/errors.js +5 -3
- package/{build → dist}/asserts/generic.d.ts +32 -3
- package/dist/asserts/generic.d.ts.map +1 -0
- package/{build → dist}/asserts/generic.js +63 -15
- 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 +18 -2
- package/dist/asserts/utils.d.ts.map +1 -0
- package/{build → dist}/asserts/utils.js +56 -1
- 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 +3 -8
- 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 +9 -2
- package/dist/function/compose.d.ts.map +1 -0
- package/{build → dist}/function/compose.js +0 -1
- package/{build → dist}/function/debounce.d.ts +8 -1
- 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 +43 -0
- package/dist/function/memoize.d.ts.map +1 -0
- package/dist/function/memoize.js +59 -0
- package/{build → dist}/function/once.d.ts +1 -0
- package/{build → dist}/function/once.d.ts.map +1 -1
- package/{build → dist}/function/once.js +2 -1
- package/{build → dist}/function/sleep.js +0 -1
- package/dist/function/throttle.d.ts +25 -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 +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -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.d.ts.map +1 -1
- package/{build → dist}/number/assert.js +38 -43
- 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.map +1 -1
- package/{build → dist}/object/clone.js +11 -5
- package/{build → dist}/object/equals.d.ts +1 -1
- package/{build → dist}/object/equals.d.ts.map +1 -1
- package/{build → dist}/object/equals.js +12 -9
- package/dist/object/filter-cached.d.ts +44 -0
- package/{build → dist}/object/filter-cached.d.ts.map +1 -1
- package/{build → dist}/object/filter-cached.js +41 -2
- package/{build → dist}/object/filter.d.ts +1 -1
- package/{build → dist}/object/filter.d.ts.map +1 -1
- package/{build → dist}/object/filter.js +38 -70
- 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 +5 -1
- package/dist/object/hash.d.ts.map +1 -0
- package/{build → dist}/object/hash.js +20 -6
- 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 +6 -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 -2
- package/{build → dist}/object/property-paths.d.ts.map +1 -1
- package/{build → dist}/object/property-paths.js +13 -9
- 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 +297 -0
- package/{build → dist}/object/sort-keys.d.ts +1 -1
- package/{build → dist}/object/sort-keys.d.ts.map +1 -1
- package/{build → dist}/object/sort-keys.js +18 -11
- package/{build → dist}/object/types.d.ts +61 -20
- package/dist/object/types.d.ts.map +1 -0
- package/dist/object/types.js +1 -0
- package/{build → dist}/string/assert.d.ts +5 -0
- package/dist/string/assert.d.ts.map +1 -0
- package/{build → dist}/string/assert.js +14 -10
- package/dist/string/case-conversion.d.ts +79 -0
- package/dist/string/case-conversion.d.ts.map +1 -0
- package/{build → dist}/string/case-conversion.js +59 -30
- package/dist/string/comparison.d.ts +20 -0
- package/dist/string/comparison.d.ts.map +1 -0
- package/dist/string/comparison.js +27 -0
- package/{build → dist}/string/formatting.d.ts +35 -22
- package/dist/string/formatting.d.ts.map +1 -0
- package/{build → dist}/string/formatting.js +40 -25
- package/{build → dist}/string/index.d.ts +1 -0
- package/{build → dist}/string/index.d.ts.map +1 -1
- package/{build → dist}/string/index.js +1 -1
- package/dist/string/transformation.d.ts +28 -0
- package/dist/string/transformation.d.ts.map +1 -0
- package/dist/string/transformation.js +42 -0
- 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/dist/string/validation.d.ts +30 -0
- package/dist/string/validation.d.ts.map +1 -0
- package/dist/string/validation.js +38 -0
- 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 +67 -15
- package/dist/time/elapsed-time/elapsed-time.d.ts.map +1 -0
- package/{build → dist}/time/elapsed-time/elapsed-time.js +172 -78
- 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/{build → dist}/time/index.d.ts +0 -2
- package/{build → dist}/time/index.d.ts.map +1 -1
- package/{build → dist}/time/index.js +0 -2
- 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 +9 -3
- package/dist/time/stopwatch/stopwatch.d.ts.map +1 -0
- package/{build → dist}/time/stopwatch/stopwatch.js +9 -4
- package/package.json +58 -81
- 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.d.ts.map +0 -1
- package/build/array/array-count-by.js.map +0 -1
- package/build/array/array-difference.d.ts +0 -25
- package/build/array/array-difference.d.ts.map +0 -1
- package/build/array/array-difference.js +0 -34
- 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.d.ts.map +0 -1
- package/build/array/array-group-by.js.map +0 -1
- package/build/array/array-intersection.d.ts +0 -25
- package/build/array/array-intersection.d.ts.map +0 -1
- package/build/array/array-intersection.js +0 -39
- 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.d.ts.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.d.ts.map +0 -1
- package/build/array/assert.js.map +0 -1
- package/build/array/index.js.map +0 -1
- package/build/array/types.d.ts.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 +0 -17
- 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.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.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.d.ts +0 -50
- package/build/string/case-conversion.d.ts.map +0 -1
- package/build/string/case-conversion.js.map +0 -1
- package/build/string/formatting.d.ts.map +0 -1
- package/build/string/formatting.js.map +0 -1
- package/build/string/index.js.map +0 -1
- package/build/string/transformation.d.ts +0 -18
- package/build/string/transformation.d.ts.map +0 -1
- package/build/string/transformation.js +0 -32
- 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.d.ts +0 -18
- package/build/string/validation.d.ts.map +0 -1
- package/build/string/validation.js +0 -26
- 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.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-element.d.ts +0 -0
- /package/{build → dist}/array/array-element.d.ts.map +0 -0
- /package/{build → dist}/array/array-range.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/index.d.ts +0 -0
- /package/{build → dist}/array/index.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/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}/object/clone.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
|
@@ -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
|
|
@@ -1 +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;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,YAAY,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,
|
|
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;;;;;;;;;;;;;;;;;;;;;;GAsBG;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
|
*
|
|
@@ -37,6 +37,10 @@ export function ObjectClone(obj, visitedInput) {
|
|
|
37
37
|
// Mark this object as visited
|
|
38
38
|
visited.add(obj);
|
|
39
39
|
}
|
|
40
|
+
// PERFORMANCE NOTE: The backtrack pattern (visited.delete() after processing composite types)
|
|
41
|
+
// uses delete/add operations on WeakSet for each Date, Array, and Object. For deeply nested
|
|
42
|
+
// structures (100+ levels), this delete/add cost accumulates. Depth tracking would optimize
|
|
43
|
+
// this, but the current implementation is correct for circular reference handling.
|
|
40
44
|
// Handle Date
|
|
41
45
|
if (obj instanceof Date) {
|
|
42
46
|
const result = new Date(obj.getTime());
|
|
@@ -52,14 +56,17 @@ export function ObjectClone(obj, visitedInput) {
|
|
|
52
56
|
return result;
|
|
53
57
|
}
|
|
54
58
|
// Handle plain objects only
|
|
55
|
-
if (obj.constructor === Object) {
|
|
59
|
+
if (obj.constructor === Object || Object.getPrototypeOf(obj) === null) {
|
|
56
60
|
// Security: Filter out dangerous keys
|
|
57
|
-
const safeObj =
|
|
61
|
+
const safeObj = FilterDangerousKeys(obj);
|
|
58
62
|
const copy = {};
|
|
59
63
|
// Object.keys() returns only own enumerable properties — no further guard needed.
|
|
60
64
|
for (const key of Object.keys(safeObj)) {
|
|
61
65
|
copy[key] = ObjectClone(safeObj[key], visited);
|
|
62
66
|
}
|
|
67
|
+
// Note: Symbol properties are intentionally not cloned. Symbols often represent
|
|
68
|
+
// object identity or metadata that should not be duplicated across instances.
|
|
69
|
+
// If symbol cloning is needed, use Object.getOwnPropertySymbols() manually.
|
|
63
70
|
visited.delete(obj); // Backtrack for the same reason as Date above.
|
|
64
71
|
return copy;
|
|
65
72
|
}
|
|
@@ -69,7 +76,7 @@ export function ObjectClone(obj, visitedInput) {
|
|
|
69
76
|
}
|
|
70
77
|
// Provide detailed error message for unsupported types
|
|
71
78
|
const typeName = typeof obj === 'object'
|
|
72
|
-
? obj
|
|
79
|
+
? Object.getPrototypeOf(obj)?.constructor?.name ?? 'Object'
|
|
73
80
|
: typeof obj;
|
|
74
81
|
throw new Error(`ObjectClone: ${typeName} objects are not supported. Create a new ${typeName} instance manually.`);
|
|
75
82
|
}
|
|
@@ -102,4 +109,3 @@ export function TransformObject(obj, transformer) {
|
|
|
102
109
|
}
|
|
103
110
|
return transformer(obj);
|
|
104
111
|
}
|
|
105
|
-
//# 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,
|
|
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,13 +48,15 @@ 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
|
+
const aObj = a;
|
|
59
|
+
const bObj = b;
|
|
58
60
|
// Handle Date objects
|
|
59
61
|
if (a instanceof Date && b instanceof Date) {
|
|
60
62
|
return a.getTime() === b.getTime();
|
|
@@ -78,27 +80,28 @@ export function ObjectEquals(a, b) {
|
|
|
78
80
|
if (Array.isArray(a) !== Array.isArray(b))
|
|
79
81
|
return false;
|
|
80
82
|
// Compare object properties
|
|
81
|
-
const keysA = Object.keys(
|
|
82
|
-
const keysB = Object.keys(
|
|
83
|
+
const keysA = Object.keys(aObj);
|
|
84
|
+
const keysB = Object.keys(bObj);
|
|
83
85
|
if (keysA.length !== keysB.length)
|
|
84
86
|
return false;
|
|
85
87
|
// Also compare symbol properties
|
|
86
|
-
const symbolsA = Object.getOwnPropertySymbols(
|
|
87
|
-
const symbolsB = Object.getOwnPropertySymbols(
|
|
88
|
+
const symbolsA = Object.getOwnPropertySymbols(aObj);
|
|
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;
|
|
88
92
|
if (symbolsA.length !== symbolsB.length)
|
|
89
93
|
return false;
|
|
90
94
|
for (const key of keysA) {
|
|
91
|
-
if (!Object.hasOwn(
|
|
95
|
+
if (!Object.hasOwn(bObj, key))
|
|
92
96
|
return false;
|
|
93
|
-
if (!ObjectEquals(
|
|
97
|
+
if (!ObjectEquals(aObj[key], bObj[key]))
|
|
94
98
|
return false;
|
|
95
99
|
}
|
|
96
100
|
for (const symbol of symbolsA) {
|
|
97
101
|
if (!symbolsB.includes(symbol))
|
|
98
102
|
return false;
|
|
99
|
-
if (!ObjectEquals(
|
|
103
|
+
if (!ObjectEquals(aObj[symbol], bObj[symbol]))
|
|
100
104
|
return false;
|
|
101
105
|
}
|
|
102
106
|
return true;
|
|
103
107
|
}
|
|
104
|
-
//# sourceMappingURL=equals.js.map
|
|
@@ -0,0 +1,44 @@
|
|
|
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>`
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const cachedFilter = ObjectFilterCached<User>({ maxCacheSize: 500 });
|
|
17
|
+
* const isAdmin = await cachedFilter(user, { role: 'admin' });
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Creates a cached version of {@link ObjectFilter} for improved performance
|
|
22
|
+
* when filtering the same objects repeatedly.
|
|
23
|
+
*
|
|
24
|
+
* Results are cached by hashing the filter and object together. When the cache
|
|
25
|
+
* exceeds `maxCacheSize`, approximately 20% of the entries in the largest
|
|
26
|
+
* per-filter bucket are evicted.
|
|
27
|
+
*
|
|
28
|
+
* @template T — The object type being filtered
|
|
29
|
+
* @param options — Configuration for both the cache and the underlying filter
|
|
30
|
+
* @returns — A cached filter function `(cursor, filter) => Promise<boolean>` that returns
|
|
31
|
+
* `true` if the object matches the filter criteria, or `false` if it does not. An empty
|
|
32
|
+
* filter argument (no properties) matches all objects.
|
|
33
|
+
* @warning Filter objects with function-valued properties are not safely cacheable because
|
|
34
|
+
* {@link ObjectHash} cannot deterministically hash function references. Two different function
|
|
35
|
+
* instances with identical behavior will hash to different values, bypassing the cache and
|
|
36
|
+
* potentially causing unexpected behavior. Avoid passing filters with methods or callbacks.
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const cachedFilter = ObjectFilterCached<User>({ maxCacheSize: 500 });
|
|
40
|
+
* const isAdmin = await cachedFilter(user, { role: 'admin' });
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function ObjectFilterCached<T extends object>(options?: ICachedObjectFilterOptions): TCachedObjectFilterFunction<T>;
|
|
44
|
+
//# sourceMappingURL=filter-cached.d.ts.map
|
|
@@ -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;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,EAAE,OAAO,GAAE,0BAA+B,GAAG,2BAA2B,CAAC,CAAC,CAAC,
|
|
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;;;;;;;;;;;;;;;;;GAiBG;AACH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,EAAE,OAAO,GAAE,0BAA+B,GAAG,2BAA2B,CAAC,CAAC,CAAC,CAmI7H"}
|
|
@@ -21,6 +21,29 @@ const CACHE_EVICTION_PERCENTAGE = 0.2; // 20%
|
|
|
21
21
|
* const isAdmin = await cachedFilter(user, { role: 'admin' });
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
|
+
/**
|
|
25
|
+
* Creates a cached version of {@link ObjectFilter} for improved performance
|
|
26
|
+
* when filtering the same objects repeatedly.
|
|
27
|
+
*
|
|
28
|
+
* Results are cached by hashing the filter and object together. When the cache
|
|
29
|
+
* exceeds `maxCacheSize`, approximately 20% of the entries in the largest
|
|
30
|
+
* per-filter bucket are evicted.
|
|
31
|
+
*
|
|
32
|
+
* @template T — The object type being filtered
|
|
33
|
+
* @param options — Configuration for both the cache and the underlying filter
|
|
34
|
+
* @returns — A cached filter function `(cursor, filter) => Promise<boolean>` that returns
|
|
35
|
+
* `true` if the object matches the filter criteria, or `false` if it does not. An empty
|
|
36
|
+
* filter argument (no properties) matches all objects.
|
|
37
|
+
* @warning Filter objects with function-valued properties are not safely cacheable because
|
|
38
|
+
* {@link ObjectHash} cannot deterministically hash function references. Two different function
|
|
39
|
+
* instances with identical behavior will hash to different values, bypassing the cache and
|
|
40
|
+
* potentially causing unexpected behavior. Avoid passing filters with methods or callbacks.
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const cachedFilter = ObjectFilterCached<User>({ maxCacheSize: 500 });
|
|
44
|
+
* const isAdmin = await cachedFilter(user, { role: 'admin' });
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
24
47
|
export function ObjectFilterCached(options = {}) {
|
|
25
48
|
const { maxCacheSize = DEFAULT_MAX_CACHE_SIZE, useDeepEqual = false, caseInsensitiveStrings = false, validatePaths = true, } = options;
|
|
26
49
|
const cache = new Map();
|
|
@@ -31,6 +54,11 @@ export function ObjectFilterCached(options = {}) {
|
|
|
31
54
|
*
|
|
32
55
|
* The eviction strategy targets the most-populated bucket to reclaim the most
|
|
33
56
|
* memory in a single pass while preserving results for other active filters.
|
|
57
|
+
*
|
|
58
|
+
* PERFORMANCE NOTE: For distributed filter load, eviction triggers too frequently.
|
|
59
|
+
* A true global LRU across all filters would be more efficient but would require
|
|
60
|
+
* tracking access order globally. Refactoring to use the library's own LRUCache
|
|
61
|
+
* (if available) instead of per-filter Maps would improve this further.
|
|
34
62
|
*/
|
|
35
63
|
const clearOldestEntries = () => {
|
|
36
64
|
if (cache.size === 0)
|
|
@@ -47,6 +75,8 @@ export function ObjectFilterCached(options = {}) {
|
|
|
47
75
|
}
|
|
48
76
|
}
|
|
49
77
|
if (largestCache) {
|
|
78
|
+
// Capture the original bucket size before eviction
|
|
79
|
+
const originalBucketSize = largestCache.size;
|
|
50
80
|
// Remove approximately 20% of entries from the largest cache
|
|
51
81
|
const entriesToRemove = Math.ceil(largestSize * CACHE_EVICTION_PERCENTAGE);
|
|
52
82
|
let removed = 0;
|
|
@@ -59,8 +89,18 @@ export function ObjectFilterCached(options = {}) {
|
|
|
59
89
|
// If the cache is now empty, remove it completely
|
|
60
90
|
if (largestCache.size === 0) {
|
|
61
91
|
cache.delete(largestCacheKey);
|
|
92
|
+
// Account for all entries that were in the bucket (not just the ones we explicitly removed)
|
|
93
|
+
totalCachedEntries -= originalBucketSize;
|
|
62
94
|
}
|
|
63
|
-
|
|
95
|
+
else {
|
|
96
|
+
// Only remove the entries we explicitly deleted
|
|
97
|
+
totalCachedEntries -= removed;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
// Recompute counter to eliminate drift
|
|
101
|
+
totalCachedEntries = 0;
|
|
102
|
+
for (const bucket of cache.values()) {
|
|
103
|
+
totalCachedEntries += bucket.size;
|
|
64
104
|
}
|
|
65
105
|
};
|
|
66
106
|
return (cursor, filter) => {
|
|
@@ -115,4 +155,3 @@ export function ObjectFilterCached(options = {}) {
|
|
|
115
155
|
return Promise.resolve(result);
|
|
116
156
|
};
|
|
117
157
|
}
|
|
118
|
-
//# sourceMappingURL=filter-cached.js.map
|
|
@@ -64,7 +64,7 @@ import type { IObjectFilterOptions, TPropertyFilter } from './types.js';
|
|
|
64
64
|
* ObjectFilter(user, { age: (v) => v < 18 }); // false
|
|
65
65
|
* ```
|
|
66
66
|
*/
|
|
67
|
-
export declare function ObjectFilter<T>(object: T, filter: Record<string,
|
|
67
|
+
export declare function ObjectFilter<T>(object: T, filter: Record<string, unknown>, options?: IObjectFilterOptions): boolean;
|
|
68
68
|
/**
|
|
69
69
|
* Filters an object's properties using a predicate function.
|
|
70
70
|
* Creates a new object containing only the properties for which the predicate returns true.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/object/filter.ts"],"names":[],"mappings":"
|
|
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;AAyFxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,40 +1,48 @@
|
|
|
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
|
+
import { StringEquals } from '../string/comparison.js';
|
|
4
5
|
/**
|
|
5
|
-
* Compares two
|
|
6
|
+
* Compares two values for ObjectFilter with support for predicates, case-insensitive strings,
|
|
7
|
+
* and deep equality via ObjectEquals.
|
|
6
8
|
*
|
|
7
9
|
* @param objValue - The object value to compare
|
|
8
10
|
* @param filterValue - The filter value to compare against
|
|
9
11
|
* @param caseInsensitiveStrings - Whether to use case-insensitive string comparison
|
|
10
|
-
* @
|
|
12
|
+
* @param useDeepEqual - Whether to use deep equality for nested objects
|
|
13
|
+
* @returns True if the values match according to filter comparison rules
|
|
11
14
|
*/
|
|
12
|
-
function
|
|
15
|
+
function compareValuesForFilter(objValue, filterValue, caseInsensitiveStrings = false, useDeepEqual = false) {
|
|
13
16
|
// Handle function as predicate
|
|
14
17
|
if (typeof filterValue === 'function') {
|
|
15
18
|
return filterValue(objValue);
|
|
16
19
|
}
|
|
17
|
-
// Handle string comparison
|
|
20
|
+
// Handle case-insensitive string comparison (filter-specific feature)
|
|
18
21
|
if (caseInsensitiveStrings && typeof objValue === 'string' && typeof filterValue === 'string') {
|
|
19
|
-
return objValue
|
|
22
|
+
return StringEquals(objValue, filterValue, true);
|
|
20
23
|
}
|
|
21
|
-
// Special handling for
|
|
22
|
-
if (objValue
|
|
23
|
-
return
|
|
24
|
+
// Special handling for NaN - ObjectEquals handles this, but strict equality doesn't
|
|
25
|
+
if (typeof objValue === 'number' && typeof filterValue === 'number' && isNaN(objValue) && isNaN(filterValue)) {
|
|
26
|
+
return true;
|
|
24
27
|
}
|
|
25
28
|
// Handle array cases: if objValue is an array, use array comparison logic
|
|
26
29
|
if (Array.isArray(objValue)) {
|
|
27
|
-
return objectHandleArrayComparison(objValue, filterValue, caseInsensitiveStrings,
|
|
30
|
+
return objectHandleArrayComparison(objValue, filterValue, caseInsensitiveStrings, useDeepEqual);
|
|
28
31
|
}
|
|
29
32
|
// For deeply nested structures, check if filter is a subset of the object
|
|
30
33
|
if (typeof objValue === 'object' && objValue !== null && typeof filterValue === 'object' && filterValue !== null && !Array.isArray(filterValue)) {
|
|
31
34
|
return ObjectFilter(objValue, filterValue, { useDeepEqual: true, caseInsensitiveStrings });
|
|
32
35
|
}
|
|
33
|
-
//
|
|
34
|
-
|
|
36
|
+
// Use deep equality if requested; otherwise use strict equality
|
|
37
|
+
if (useDeepEqual) {
|
|
38
|
+
return ObjectEquals(objValue, filterValue);
|
|
39
|
+
}
|
|
40
|
+
// Default: strict equality
|
|
41
|
+
return objValue === filterValue;
|
|
35
42
|
}
|
|
36
43
|
/**
|
|
37
|
-
* Handles array filtering logic with support for string inclusion and subset matching
|
|
44
|
+
* Handles array filtering logic with support for string inclusion and subset matching.
|
|
45
|
+
* Uses compareValuesForFilter for consistent comparison logic.
|
|
38
46
|
*
|
|
39
47
|
* @param objValue - The array value from the object
|
|
40
48
|
* @param filterValue - The filter value to match against
|
|
@@ -46,53 +54,24 @@ function objectHandleArrayComparison(objValue, filterValue, caseInsensitiveStrin
|
|
|
46
54
|
// If filterValue is a string, check if it exists in the array
|
|
47
55
|
if (typeof filterValue === 'string') {
|
|
48
56
|
if (caseInsensitiveStrings) {
|
|
49
|
-
return objValue.some((item) => typeof item === 'string' && item
|
|
57
|
+
return objValue.some((item) => typeof item === 'string' && StringEquals(item, filterValue, true));
|
|
50
58
|
}
|
|
51
59
|
return objValue.includes(filterValue);
|
|
52
60
|
}
|
|
53
61
|
// If filterValue is also an array, check if it's a subset
|
|
54
62
|
if (Array.isArray(filterValue)) {
|
|
55
|
-
|
|
63
|
+
// PERFORMANCE: For arrays of primitives without deep equality or case-insensitive matching,
|
|
64
|
+
// use a Set-based approach for O(n+m) performance instead of nested loops.
|
|
65
|
+
if (!useDeepEqual && !caseInsensitiveStrings && filterValue.every((item) => typeof item !== 'object' || item === null)) {
|
|
66
|
+
const objSet = new Set(objValue);
|
|
67
|
+
return filterValue.every((item) => objSet.has(item));
|
|
68
|
+
}
|
|
69
|
+
// For object arrays or when deep equality is enabled, fall back to nested loop comparison
|
|
70
|
+
// (reference equality for objects, deep equality if requested)
|
|
71
|
+
return filterValue.every((item) => objValue.some((objItem) => compareValuesForFilter(objItem, item, caseInsensitiveStrings, useDeepEqual)));
|
|
56
72
|
}
|
|
57
73
|
// For non-string, non-array filter values, check direct inclusion
|
|
58
|
-
return objValue.some((item) =>
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Compare values based on filter criteria
|
|
62
|
-
*
|
|
63
|
-
* @param objValue The object value
|
|
64
|
-
* @param filterValue The filter value to compare against
|
|
65
|
-
* @param caseInsensitiveStrings Whether to do case-insensitive string comparison
|
|
66
|
-
* @param useDeepEqual Whether to use deep equality for nested objects
|
|
67
|
-
* @returns True if values match according to specified criteria
|
|
68
|
-
*/
|
|
69
|
-
function objectCompareValues(objValue, filterValue, caseInsensitiveStrings, useDeepEqual = false) {
|
|
70
|
-
// Handle function as predicate
|
|
71
|
-
if (typeof filterValue === 'function') {
|
|
72
|
-
return filterValue(objValue);
|
|
73
|
-
}
|
|
74
|
-
// Check if objValue is an array
|
|
75
|
-
if (Array.isArray(objValue)) {
|
|
76
|
-
return objectHandleArrayComparison(objValue, filterValue, caseInsensitiveStrings, useDeepEqual);
|
|
77
|
-
}
|
|
78
|
-
// Handle string comparison with case insensitivity option
|
|
79
|
-
if (caseInsensitiveStrings && typeof objValue === 'string' && typeof filterValue === 'string') {
|
|
80
|
-
return objValue.toLowerCase() === filterValue.toLowerCase();
|
|
81
|
-
}
|
|
82
|
-
// Special handling for NaN
|
|
83
|
-
if (typeof objValue === 'number' && typeof filterValue === 'number' && isNaN(objValue) && isNaN(filterValue)) {
|
|
84
|
-
return true;
|
|
85
|
-
}
|
|
86
|
-
// For object filtering with useDeepEqual, check if filterValue is a subset of objValue
|
|
87
|
-
if (useDeepEqual && typeof objValue === 'object' && objValue !== null && typeof filterValue === 'object' && filterValue !== null && !Array.isArray(filterValue)) {
|
|
88
|
-
return ObjectFilter(objValue, filterValue, { useDeepEqual: true, caseInsensitiveStrings });
|
|
89
|
-
}
|
|
90
|
-
// Use deep equality if requested
|
|
91
|
-
if (useDeepEqual) {
|
|
92
|
-
return ObjectEquals(objValue, filterValue);
|
|
93
|
-
}
|
|
94
|
-
// Default strict equality
|
|
95
|
-
return objValue === filterValue;
|
|
74
|
+
return objValue.some((item) => compareValuesForFilter(item, filterValue, caseInsensitiveStrings, useDeepEqual));
|
|
96
75
|
}
|
|
97
76
|
/**
|
|
98
77
|
* Filters an object based on a provided filter using flexible matching criteria.
|
|
@@ -163,26 +142,21 @@ export function ObjectFilter(object, filter, options = {}) {
|
|
|
163
142
|
// Default options
|
|
164
143
|
const { useDeepEqual = false, caseInsensitiveStrings = false, validatePaths = false } = options;
|
|
165
144
|
for (const key in filter) {
|
|
166
|
-
|
|
167
|
-
if (!Object.hasOwn(filter, key))
|
|
145
|
+
if (!Object.hasOwn(filter, key)) {
|
|
168
146
|
continue;
|
|
147
|
+
}
|
|
169
148
|
// Handle dot notation paths
|
|
170
149
|
if (key.includes('.')) {
|
|
171
|
-
if (validatePaths && !
|
|
150
|
+
if (validatePaths && !IsPropertyPathSafe(key)) {
|
|
172
151
|
return false;
|
|
173
152
|
}
|
|
174
153
|
const objValue = ObjectGetPropertyByPath(object, key);
|
|
175
154
|
if (objValue === undefined) {
|
|
176
155
|
return false;
|
|
177
156
|
}
|
|
178
|
-
// Compare the values
|
|
157
|
+
// Compare the values using the consolidated function
|
|
179
158
|
const filterValue = filter[key];
|
|
180
|
-
if (useDeepEqual) {
|
|
181
|
-
if (!objectDeepComparison(objValue, filterValue, caseInsensitiveStrings)) {
|
|
182
|
-
return false;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
else if (!objectCompareValues(objValue, filterValue, caseInsensitiveStrings, useDeepEqual)) {
|
|
159
|
+
if (!compareValuesForFilter(objValue, filterValue, caseInsensitiveStrings, useDeepEqual)) {
|
|
186
160
|
return false;
|
|
187
161
|
}
|
|
188
162
|
}
|
|
@@ -193,12 +167,7 @@ export function ObjectFilter(object, filter, options = {}) {
|
|
|
193
167
|
if (!(key in object)) {
|
|
194
168
|
return false;
|
|
195
169
|
}
|
|
196
|
-
if (useDeepEqual) {
|
|
197
|
-
if (!objectDeepComparison(objValue, filterValue, caseInsensitiveStrings)) {
|
|
198
|
-
return false;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
else if (!objectCompareValues(objValue, filterValue, caseInsensitiveStrings, useDeepEqual)) {
|
|
170
|
+
if (!compareValuesForFilter(objValue, filterValue, caseInsensitiveStrings, useDeepEqual)) {
|
|
202
171
|
return false;
|
|
203
172
|
}
|
|
204
173
|
}
|
|
@@ -242,4 +211,3 @@ export function FilterObject(obj, predicate) {
|
|
|
242
211
|
}
|
|
243
212
|
return result;
|
|
244
213
|
}
|
|
245
|
-
//# 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
|
|
@@ -23,5 +27,5 @@
|
|
|
23
27
|
* );
|
|
24
28
|
* ```
|
|
25
29
|
*/
|
|
26
|
-
export declare function ObjectHash(obj:
|
|
30
|
+
export declare function ObjectHash(obj: unknown, hashFunction?: (data: string) => string): string;
|
|
27
31
|
//# sourceMappingURL=hash.d.ts.map
|
|
@@ -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"}
|