@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
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @template T - The type of array elements
|
|
5
5
|
* @param array - The array to split
|
|
6
6
|
* @param size - Size of each chunk (last chunk may be smaller)
|
|
7
|
-
* @returns Array of arrays, each of the specified size
|
|
7
|
+
* @returns Array of arrays, each of the specified size. Returns `[]` if `array` is `null`, `undefined`, or `size` is not positive.
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* ```typescript
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* ```
|
|
14
14
|
*/
|
|
15
15
|
export function ArrayChunk(array, size) {
|
|
16
|
-
if (array
|
|
16
|
+
if (array == null || !(size > 0)) {
|
|
17
17
|
return [];
|
|
18
18
|
}
|
|
19
19
|
const result = [];
|
|
@@ -22,4 +22,3 @@ export function ArrayChunk(array, size) {
|
|
|
22
22
|
}
|
|
23
23
|
return result;
|
|
24
24
|
}
|
|
25
|
-
//# sourceMappingURL=array-chunk.js.map
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @template T - The non-nullish element type
|
|
5
5
|
* @param array - The array to compact
|
|
6
|
-
* @returns A new array with `null`/`undefined` entries removed
|
|
6
|
+
* @returns A new array with `null`/`undefined` entries removed. Returns `[]` if `array` is `null` or `undefined`.
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* ```typescript
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @template T - The non-nullish element type
|
|
5
5
|
* @param array - The array to compact
|
|
6
|
-
* @returns A new array with `null`/`undefined` entries removed
|
|
6
|
+
* @returns A new array with `null`/`undefined` entries removed. Returns `[]` if `array` is `null` or `undefined`.
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* ```typescript
|
|
@@ -19,4 +19,3 @@ export function ArrayCompact(array) {
|
|
|
19
19
|
return [];
|
|
20
20
|
return array.filter((item) => item !== null && item !== undefined);
|
|
21
21
|
}
|
|
22
|
-
//# sourceMappingURL=array-compact.js.map
|
|
@@ -2,10 +2,13 @@ import type { TPredicate } from './types.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Checks if an array contains at least one element that passes a predicate test.
|
|
4
4
|
*
|
|
5
|
+
* Uses `array.some()` to check if any element satisfies the predicate condition.
|
|
6
|
+
* Returns false if the array is null, undefined, or empty.
|
|
7
|
+
*
|
|
5
8
|
* @template T - The type of array elements
|
|
6
9
|
* @param array - The array to check
|
|
7
10
|
* @param predicate - A function that tests each element; returns `true` to signal a match
|
|
8
|
-
* @returns `true` if at least one element passes the test, `false`
|
|
11
|
+
* @returns `true` if at least one element passes the test, `false` if no element passes, the array is `null`, `undefined`, or empty
|
|
9
12
|
*
|
|
10
13
|
* @example
|
|
11
14
|
* ```typescript
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-contains.d.ts","sourceRoot":"","sources":["../../src/array/array-contains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C
|
|
1
|
+
{"version":3,"file":"array-contains.d.ts","sourceRoot":"","sources":["../../src/array/array-contains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,OAAO,CAOvF"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Checks if an array contains at least one element that passes a predicate test.
|
|
3
3
|
*
|
|
4
|
+
* Uses `array.some()` to check if any element satisfies the predicate condition.
|
|
5
|
+
* Returns false if the array is null, undefined, or empty.
|
|
6
|
+
*
|
|
4
7
|
* @template T - The type of array elements
|
|
5
8
|
* @param array - The array to check
|
|
6
9
|
* @param predicate - A function that tests each element; returns `true` to signal a match
|
|
7
|
-
* @returns `true` if at least one element passes the test, `false`
|
|
10
|
+
* @returns `true` if at least one element passes the test, `false` if no element passes, the array is `null`, `undefined`, or empty
|
|
8
11
|
*
|
|
9
12
|
* @example
|
|
10
13
|
* ```typescript
|
|
@@ -13,9 +16,9 @@
|
|
|
13
16
|
* ```
|
|
14
17
|
*/
|
|
15
18
|
export function ArrayContains(array, predicate) {
|
|
16
|
-
|
|
19
|
+
// Predicate functions use array.some() / array.every() for consistency
|
|
20
|
+
if (array === null || array === undefined || array.length === 0) {
|
|
17
21
|
return false;
|
|
18
22
|
}
|
|
19
23
|
return array.some(predicate);
|
|
20
24
|
}
|
|
21
|
-
//# sourceMappingURL=array-contains.js.map
|
|
@@ -2,11 +2,13 @@ import type { TTransform } from './types.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Counts how many elements fall into each group defined by `keyFn`.
|
|
4
4
|
*
|
|
5
|
+
* Returns empty object if array is null, undefined, or empty.
|
|
6
|
+
*
|
|
5
7
|
* @template T - The type of array elements
|
|
6
8
|
* @template K - The key type (string, number, or symbol)
|
|
7
9
|
* @param array - The array to count
|
|
8
10
|
* @param keyFn - Function that assigns each element to a group key
|
|
9
|
-
* @returns A record where keys are group identifiers and values are occurrence counts
|
|
11
|
+
* @returns A record where keys are group identifiers and values are occurrence counts. Returns `{}` if `array` is `null`, `undefined`, or an empty array.
|
|
10
12
|
*
|
|
11
13
|
* @example
|
|
12
14
|
* ```typescript
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-count-by.d.ts","sourceRoot":"","sources":["../../src/array/array-count-by.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EACjE,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,GACrB,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAYnB"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Counts how many elements fall into each group defined by `keyFn`.
|
|
3
3
|
*
|
|
4
|
+
* Returns empty object if array is null, undefined, or empty.
|
|
5
|
+
*
|
|
4
6
|
* @template T - The type of array elements
|
|
5
7
|
* @template K - The key type (string, number, or symbol)
|
|
6
8
|
* @param array - The array to count
|
|
7
9
|
* @param keyFn - Function that assigns each element to a group key
|
|
8
|
-
* @returns A record where keys are group identifiers and values are occurrence counts
|
|
10
|
+
* @returns A record where keys are group identifiers and values are occurrence counts. Returns `{}` if `array` is `null`, `undefined`, or an empty array.
|
|
9
11
|
*
|
|
10
12
|
* @example
|
|
11
13
|
* ```typescript
|
|
@@ -17,6 +19,7 @@
|
|
|
17
19
|
* ```
|
|
18
20
|
*/
|
|
19
21
|
export function ArrayCountBy(array, keyFn) {
|
|
22
|
+
// Consistent null-check: early return for null/undefined arrays
|
|
20
23
|
if (array === null || array === undefined)
|
|
21
24
|
return {};
|
|
22
25
|
const result = {};
|
|
@@ -26,4 +29,3 @@ export function ArrayCountBy(array, keyFn) {
|
|
|
26
29
|
}
|
|
27
30
|
return result;
|
|
28
31
|
}
|
|
29
|
-
//# sourceMappingURL=array-count-by.js.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { TArrayComparisonOptions } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Returns elements present in the first array but not in the second (set difference).
|
|
4
|
+
* Optimised O(n+m) using a Set when no custom comparator is provided.
|
|
5
|
+
* Supports custom comparators for advanced comparison logic, deep equality checking, or key extraction.
|
|
6
|
+
*
|
|
7
|
+
* @template T - The type of array elements
|
|
8
|
+
* @param array1 - The source array
|
|
9
|
+
* @param array2 - Elements to exclude
|
|
10
|
+
* @param options - Optional configuration. Choose one strategy: `comparator`, `useDeepEqual`, or `keyFn`.
|
|
11
|
+
* @param options.comparator - Custom function to determine if elements are equal (optional)
|
|
12
|
+
* @param options.useDeepEqual - Use deep equality for comparison (optional)
|
|
13
|
+
* @param options.keyFn - Optional function to extract a primitive key for O(n+m) Set-based lookup. When provided, enables efficient comparison by mapping each item to a key that can be stored in a Set. Example: `{ keyFn: item => item.id }` for objects with a unique id field.
|
|
14
|
+
* @returns Array of elements in `array1` that are not in `array2`. Returns `[]` if `array1` is `null`, `undefined`, or an empty array.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* // Basic difference with primitives
|
|
19
|
+
* ArrayDifference([1, 2, 3, 4], [2, 4]); // [1, 3]
|
|
20
|
+
*
|
|
21
|
+
* // Deep equality comparison with objects
|
|
22
|
+
* const arr1 = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];
|
|
23
|
+
* const arr2 = [{ id: 2, name: 'Bob' }, { id: 3, name: 'Charlie' }];
|
|
24
|
+
* ArrayDifference(arr1, arr2, { useDeepEqual: true });
|
|
25
|
+
* // [{ id: 1, name: 'Alice' }]
|
|
26
|
+
*
|
|
27
|
+
* // Custom comparator
|
|
28
|
+
* ArrayDifference(arr1, arr2, {
|
|
29
|
+
* comparator: (a, b) => a.id === b.id
|
|
30
|
+
* });
|
|
31
|
+
* // [{ id: 1, name: 'Alice' }]
|
|
32
|
+
*
|
|
33
|
+
* // Key function for O(n+m) lookup
|
|
34
|
+
* ArrayDifference(arr1, arr2, {
|
|
35
|
+
* keyFn: item => item.id
|
|
36
|
+
* });
|
|
37
|
+
* // [{ id: 1, name: 'Alice' }]
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @complexity O(n+m) for primitive values, O(n+m) with keyFn, O(n*m) when a comparator or deep equality is provided
|
|
41
|
+
*/
|
|
42
|
+
export declare function ArrayDifference<T>(array1: readonly T[], array2: readonly T[], options?: TArrayComparisonOptions<T>): T[];
|
|
43
|
+
//# sourceMappingURL=array-difference.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-difference.d.ts","sourceRoot":"","sources":["../../src/array/array-difference.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAG1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAChC,MAAM,EAAE,SAAS,CAAC,EAAE,EACpB,MAAM,EAAE,SAAS,CAAC,EAAE,EACpB,OAAO,CAAC,EAAE,uBAAuB,CAAC,CAAC,CAAC,GAClC,CAAC,EAAE,CA+BL"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { ObjectEquals } from '../object/equals.js';
|
|
2
|
+
/**
|
|
3
|
+
* Returns elements present in the first array but not in the second (set difference).
|
|
4
|
+
* Optimised O(n+m) using a Set when no custom comparator is provided.
|
|
5
|
+
* Supports custom comparators for advanced comparison logic, deep equality checking, or key extraction.
|
|
6
|
+
*
|
|
7
|
+
* @template T - The type of array elements
|
|
8
|
+
* @param array1 - The source array
|
|
9
|
+
* @param array2 - Elements to exclude
|
|
10
|
+
* @param options - Optional configuration. Choose one strategy: `comparator`, `useDeepEqual`, or `keyFn`.
|
|
11
|
+
* @param options.comparator - Custom function to determine if elements are equal (optional)
|
|
12
|
+
* @param options.useDeepEqual - Use deep equality for comparison (optional)
|
|
13
|
+
* @param options.keyFn - Optional function to extract a primitive key for O(n+m) Set-based lookup. When provided, enables efficient comparison by mapping each item to a key that can be stored in a Set. Example: `{ keyFn: item => item.id }` for objects with a unique id field.
|
|
14
|
+
* @returns Array of elements in `array1` that are not in `array2`. Returns `[]` if `array1` is `null`, `undefined`, or an empty array.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* // Basic difference with primitives
|
|
19
|
+
* ArrayDifference([1, 2, 3, 4], [2, 4]); // [1, 3]
|
|
20
|
+
*
|
|
21
|
+
* // Deep equality comparison with objects
|
|
22
|
+
* const arr1 = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];
|
|
23
|
+
* const arr2 = [{ id: 2, name: 'Bob' }, { id: 3, name: 'Charlie' }];
|
|
24
|
+
* ArrayDifference(arr1, arr2, { useDeepEqual: true });
|
|
25
|
+
* // [{ id: 1, name: 'Alice' }]
|
|
26
|
+
*
|
|
27
|
+
* // Custom comparator
|
|
28
|
+
* ArrayDifference(arr1, arr2, {
|
|
29
|
+
* comparator: (a, b) => a.id === b.id
|
|
30
|
+
* });
|
|
31
|
+
* // [{ id: 1, name: 'Alice' }]
|
|
32
|
+
*
|
|
33
|
+
* // Key function for O(n+m) lookup
|
|
34
|
+
* ArrayDifference(arr1, arr2, {
|
|
35
|
+
* keyFn: item => item.id
|
|
36
|
+
* });
|
|
37
|
+
* // [{ id: 1, name: 'Alice' }]
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @complexity O(n+m) for primitive values, O(n+m) with keyFn, O(n*m) when a comparator or deep equality is provided
|
|
41
|
+
*/
|
|
42
|
+
export function ArrayDifference(array1, array2, options) {
|
|
43
|
+
if (!array1)
|
|
44
|
+
return [];
|
|
45
|
+
if (!array2 || array2.length === 0)
|
|
46
|
+
return [...array1];
|
|
47
|
+
// Type narrowing: determine which strategy to use
|
|
48
|
+
if (!options) {
|
|
49
|
+
// No options: use reference equality (===)
|
|
50
|
+
const set2 = new Set(array2);
|
|
51
|
+
return array1.filter((item) => !set2.has(item));
|
|
52
|
+
}
|
|
53
|
+
if ('keyFn' in options && options.keyFn !== undefined) {
|
|
54
|
+
// Use key function for O(n+m) Set-based lookup
|
|
55
|
+
const keyFn = options.keyFn;
|
|
56
|
+
const set2 = new Set(array2.map(keyFn));
|
|
57
|
+
return array1.filter((item) => !set2.has(keyFn(item)));
|
|
58
|
+
}
|
|
59
|
+
if ('comparator' in options && options.comparator !== undefined) {
|
|
60
|
+
// Use custom comparator
|
|
61
|
+
return array1.filter((item) => !array2.some((other) => options.comparator(item, other)));
|
|
62
|
+
}
|
|
63
|
+
if (options.useDeepEqual) {
|
|
64
|
+
// Use deep equality
|
|
65
|
+
return array1.filter((item) => !array2.some((other) => ObjectEquals(item, other)));
|
|
66
|
+
}
|
|
67
|
+
// Fallback (should not reach here with proper type narrowing)
|
|
68
|
+
const set2 = new Set(array2);
|
|
69
|
+
return array1.filter((item) => !set2.has(item));
|
|
70
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,9 +3,11 @@ import type { TPredicate } from './types.js';
|
|
|
3
3
|
* Filters an array based on criteria that can be an object filter or a predicate function.
|
|
4
4
|
* Supports nested property filtering with dot notation and array property filtering.
|
|
5
5
|
*
|
|
6
|
+
* Returns empty array if input is null, undefined, or empty.
|
|
7
|
+
*
|
|
6
8
|
* @param array - The array to filter
|
|
7
9
|
* @param criteria - Either an object with filter criteria or a predicate function
|
|
8
|
-
* @returns A new array containing only items that match the criteria
|
|
10
|
+
* @returns A new array containing only items that match the criteria. Returns `[]` if `array` is `null`, `undefined`, or empty.
|
|
9
11
|
*
|
|
10
12
|
* @example
|
|
11
13
|
* // Simple property filtering
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-filter.d.ts","sourceRoot":"","sources":["../../src/array/array-filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAsC7C
|
|
1
|
+
{"version":3,"file":"array-filter.d.ts","sourceRoot":"","sources":["../../src/array/array-filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAsC7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC5B,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,GACxD,CAAC,EAAE,CAgBL"}
|
|
@@ -35,9 +35,11 @@ function matchesValue(value, filterValue) {
|
|
|
35
35
|
* Filters an array based on criteria that can be an object filter or a predicate function.
|
|
36
36
|
* Supports nested property filtering with dot notation and array property filtering.
|
|
37
37
|
*
|
|
38
|
+
* Returns empty array if input is null, undefined, or empty.
|
|
39
|
+
*
|
|
38
40
|
* @param array - The array to filter
|
|
39
41
|
* @param criteria - Either an object with filter criteria or a predicate function
|
|
40
|
-
* @returns A new array containing only items that match the criteria
|
|
42
|
+
* @returns A new array containing only items that match the criteria. Returns `[]` if `array` is `null`, `undefined`, or empty.
|
|
41
43
|
*
|
|
42
44
|
* @example
|
|
43
45
|
* // Simple property filtering
|
|
@@ -66,7 +68,8 @@ function matchesValue(value, filterValue) {
|
|
|
66
68
|
* ArrayFilter(numbers, (n) => n > 3); // [4, 5]
|
|
67
69
|
*/
|
|
68
70
|
export function ArrayFilter(array, criteria) {
|
|
69
|
-
|
|
71
|
+
// Consistent null-check: early return for null/undefined arrays
|
|
72
|
+
if (!array)
|
|
70
73
|
return [];
|
|
71
74
|
// If criteria is a function, use it as predicate
|
|
72
75
|
if (typeof criteria === 'function') {
|
|
@@ -80,4 +83,3 @@ export function ArrayFilter(array, criteria) {
|
|
|
80
83
|
});
|
|
81
84
|
});
|
|
82
85
|
}
|
|
83
|
-
//# sourceMappingURL=array-filter.js.map
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @template T - The leaf element type
|
|
5
5
|
* @param array - The nested array to flatten
|
|
6
6
|
* @param depth - How many levels deep to flatten (default: `Infinity`)
|
|
7
|
-
* @returns Flattened array of `T`
|
|
7
|
+
* @returns Flattened array of `T`. Returns `[]` if `array` is `null` or `undefined`.
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* ```typescript
|
|
@@ -12,5 +12,5 @@
|
|
|
12
12
|
* ArrayFlatten([1, [2, [3]]], 1); // [1, 2, [3]]
|
|
13
13
|
* ```
|
|
14
14
|
*/
|
|
15
|
-
export declare function ArrayFlatten<T = unknown>(array: readonly
|
|
15
|
+
export declare function ArrayFlatten<T = unknown>(array: readonly unknown[], depth?: number): T[];
|
|
16
16
|
//# sourceMappingURL=array-flatten.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-flatten.d.ts","sourceRoot":"","sources":["../../src/array/array-flatten.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"array-flatten.d.ts","sourceRoot":"","sources":["../../src/array/array-flatten.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,SAAS,OAAO,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,CAAC,EAAE,CAGxF"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @template T - The leaf element type
|
|
5
5
|
* @param array - The nested array to flatten
|
|
6
6
|
* @param depth - How many levels deep to flatten (default: `Infinity`)
|
|
7
|
-
* @returns Flattened array of `T`
|
|
7
|
+
* @returns Flattened array of `T`. Returns `[]` if `array` is `null` or `undefined`.
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* ```typescript
|
|
@@ -17,4 +17,3 @@ export function ArrayFlatten(array, depth) {
|
|
|
17
17
|
return [];
|
|
18
18
|
return array.flat(depth ?? Infinity);
|
|
19
19
|
}
|
|
20
|
-
//# sourceMappingURL=array-flatten.js.map
|
|
@@ -2,11 +2,13 @@ import type { TTransform } from './types.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Groups array elements by a key generated by a provided function.
|
|
4
4
|
*
|
|
5
|
+
* Returns empty object if array is null, undefined, or empty.
|
|
6
|
+
*
|
|
5
7
|
* @template T - The type of array elements
|
|
6
8
|
* @template K - The key type (string, number, or symbol)
|
|
7
9
|
* @param array - The array to group
|
|
8
10
|
* @param keyFn - Function that returns the grouping key for each element
|
|
9
|
-
* @returns A record where each key maps to an array of matching elements
|
|
11
|
+
* @returns A record where each key maps to an array of matching elements. Returns `{}` if `array` is `null`, `undefined`, or an empty array.
|
|
10
12
|
*
|
|
11
13
|
* @example
|
|
12
14
|
* ```typescript
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-group-by.d.ts","sourceRoot":"","sources":["../../src/array/array-group-by.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAgBhI"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Groups array elements by a key generated by a provided function.
|
|
3
3
|
*
|
|
4
|
+
* Returns empty object if array is null, undefined, or empty.
|
|
5
|
+
*
|
|
4
6
|
* @template T - The type of array elements
|
|
5
7
|
* @template K - The key type (string, number, or symbol)
|
|
6
8
|
* @param array - The array to group
|
|
7
9
|
* @param keyFn - Function that returns the grouping key for each element
|
|
8
|
-
* @returns A record where each key maps to an array of matching elements
|
|
10
|
+
* @returns A record where each key maps to an array of matching elements. Returns `{}` if `array` is `null`, `undefined`, or an empty array.
|
|
9
11
|
*
|
|
10
12
|
* @example
|
|
11
13
|
* ```typescript
|
|
@@ -18,16 +20,18 @@
|
|
|
18
20
|
* ```
|
|
19
21
|
*/
|
|
20
22
|
export function ArrayGroupBy(array, keyFn) {
|
|
23
|
+
// Consistent null-check: early return for null/undefined arrays
|
|
21
24
|
if (array === null || array === undefined) {
|
|
22
25
|
return {};
|
|
23
26
|
}
|
|
24
|
-
|
|
27
|
+
// Use imperative loop instead of reduce for slightly better performance on large arrays
|
|
28
|
+
const result = {};
|
|
29
|
+
for (const item of array) {
|
|
25
30
|
const key = keyFn(item);
|
|
26
|
-
if (!
|
|
27
|
-
|
|
31
|
+
if (!result[key]) {
|
|
32
|
+
result[key] = [];
|
|
28
33
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
34
|
+
result[key].push(item);
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
32
37
|
}
|
|
33
|
-
//# sourceMappingURL=array-group-by.js.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { TArrayComparisonOptions } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the intersection of two arrays (elements present in both)
|
|
4
|
+
* Optimized O(n+m) complexity using Set-based approach.
|
|
5
|
+
* Supports custom comparators for advanced comparison logic, deep equality checking, or key extraction.
|
|
6
|
+
*
|
|
7
|
+
* @template T - The type of array elements
|
|
8
|
+
* @param array1 - First array
|
|
9
|
+
* @param array2 - Second array
|
|
10
|
+
* @param options - Optional configuration. Choose one strategy: `comparator`, `useDeepEqual`, or `keyFn`.
|
|
11
|
+
* @param options.comparator - Custom function to determine if elements are equal (optional)
|
|
12
|
+
* @param options.useDeepEqual - Use deep equality for comparison (optional)
|
|
13
|
+
* @param options.keyFn - Optional function to extract a primitive key for O(n+m) Set-based lookup. When provided, enables efficient comparison by mapping each item to a key that can be stored in a Set. Example: `{ keyFn: item => item.id }` for objects with a unique id field.
|
|
14
|
+
* @returns Array containing elements present in both arrays. Returns `[]` if either `array1` or `array2` is `null`, `undefined`, or an empty array.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* // Basic intersection with primitives
|
|
19
|
+
* ArrayIntersection([1, 2, 3], [2, 3, 4]); // [2, 3]
|
|
20
|
+
*
|
|
21
|
+
* // Deep equality comparison with objects
|
|
22
|
+
* const arr1 = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];
|
|
23
|
+
* const arr2 = [{ id: 2, name: 'Bob' }, { id: 3, name: 'Charlie' }];
|
|
24
|
+
* ArrayIntersection(arr1, arr2, { useDeepEqual: true });
|
|
25
|
+
* // [{ id: 2, name: 'Bob' }]
|
|
26
|
+
*
|
|
27
|
+
* // Custom comparator
|
|
28
|
+
* ArrayIntersection(arr1, arr2, {
|
|
29
|
+
* comparator: (a, b) => a.id === b.id
|
|
30
|
+
* });
|
|
31
|
+
* // [{ id: 2, name: 'Bob' }]
|
|
32
|
+
*
|
|
33
|
+
* // Key function for O(n+m) lookup
|
|
34
|
+
* ArrayIntersection(arr1, arr2, {
|
|
35
|
+
* keyFn: item => item.id
|
|
36
|
+
* });
|
|
37
|
+
* // [{ id: 2, name: 'Bob' }]
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @complexity O(n+m) where n and m are array lengths (O(n*m) with custom comparator or deep equality)
|
|
41
|
+
*/
|
|
42
|
+
export declare function ArrayIntersection<T>(array1: readonly T[], array2: readonly T[], options?: TArrayComparisonOptions<T>): T[];
|
|
43
|
+
//# sourceMappingURL=array-intersection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-intersection.d.ts","sourceRoot":"","sources":["../../src/array/array-intersection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAG1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAClC,MAAM,EAAE,SAAS,CAAC,EAAE,EACpB,MAAM,EAAE,SAAS,CAAC,EAAE,EACpB,OAAO,CAAC,EAAE,uBAAuB,CAAC,CAAC,CAAC,GAClC,CAAC,EAAE,CA8CL"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { ObjectEquals } from '../object/equals.js';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the intersection of two arrays (elements present in both)
|
|
4
|
+
* Optimized O(n+m) complexity using Set-based approach.
|
|
5
|
+
* Supports custom comparators for advanced comparison logic, deep equality checking, or key extraction.
|
|
6
|
+
*
|
|
7
|
+
* @template T - The type of array elements
|
|
8
|
+
* @param array1 - First array
|
|
9
|
+
* @param array2 - Second array
|
|
10
|
+
* @param options - Optional configuration. Choose one strategy: `comparator`, `useDeepEqual`, or `keyFn`.
|
|
11
|
+
* @param options.comparator - Custom function to determine if elements are equal (optional)
|
|
12
|
+
* @param options.useDeepEqual - Use deep equality for comparison (optional)
|
|
13
|
+
* @param options.keyFn - Optional function to extract a primitive key for O(n+m) Set-based lookup. When provided, enables efficient comparison by mapping each item to a key that can be stored in a Set. Example: `{ keyFn: item => item.id }` for objects with a unique id field.
|
|
14
|
+
* @returns Array containing elements present in both arrays. Returns `[]` if either `array1` or `array2` is `null`, `undefined`, or an empty array.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* // Basic intersection with primitives
|
|
19
|
+
* ArrayIntersection([1, 2, 3], [2, 3, 4]); // [2, 3]
|
|
20
|
+
*
|
|
21
|
+
* // Deep equality comparison with objects
|
|
22
|
+
* const arr1 = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];
|
|
23
|
+
* const arr2 = [{ id: 2, name: 'Bob' }, { id: 3, name: 'Charlie' }];
|
|
24
|
+
* ArrayIntersection(arr1, arr2, { useDeepEqual: true });
|
|
25
|
+
* // [{ id: 2, name: 'Bob' }]
|
|
26
|
+
*
|
|
27
|
+
* // Custom comparator
|
|
28
|
+
* ArrayIntersection(arr1, arr2, {
|
|
29
|
+
* comparator: (a, b) => a.id === b.id
|
|
30
|
+
* });
|
|
31
|
+
* // [{ id: 2, name: 'Bob' }]
|
|
32
|
+
*
|
|
33
|
+
* // Key function for O(n+m) lookup
|
|
34
|
+
* ArrayIntersection(arr1, arr2, {
|
|
35
|
+
* keyFn: item => item.id
|
|
36
|
+
* });
|
|
37
|
+
* // [{ id: 2, name: 'Bob' }]
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @complexity O(n+m) where n and m are array lengths (O(n*m) with custom comparator or deep equality)
|
|
41
|
+
*/
|
|
42
|
+
export function ArrayIntersection(array1, array2, options) {
|
|
43
|
+
if (!array1 || !array2) {
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
// Type narrowing: determine which strategy to use
|
|
47
|
+
if (!options) {
|
|
48
|
+
// No options: use reference equality (===)
|
|
49
|
+
const set2 = new Set(array2);
|
|
50
|
+
return array1.filter(item => set2.has(item));
|
|
51
|
+
}
|
|
52
|
+
if ('keyFn' in options && options.keyFn !== undefined) {
|
|
53
|
+
// Use key function for O(n+m) Set-based lookup
|
|
54
|
+
const keyFn = options.keyFn;
|
|
55
|
+
const set2 = new Set(array2.map(keyFn));
|
|
56
|
+
return array1.filter(item => set2.has(keyFn(item)));
|
|
57
|
+
}
|
|
58
|
+
if ('comparator' in options && options.comparator !== undefined) {
|
|
59
|
+
// Use custom comparator
|
|
60
|
+
// Optimize by checking smaller array to reduce comparisons from n*m to min(n,m)*max(n,m)
|
|
61
|
+
const [smaller, larger] = array1.length <= array2.length
|
|
62
|
+
? [array1, array2]
|
|
63
|
+
: [array2, array1];
|
|
64
|
+
return smaller.filter(item => larger.some(otherItem => options.comparator(item, otherItem)));
|
|
65
|
+
}
|
|
66
|
+
if (options.useDeepEqual) {
|
|
67
|
+
// Use deep equality
|
|
68
|
+
// Optimize by checking smaller array
|
|
69
|
+
// PERFORMANCE NOTE: This nested .some() call is O(n*m) where n and m are array lengths.
|
|
70
|
+
// For large arrays using deep equality, this can be 100-1000x slower than necessary.
|
|
71
|
+
const [smaller, larger] = array1.length <= array2.length
|
|
72
|
+
? [array1, array2]
|
|
73
|
+
: [array2, array1];
|
|
74
|
+
return smaller.filter(item => larger.some(otherItem => ObjectEquals(item, otherItem)));
|
|
75
|
+
}
|
|
76
|
+
// Fallback (should not reach here with proper type narrowing)
|
|
77
|
+
const set2 = new Set(array2);
|
|
78
|
+
return array1.filter(item => set2.has(item));
|
|
79
|
+
}
|
|
@@ -2,10 +2,12 @@ import type { TPredicate } from './types.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Splits an array into two groups: elements that satisfy the predicate and those that do not.
|
|
4
4
|
*
|
|
5
|
+
* Returns `[[], []]` if array is null, undefined, or empty.
|
|
6
|
+
*
|
|
5
7
|
* @template T - The type of array elements
|
|
6
8
|
* @param array - The array to partition
|
|
7
9
|
* @param predicate - The condition to test each element against
|
|
8
|
-
* @returns A tuple `[matches, rest]` where `matches` passed the predicate
|
|
10
|
+
* @returns A tuple `[matches, rest]` where `matches` passed the predicate. Returns `[[], []]` if `array` is `null`, `undefined`, or empty.
|
|
9
11
|
*
|
|
10
12
|
* @example
|
|
11
13
|
* ```typescript
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-partition.d.ts","sourceRoot":"","sources":["../../src/array/array-partition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C
|
|
1
|
+
{"version":3,"file":"array-partition.d.ts","sourceRoot":"","sources":["../../src/array/array-partition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAgB3F"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Splits an array into two groups: elements that satisfy the predicate and those that do not.
|
|
3
3
|
*
|
|
4
|
+
* Returns `[[], []]` if array is null, undefined, or empty.
|
|
5
|
+
*
|
|
4
6
|
* @template T - The type of array elements
|
|
5
7
|
* @param array - The array to partition
|
|
6
8
|
* @param predicate - The condition to test each element against
|
|
7
|
-
* @returns A tuple `[matches, rest]` where `matches` passed the predicate
|
|
9
|
+
* @returns A tuple `[matches, rest]` where `matches` passed the predicate. Returns `[[], []]` if `array` is `null`, `undefined`, or empty.
|
|
8
10
|
*
|
|
9
11
|
* @example
|
|
10
12
|
* ```typescript
|
|
@@ -15,6 +17,7 @@
|
|
|
15
17
|
* ```
|
|
16
18
|
*/
|
|
17
19
|
export function ArrayPartition(array, predicate) {
|
|
20
|
+
// Consistent null-check: early return for null/undefined arrays
|
|
18
21
|
if (array === null || array === undefined)
|
|
19
22
|
return [[], []];
|
|
20
23
|
const matches = [];
|
|
@@ -29,4 +32,3 @@ export function ArrayPartition(array, predicate) {
|
|
|
29
32
|
}
|
|
30
33
|
return [matches, rest];
|
|
31
34
|
}
|
|
32
|
-
//# sourceMappingURL=array-partition.js.map
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @param start - The first value in the range
|
|
5
5
|
* @param end - The value to stop before (exclusive)
|
|
6
6
|
* @param step - Increment between values (default: `1`; use negative for descending ranges)
|
|
7
|
-
* @returns Array of numbers
|
|
7
|
+
* @returns Array of numbers. Returns `[]` if `step` is 0, or if the range is invalid (e.g., `start >= end` with positive `step`).
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* ```typescript
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @param start - The first value in the range
|
|
5
5
|
* @param end - The value to stop before (exclusive)
|
|
6
6
|
* @param step - Increment between values (default: `1`; use negative for descending ranges)
|
|
7
|
-
* @returns Array of numbers
|
|
7
|
+
* @returns Array of numbers. Returns `[]` if `step` is 0, or if the range is invalid (e.g., `start >= end` with positive `step`).
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* ```typescript
|
|
@@ -29,4 +29,3 @@ export function ArrayRange(start, end, step = 1) {
|
|
|
29
29
|
}
|
|
30
30
|
return result;
|
|
31
31
|
}
|
|
32
|
-
//# sourceMappingURL=array-range.js.map
|
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
* @template T - The type of array elements
|
|
5
5
|
* @param array - The array to sample from
|
|
6
6
|
* @param random - Optional custom RNG function (returns number between 0 and 1). Defaults to `Math.random`.
|
|
7
|
-
* @returns A random element, or `undefined` if the array is empty
|
|
7
|
+
* @returns A random element, or `undefined` if the array is `null`, `undefined`, or empty
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* ```typescript
|
|
11
11
|
* ArraySample([1, 2, 3, 4, 5]); // e.g. 3
|
|
12
|
-
* ArraySample([1, 2, 3], () => 0.5); // deterministic with custom RNG
|
|
12
|
+
* ArraySample([1, 2, 3], undefined, () => 0.5); // deterministic with custom RNG
|
|
13
13
|
* ```
|
|
14
14
|
*/
|
|
15
|
-
export declare function ArraySample<T>(array: readonly T[]
|
|
15
|
+
export declare function ArraySample<T>(array: readonly T[]): T | undefined;
|
|
16
16
|
/**
|
|
17
17
|
* Returns `n` unique random elements from an array (without replacement).
|
|
18
18
|
* If `n` exceeds the array length, all elements are returned in random order.
|
|
@@ -21,7 +21,7 @@ export declare function ArraySample<T>(array: readonly T[], random?: () => numbe
|
|
|
21
21
|
* @param array - The array to sample from
|
|
22
22
|
* @param n - How many elements to sample
|
|
23
23
|
* @param random - Optional custom RNG function (returns number between 0 and 1). Defaults to `Math.random`.
|
|
24
|
-
* @returns An array of `n` randomly selected elements
|
|
24
|
+
* @returns An array of `n` randomly selected elements. Returns `[]` if `array` is `null`, `undefined`, or empty.
|
|
25
25
|
*
|
|
26
26
|
* @example
|
|
27
27
|
* ```typescript
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-sample.d.ts","sourceRoot":"","sources":["../../src/array/array-sample.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC;AAEnE;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,MAAM,GAAG,CAAC,EAAE,CAAC"}
|