@telperion/js-utils 3.7.1 → 3.8.0
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/.build-manifest.json +966 -0
- package/README.md +24 -0
- package/array/arrayize.cjs +5 -3
- package/array/arrayize.cjs.map +1 -0
- package/array/arrayize.d.cts +19 -0
- package/array/arrayize.d.ts +3 -1
- package/array/arrayize.js +2 -1
- package/array/arrayize.js.map +1 -1
- package/array/async-map.cjs +5 -3
- package/array/async-map.cjs.map +1 -0
- package/array/async-map.d.cts +36 -0
- package/array/async-map.d.ts +3 -1
- package/array/async-map.js +2 -1
- package/array/async-map.js.map +1 -1
- package/array/compact.cjs +8 -5
- package/array/compact.cjs.map +1 -0
- package/array/compact.d.cts +30 -0
- package/array/compact.d.ts +3 -1
- package/array/compact.js +4 -2
- package/array/compact.js.map +1 -1
- package/array/difference.cjs +5 -3
- package/array/difference.cjs.map +1 -0
- package/array/difference.d.cts +48 -0
- package/array/difference.d.ts +6 -3
- package/array/difference.js +2 -1
- package/array/difference.js.map +1 -1
- package/array/find-by-key.cjs +5 -3
- package/array/find-by-key.cjs.map +1 -0
- package/array/find-by-key.d.cts +32 -0
- package/array/find-by-key.d.ts +3 -1
- package/array/find-by-key.js +2 -1
- package/array/find-by-key.js.map +1 -1
- package/array/gather.cjs +5 -3
- package/array/gather.cjs.map +1 -0
- package/array/gather.d.cts +50 -0
- package/array/gather.d.ts +3 -1
- package/array/gather.js +2 -1
- package/array/gather.js.map +1 -1
- package/array/index.cjs +34 -15
- package/array/index.cjs.map +1 -0
- package/array/index.d.cts +14 -0
- package/array/index.d.ts +14 -12
- package/array/index.js +14 -13
- package/array/index.js.map +1 -1
- package/array/intersection.cjs +5 -3
- package/array/intersection.cjs.map +1 -0
- package/array/intersection.d.cts +48 -0
- package/array/intersection.d.ts +6 -3
- package/array/intersection.js +2 -1
- package/array/intersection.js.map +1 -1
- package/array/limit.cjs +5 -3
- package/array/limit.cjs.map +1 -0
- package/array/limit.d.cts +31 -0
- package/array/limit.d.ts +3 -1
- package/array/limit.js +2 -1
- package/array/limit.js.map +1 -1
- package/array/proto/async-map.cjs +6 -4
- package/array/proto/async-map.cjs.map +1 -0
- package/array/proto/async-map.d.cts +24 -0
- package/array/proto/async-map.d.ts +0 -1
- package/array/proto/async-map.js +2 -2
- package/array/proto/async-map.js.map +1 -1
- package/array/proto/compact.cjs +6 -4
- package/array/proto/compact.cjs.map +1 -0
- package/array/proto/compact.d.cts +14 -0
- package/array/proto/compact.d.ts +0 -1
- package/array/proto/compact.js +2 -2
- package/array/proto/compact.js.map +1 -1
- package/array/proto/difference.cjs +6 -4
- package/array/proto/difference.cjs.map +1 -0
- package/array/proto/difference.d.cts +28 -0
- package/array/proto/difference.d.ts +2 -1
- package/array/proto/difference.js +2 -2
- package/array/proto/difference.js.map +1 -1
- package/array/proto/find-by-key.cjs +6 -4
- package/array/proto/find-by-key.cjs.map +1 -0
- package/array/proto/find-by-key.d.cts +24 -0
- package/array/proto/find-by-key.d.ts +0 -1
- package/array/proto/find-by-key.js +2 -2
- package/array/proto/find-by-key.js.map +1 -1
- package/array/proto/gather.cjs +6 -4
- package/array/proto/gather.cjs.map +1 -0
- package/array/proto/gather.d.cts +31 -0
- package/array/proto/gather.d.ts +0 -1
- package/array/proto/gather.js +2 -2
- package/array/proto/gather.js.map +1 -1
- package/array/proto/intersection.cjs +6 -4
- package/array/proto/intersection.cjs.map +1 -0
- package/array/proto/intersection.d.cts +28 -0
- package/array/proto/intersection.d.ts +2 -1
- package/array/proto/intersection.js +2 -2
- package/array/proto/intersection.js.map +1 -1
- package/array/proto/limit.cjs +6 -4
- package/array/proto/limit.cjs.map +1 -0
- package/array/proto/limit.d.cts +23 -0
- package/array/proto/limit.d.ts +0 -1
- package/array/proto/limit.js +2 -2
- package/array/proto/limit.js.map +1 -1
- package/array/proto/remove.cjs +6 -4
- package/array/proto/remove.cjs.map +1 -0
- package/array/proto/remove.d.cts +32 -0
- package/array/proto/remove.d.ts +3 -3
- package/array/proto/remove.js +2 -2
- package/array/proto/remove.js.map +1 -1
- package/array/proto/replace.cjs +6 -4
- package/array/proto/replace.cjs.map +1 -0
- package/array/proto/replace.d.cts +73 -0
- package/array/proto/replace.d.ts +2 -1
- package/array/proto/replace.js +2 -2
- package/array/proto/replace.js.map +1 -1
- package/array/proto/slice-after.cjs +8 -0
- package/array/proto/slice-after.cjs.map +1 -0
- package/array/proto/slice-after.d.cts +33 -0
- package/array/proto/slice-after.d.ts +33 -0
- package/array/proto/slice-after.js +6 -0
- package/array/proto/slice-after.js.map +1 -0
- package/array/proto/slice-before.cjs +8 -0
- package/array/proto/slice-before.cjs.map +1 -0
- package/array/proto/slice-before.d.cts +33 -0
- package/array/proto/slice-before.d.ts +33 -0
- package/array/proto/slice-before.js +6 -0
- package/array/proto/slice-before.js.map +1 -0
- package/array/proto/uniquify-by-key.cjs +6 -4
- package/array/proto/uniquify-by-key.cjs.map +1 -0
- package/array/proto/uniquify-by-key.d.cts +23 -0
- package/array/proto/uniquify-by-key.d.ts +0 -1
- package/array/proto/uniquify-by-key.js +2 -2
- package/array/proto/uniquify-by-key.js.map +1 -1
- package/array/proto/uniquify.cjs +6 -4
- package/array/proto/uniquify.cjs.map +1 -0
- package/array/proto/uniquify.d.cts +22 -0
- package/array/proto/uniquify.d.ts +0 -1
- package/array/proto/uniquify.js +2 -2
- package/array/proto/uniquify.js.map +1 -1
- package/array/remove.cjs +5 -3
- package/array/remove.cjs.map +1 -0
- package/array/remove.d.cts +35 -0
- package/array/remove.d.ts +3 -1
- package/array/remove.js +2 -1
- package/array/remove.js.map +1 -1
- package/array/replace.cjs +5 -3
- package/array/replace.cjs.map +1 -0
- package/array/replace.d.cts +142 -0
- package/array/replace.d.ts +8 -5
- package/array/replace.js +2 -1
- package/array/replace.js.map +1 -1
- package/array/slice-after.cjs +44 -0
- package/array/slice-after.cjs.map +1 -0
- package/array/slice-after.d.cts +35 -0
- package/array/slice-after.d.ts +35 -0
- package/array/slice-after.js +42 -0
- package/array/slice-after.js.map +1 -0
- package/array/slice-before.cjs +44 -0
- package/array/slice-before.cjs.map +1 -0
- package/array/slice-before.d.cts +35 -0
- package/array/slice-before.d.ts +35 -0
- package/array/slice-before.js +42 -0
- package/array/slice-before.js.map +1 -0
- package/array/static/arrayize.cjs +6 -4
- package/array/static/arrayize.cjs.map +1 -0
- package/array/static/arrayize.d.cts +7 -0
- package/array/static/arrayize.d.ts +2 -1
- package/array/static/arrayize.js +2 -2
- package/array/static/arrayize.js.map +1 -1
- package/array/uniquify-by-key.cjs +5 -3
- package/array/uniquify-by-key.cjs.map +1 -0
- package/array/uniquify-by-key.d.cts +31 -0
- package/array/uniquify-by-key.d.ts +3 -1
- package/array/uniquify-by-key.js +2 -1
- package/array/uniquify-by-key.js.map +1 -1
- package/array/uniquify.cjs +5 -3
- package/array/uniquify.cjs.map +1 -0
- package/array/uniquify.d.cts +29 -0
- package/array/uniquify.d.ts +3 -1
- package/array/uniquify.js +2 -1
- package/array/uniquify.js.map +1 -1
- package/boolean/static/is-falsy.cjs +6 -4
- package/boolean/static/is-falsy.cjs.map +1 -0
- package/boolean/static/is-falsy.d.cts +24 -0
- package/boolean/static/is-falsy.d.ts +2 -1
- package/boolean/static/is-falsy.js +2 -2
- package/boolean/static/is-falsy.js.map +1 -1
- package/boolean/static/is-truthy.cjs +6 -4
- package/boolean/static/is-truthy.cjs.map +1 -0
- package/boolean/static/is-truthy.d.cts +24 -0
- package/boolean/static/is-truthy.d.ts +2 -1
- package/boolean/static/is-truthy.js +2 -2
- package/boolean/static/is-truthy.js.map +1 -1
- package/class/index.cjs +8 -4
- package/class/index.cjs.map +1 -0
- package/class/index.d.cts +1 -0
- package/class/index.d.ts +1 -1
- package/class/index.js +1 -2
- package/class/index.js.map +1 -1
- package/class/mixin.cjs +5 -3
- package/class/mixin.cjs.map +1 -0
- package/class/mixin.d.cts +51 -0
- package/class/mixin.d.ts +3 -2
- package/class/mixin.js +2 -1
- package/class/mixin.js.map +1 -1
- package/compact.cjs +10 -7
- package/compact.cjs.map +1 -0
- package/compact.d.cts +4 -0
- package/compact.d.ts +4 -2
- package/compact.js +7 -5
- package/compact.js.map +1 -1
- package/fesm/js-utils.mjs +1817 -0
- package/fesm/js-utils.mjs.map +1 -0
- package/function/call.cjs +5 -3
- package/function/call.cjs.map +1 -0
- package/function/call.d.cts +3 -0
- package/function/call.d.ts +3 -1
- package/function/call.js +2 -1
- package/function/call.js.map +1 -1
- package/function/debounce.cjs +19 -16
- package/function/debounce.cjs.map +1 -0
- package/function/debounce.d.cts +47 -0
- package/function/debounce.d.ts +7 -4
- package/function/debounce.js +8 -6
- package/function/debounce.js.map +1 -1
- package/function/defer.cjs +8 -5
- package/function/defer.cjs.map +1 -0
- package/function/defer.d.cts +28 -0
- package/function/defer.d.ts +3 -1
- package/function/defer.js +4 -2
- package/function/defer.js.map +1 -1
- package/function/index.cjs +18 -8
- package/function/index.cjs.map +1 -0
- package/function/index.d.cts +5 -0
- package/function/index.d.ts +5 -5
- package/function/index.js +5 -6
- package/function/index.js.map +1 -1
- package/function/noop.cjs +5 -3
- package/function/noop.cjs.map +1 -0
- package/function/noop.d.cts +22 -0
- package/function/noop.d.ts +3 -1
- package/function/noop.js +2 -1
- package/function/noop.js.map +1 -1
- package/function/of.cjs +8 -5
- package/function/of.cjs.map +1 -0
- package/function/of.d.cts +33 -0
- package/function/of.d.ts +3 -1
- package/function/of.js +4 -2
- package/function/of.js.map +1 -1
- package/function/proto/debounce.cjs +7 -5
- package/function/proto/debounce.cjs.map +1 -0
- package/function/proto/debounce.d.cts +29 -0
- package/function/proto/debounce.d.ts +0 -1
- package/function/proto/debounce.js +2 -2
- package/function/proto/debounce.js.map +1 -1
- package/function/static/call.cjs +6 -4
- package/function/static/call.cjs.map +1 -0
- package/function/static/call.d.cts +7 -0
- package/function/static/call.d.ts +2 -1
- package/function/static/call.js +2 -2
- package/function/static/call.js.map +1 -1
- package/function/static/defer.cjs +6 -4
- package/function/static/defer.cjs.map +1 -0
- package/function/static/defer.d.cts +24 -0
- package/function/static/defer.d.ts +2 -1
- package/function/static/defer.js +2 -2
- package/function/static/defer.js.map +1 -1
- package/function/static/noop.cjs +6 -4
- package/function/static/noop.cjs.map +1 -0
- package/function/static/noop.d.cts +19 -0
- package/function/static/noop.d.ts +2 -1
- package/function/static/noop.js +2 -2
- package/function/static/noop.js.map +1 -1
- package/function/static/of.cjs +6 -4
- package/function/static/of.cjs.map +1 -0
- package/function/static/of.d.cts +27 -0
- package/function/static/of.d.ts +2 -1
- package/function/static/of.js +2 -2
- package/function/static/of.js.map +1 -1
- package/index.cjs +95 -34
- package/index.cjs.map +1 -0
- package/index.d.cts +44 -0
- package/index.d.ts +44 -15
- package/index.js +43 -17
- package/index.js.map +1 -1
- package/is-falsy.cjs +5 -3
- package/is-falsy.cjs.map +1 -0
- package/is-falsy.d.cts +30 -0
- package/is-falsy.d.ts +3 -1
- package/is-falsy.js +2 -1
- package/is-falsy.js.map +1 -1
- package/is-truthy.cjs +5 -3
- package/is-truthy.cjs.map +1 -0
- package/is-truthy.d.cts +30 -0
- package/is-truthy.d.ts +3 -1
- package/is-truthy.js +2 -1
- package/is-truthy.js.map +1 -1
- package/limit.cjs +10 -7
- package/limit.cjs.map +1 -0
- package/limit.d.cts +4 -0
- package/limit.d.ts +4 -2
- package/limit.js +7 -5
- package/limit.js.map +1 -1
- package/map/index.cjs +8 -4
- package/map/index.cjs.map +1 -0
- package/map/index.d.cts +1 -0
- package/map/index.d.ts +1 -1
- package/map/index.js +1 -2
- package/map/index.js.map +1 -1
- package/map/merge.cjs +5 -3
- package/map/merge.cjs.map +1 -0
- package/map/merge.d.cts +26 -0
- package/map/merge.d.ts +3 -1
- package/map/merge.js +2 -1
- package/map/merge.js.map +1 -1
- package/math/index.cjs +8 -4
- package/math/index.cjs.map +1 -0
- package/math/index.d.cts +1 -0
- package/math/index.d.ts +1 -1
- package/math/index.js +1 -2
- package/math/index.js.map +1 -1
- package/math/min-max.cjs +5 -3
- package/math/min-max.cjs.map +1 -0
- package/math/min-max.d.cts +26 -0
- package/math/min-max.d.ts +3 -1
- package/math/min-max.js +2 -1
- package/math/min-max.js.map +1 -1
- package/math/static/min-max.cjs +6 -4
- package/math/static/min-max.cjs.map +1 -0
- package/math/static/min-max.d.cts +21 -0
- package/math/static/min-max.d.ts +2 -1
- package/math/static/min-max.js +2 -2
- package/math/static/min-max.js.map +1 -1
- package/object/clone.cjs +14 -11
- package/object/clone.cjs.map +1 -0
- package/object/clone.d.cts +164 -0
- package/object/clone.d.ts +9 -6
- package/object/clone.js +6 -4
- package/object/clone.js.map +1 -1
- package/object/compact.cjs +5 -3
- package/object/compact.cjs.map +1 -0
- package/object/compact.d.cts +39 -0
- package/object/compact.d.ts +3 -1
- package/object/compact.js +2 -1
- package/object/compact.js.map +1 -1
- package/object/deep-freeze.cjs +5 -3
- package/object/deep-freeze.cjs.map +1 -0
- package/object/deep-freeze.d.cts +3 -0
- package/object/deep-freeze.d.ts +3 -1
- package/object/deep-freeze.js +2 -1
- package/object/deep-freeze.js.map +1 -1
- package/object/deepest.cjs +5 -3
- package/object/deepest.cjs.map +1 -0
- package/object/deepest.d.cts +50 -0
- package/object/deepest.d.ts +5 -2
- package/object/deepest.js +2 -1
- package/object/deepest.js.map +1 -1
- package/object/index.cjs +16 -8
- package/object/index.cjs.map +1 -0
- package/object/index.d.cts +6 -0
- package/object/index.d.ts +6 -5
- package/object/index.js +5 -6
- package/object/index.js.map +1 -1
- package/object/map.cjs +5 -3
- package/object/map.cjs.map +1 -0
- package/object/map.d.cts +34 -0
- package/object/map.d.ts +3 -1
- package/object/map.js +2 -1
- package/object/map.js.map +1 -1
- package/object/static/clone.cjs +6 -4
- package/object/static/clone.cjs.map +1 -0
- package/object/static/clone.d.cts +44 -0
- package/object/static/clone.d.ts +2 -1
- package/object/static/clone.js +2 -2
- package/object/static/clone.js.map +1 -1
- package/object/static/compact.cjs +6 -4
- package/object/static/compact.cjs.map +1 -0
- package/object/static/compact.d.cts +27 -0
- package/object/static/compact.d.ts +2 -1
- package/object/static/compact.js +2 -2
- package/object/static/compact.js.map +1 -1
- package/object/static/deep-freeze.cjs +6 -4
- package/object/static/deep-freeze.cjs.map +1 -0
- package/object/static/deep-freeze.d.cts +7 -0
- package/object/static/deep-freeze.d.ts +2 -1
- package/object/static/deep-freeze.js +2 -2
- package/object/static/deep-freeze.js.map +1 -1
- package/object/static/deepest.cjs +6 -4
- package/object/static/deepest.cjs.map +1 -0
- package/object/static/deepest.d.cts +34 -0
- package/object/static/deepest.d.ts +3 -1
- package/object/static/deepest.js +2 -2
- package/object/static/deepest.js.map +1 -1
- package/object/static/map.cjs +6 -4
- package/object/static/map.cjs.map +1 -0
- package/object/static/map.d.cts +27 -0
- package/object/static/map.d.ts +2 -1
- package/object/static/map.js +2 -2
- package/object/static/map.js.map +1 -1
- package/open-promise.cjs +13 -11
- package/open-promise.cjs.map +1 -0
- package/open-promise.d.cts +82 -0
- package/open-promise.d.ts +5 -3
- package/open-promise.js +4 -2
- package/open-promise.js.map +1 -1
- package/package.json +817 -412
- package/promise/chain.cjs +5 -3
- package/promise/chain.cjs.map +1 -0
- package/promise/chain.d.cts +9 -0
- package/promise/chain.d.ts +3 -1
- package/promise/chain.js +2 -1
- package/promise/chain.js.map +1 -1
- package/promise/index.cjs +21 -10
- package/promise/index.cjs.map +1 -0
- package/promise/index.d.cts +7 -0
- package/promise/index.d.ts +7 -7
- package/promise/index.js +7 -8
- package/promise/index.js.map +1 -1
- package/promise/never.cjs +10 -7
- package/promise/never.cjs.map +1 -0
- package/promise/never.d.cts +36 -0
- package/promise/never.d.ts +4 -2
- package/promise/never.js +5 -3
- package/promise/never.js.map +1 -1
- package/promise/promisify.cjs +5 -3
- package/promise/promisify.cjs.map +1 -0
- package/promise/promisify.d.cts +9 -0
- package/promise/promisify.d.ts +3 -1
- package/promise/promisify.js +2 -1
- package/promise/promisify.js.map +1 -1
- package/promise/proto/revert.cjs +6 -4
- package/promise/proto/revert.cjs.map +1 -0
- package/promise/proto/revert.d.cts +28 -0
- package/promise/proto/revert.d.ts +0 -1
- package/promise/proto/revert.js +2 -2
- package/promise/proto/revert.js.map +1 -1
- package/promise/proto/try-catch.cjs +6 -4
- package/promise/proto/try-catch.cjs.map +1 -0
- package/promise/proto/try-catch.d.cts +29 -0
- package/promise/proto/try-catch.d.ts +0 -1
- package/promise/proto/try-catch.js +2 -2
- package/promise/proto/try-catch.js.map +1 -1
- package/promise/revert.cjs +5 -3
- package/promise/revert.cjs.map +1 -0
- package/promise/revert.d.cts +40 -0
- package/promise/revert.d.ts +3 -1
- package/promise/revert.js +2 -1
- package/promise/revert.js.map +1 -1
- package/promise/static/chain.cjs +6 -4
- package/promise/static/chain.cjs.map +1 -0
- package/promise/static/chain.d.cts +11 -0
- package/promise/static/chain.d.ts +2 -1
- package/promise/static/chain.js +2 -2
- package/promise/static/chain.js.map +1 -1
- package/promise/static/never.cjs +7 -5
- package/promise/static/never.cjs.map +1 -0
- package/promise/static/never.d.cts +40 -0
- package/promise/static/never.d.ts +2 -1
- package/promise/static/never.js +2 -2
- package/promise/static/never.js.map +1 -1
- package/promise/static/timeout.cjs +6 -4
- package/promise/static/timeout.cjs.map +1 -0
- package/promise/static/timeout.d.cts +22 -0
- package/promise/static/timeout.d.ts +2 -1
- package/promise/static/timeout.js +2 -2
- package/promise/static/timeout.js.map +1 -1
- package/promise/static/try-one-by-one.cjs +6 -4
- package/promise/static/try-one-by-one.cjs.map +1 -0
- package/promise/static/try-one-by-one.d.cts +28 -0
- package/promise/static/try-one-by-one.d.ts +2 -1
- package/promise/static/try-one-by-one.js +2 -2
- package/promise/static/try-one-by-one.js.map +1 -1
- package/promise/timeout.cjs +13 -11
- package/promise/timeout.cjs.map +1 -0
- package/promise/timeout.d.cts +112 -0
- package/promise/timeout.d.ts +5 -2
- package/promise/timeout.js +4 -3
- package/promise/timeout.js.map +1 -1
- package/promise/try-catch.cjs +5 -3
- package/promise/try-catch.cjs.map +1 -0
- package/promise/try-catch.d.cts +47 -0
- package/promise/try-catch.d.ts +4 -2
- package/promise/try-catch.js +2 -1
- package/promise/try-catch.js.map +1 -1
- package/promise/try-one-by-one.cjs +5 -3
- package/promise/try-one-by-one.cjs.map +1 -0
- package/promise/try-one-by-one.d.cts +44 -0
- package/promise/try-one-by-one.d.ts +3 -1
- package/promise/try-one-by-one.js +2 -1
- package/promise/try-one-by-one.js.map +1 -1
- package/set/proto/difference.cjs +6 -4
- package/set/proto/difference.cjs.map +1 -0
- package/set/proto/difference.d.cts +27 -0
- package/set/proto/difference.d.ts +2 -1
- package/set/proto/difference.js +2 -2
- package/set/proto/difference.js.map +1 -1
- package/set/proto/intersection.cjs +6 -4
- package/set/proto/intersection.cjs.map +1 -0
- package/set/proto/intersection.d.cts +27 -0
- package/set/proto/intersection.d.ts +2 -1
- package/set/proto/intersection.js +2 -2
- package/set/proto/intersection.js.map +1 -1
- package/smart-map.cjs +4 -3
- package/smart-map.cjs.map +1 -0
- package/smart-map.d.cts +82 -0
- package/smart-map.d.ts +3 -2
- package/smart-map.js +2 -1
- package/smart-map.js.map +1 -1
- package/string/index.cjs +8 -4
- package/string/index.cjs.map +1 -0
- package/string/index.d.cts +1 -0
- package/string/index.d.ts +1 -1
- package/string/index.js +1 -2
- package/string/index.js.map +1 -1
- package/string/limit.cjs +8 -5
- package/string/limit.cjs.map +1 -0
- package/string/limit.d.cts +31 -0
- package/string/limit.d.ts +3 -1
- package/string/limit.js +5 -3
- package/string/limit.js.map +1 -1
- package/string/proto/limit.cjs +6 -4
- package/string/proto/limit.cjs.map +1 -0
- package/string/proto/limit.d.cts +30 -0
- package/string/proto/limit.d.ts +3 -3
- package/string/proto/limit.js +2 -2
- package/string/proto/limit.js.map +1 -1
- package/time/days.cjs +8 -5
- package/time/days.cjs.map +1 -0
- package/time/days.d.cts +17 -0
- package/time/days.d.ts +3 -1
- package/time/days.js +4 -2
- package/time/days.js.map +1 -1
- package/time/hours.cjs +8 -5
- package/time/hours.cjs.map +1 -0
- package/time/hours.d.cts +17 -0
- package/time/hours.d.ts +3 -1
- package/time/hours.js +4 -2
- package/time/hours.js.map +1 -1
- package/time/index.cjs +20 -10
- package/time/index.cjs.map +1 -0
- package/time/index.d.cts +7 -0
- package/time/index.d.ts +7 -7
- package/time/index.js +7 -8
- package/time/index.js.map +1 -1
- package/time/minutes.cjs +8 -5
- package/time/minutes.cjs.map +1 -0
- package/time/minutes.d.cts +17 -0
- package/time/minutes.d.ts +3 -1
- package/time/minutes.js +4 -2
- package/time/minutes.js.map +1 -1
- package/time/months.cjs +8 -5
- package/time/months.cjs.map +1 -0
- package/time/months.d.cts +17 -0
- package/time/months.d.ts +3 -1
- package/time/months.js +4 -2
- package/time/months.js.map +1 -1
- package/time/seconds.cjs +5 -3
- package/time/seconds.cjs.map +1 -0
- package/time/seconds.d.cts +17 -0
- package/time/seconds.d.ts +3 -1
- package/time/seconds.js +2 -1
- package/time/seconds.js.map +1 -1
- package/time/weeks.cjs +8 -5
- package/time/weeks.cjs.map +1 -0
- package/time/weeks.d.cts +17 -0
- package/time/weeks.d.ts +3 -1
- package/time/weeks.js +4 -2
- package/time/weeks.js.map +1 -1
- package/time/years.cjs +8 -5
- package/time/years.cjs.map +1 -0
- package/time/years.d.cts +17 -0
- package/time/years.d.ts +3 -1
- package/time/years.js +4 -2
- package/time/years.js.map +1 -1
- package/unique-id.cjs +5 -3
- package/unique-id.cjs.map +1 -0
- package/unique-id.d.cts +23 -0
- package/unique-id.d.ts +4 -2
- package/unique-id.js +2 -1
- package/unique-id.js.map +1 -1
package/README.md
CHANGED
|
@@ -155,6 +155,30 @@ replace(array, {itemsToReplace: config}); // ["x", "y", "c", "a", "b", "c"];
|
|
|
155
155
|
replace(array, {itemsToReplace: config, multi: true}); // ["x", "y", "c", "x", "y", "c"];
|
|
156
156
|
```
|
|
157
157
|
|
|
158
|
+
#### [Slice After](https://open-source.telperion.tr/js-utils/modules/_array_slice_after_.html)
|
|
159
|
+
Returns the items located after the first occurrence of the given item
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
import { sliceAfter } from "@telperion/js-utils/array";
|
|
163
|
+
|
|
164
|
+
const fruits = ["apple", "grapes", "banana", "melon", "orange"];
|
|
165
|
+
|
|
166
|
+
sliceAfter(fruits, "banana"); // ["melon", "orange"]
|
|
167
|
+
sliceAfter(fruits, "kiwi"); // []
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
#### [Slice Before](https://open-source.telperion.tr/js-utils/modules/_array_slice_before_.html)
|
|
171
|
+
Returns the items located before the first occurrence of the given item
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
import { sliceBefore } from "@telperion/js-utils/array";
|
|
175
|
+
|
|
176
|
+
const fruits = ["apple", "grapes", "banana", "melon", "orange"];
|
|
177
|
+
|
|
178
|
+
sliceBefore(fruits, "melon"); // ["apple", "grapes", "banana"]
|
|
179
|
+
sliceBefore(fruits, "kiwi"); // []
|
|
180
|
+
```
|
|
181
|
+
|
|
158
182
|
#### [Uniquify](https://open-source.telperion.tr/js-utils/modules/_array_uniquify_.html)
|
|
159
183
|
Removes repeated items from the array
|
|
160
184
|
|
package/array/arrayize.cjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.arrayize = arrayize;
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
4
3
|
/**
|
|
5
4
|
* Encapsulates a non array value with an array that contains it unless the value is already an array
|
|
6
5
|
*
|
|
@@ -20,3 +19,6 @@ exports.arrayize = arrayize;
|
|
|
20
19
|
function arrayize(value) {
|
|
21
20
|
return value instanceof Array ? value : [value];
|
|
22
21
|
}
|
|
22
|
+
|
|
23
|
+
exports.arrayize = arrayize;
|
|
24
|
+
//# sourceMappingURL=arrayize.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrayize.cjs","sources":["../../../../libs/js-utils/src/array/arrayize.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;AAeG;AACG,SAAU,QAAQ,CAAI,KAAc,EAAA;AACxC,IAAA,OAAO,KAAK,YAAY,KAAK,GAAG,KAAK,GAAG,CAAC,KAAK,CAAC;AACjD;;;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encapsulates a non array value with an array that contains it unless the value is already an array
|
|
3
|
+
*
|
|
4
|
+
* * * *
|
|
5
|
+
* Example usage:
|
|
6
|
+
* ```typescript
|
|
7
|
+
* import { arrayize } from "@telperion/js-utils";
|
|
8
|
+
*
|
|
9
|
+
* const foo = 'foo';
|
|
10
|
+
* const bar = ['bar'];
|
|
11
|
+
* const fooArr = arrayize(foo); // ['foo'];
|
|
12
|
+
* const barArr = arrayize(bar); // ['bar'];
|
|
13
|
+
* ```
|
|
14
|
+
* * * *
|
|
15
|
+
* @param value Array or single value to capsulate
|
|
16
|
+
*/
|
|
17
|
+
declare function arrayize<T>(value: T | T[]): T[];
|
|
18
|
+
|
|
19
|
+
export { arrayize };
|
package/array/arrayize.d.ts
CHANGED
package/array/arrayize.js
CHANGED
|
@@ -14,8 +14,9 @@
|
|
|
14
14
|
* * * *
|
|
15
15
|
* @param value Array or single value to capsulate
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
function arrayize(value) {
|
|
18
18
|
return value instanceof Array ? value : [value];
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
export { arrayize };
|
|
21
22
|
//# sourceMappingURL=arrayize.js.map
|
package/array/arrayize.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"file":"arrayize.js","sources":["../../../../libs/js-utils/src/array/arrayize.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;AAeG;AACG,SAAU,QAAQ,CAAI,KAAc,EAAA;AACxC,IAAA,OAAO,KAAK,YAAY,KAAK,GAAG,KAAK,GAAG,CAAC,KAAK,CAAC;AACjD;;;;"}
|
package/array/async-map.cjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.asyncMap = asyncMap;
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
4
3
|
/**
|
|
5
4
|
* #### Async Map
|
|
6
5
|
*
|
|
@@ -38,3 +37,6 @@ async function asyncMap(array, mapper) {
|
|
|
38
37
|
const promises = array.map(mapper);
|
|
39
38
|
return await Promise.all(promises);
|
|
40
39
|
}
|
|
40
|
+
|
|
41
|
+
exports.asyncMap = asyncMap;
|
|
42
|
+
//# sourceMappingURL=async-map.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-map.cjs","sources":["../../../../libs/js-utils/src/array/async-map.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCG;AACI,eAAe,QAAQ,CAAO,KAAU,EAAE,MAA2D,EAAA;IAC1G,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC;AAElC,IAAA,OAAO,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;AACpC;;;;"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #### Async Map
|
|
3
|
+
*
|
|
4
|
+
* Maps an array asynchronously
|
|
5
|
+
*
|
|
6
|
+
* * * *
|
|
7
|
+
* Example:
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { asyncMap } "@telperion/js-utils/array";
|
|
10
|
+
*
|
|
11
|
+
* const array = [1, 2, 3];
|
|
12
|
+
*
|
|
13
|
+
* asyncMap(array, async value => {
|
|
14
|
+
* return await addOneAfterASecond(value);
|
|
15
|
+
* }).then(result => {
|
|
16
|
+
* console.log(result); // [2, 3, 4]
|
|
17
|
+
* });
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* Example as Array Prototype:
|
|
21
|
+
* ```typescript
|
|
22
|
+
* import "@telperion/js-utils/array/proto/async-map";
|
|
23
|
+
*
|
|
24
|
+
* const array = [1, 2, 3];
|
|
25
|
+
*
|
|
26
|
+
* const result = await array.asyncMap(async value => await addOneAfterASecond(value));
|
|
27
|
+
* // [2, 3, 4]
|
|
28
|
+
* ```
|
|
29
|
+
* * * *
|
|
30
|
+
* @param array Array to map
|
|
31
|
+
* @param mapper Callback async function to map the array
|
|
32
|
+
* @return A promise contains asynchronusly mapped array result
|
|
33
|
+
*/
|
|
34
|
+
declare function asyncMap<T, U>(array: T[], mapper: (value: T, index: number, array: T[]) => Promise<U>): Promise<U[]>;
|
|
35
|
+
|
|
36
|
+
export { asyncMap };
|
package/array/async-map.d.ts
CHANGED
|
@@ -31,4 +31,6 @@
|
|
|
31
31
|
* @param mapper Callback async function to map the array
|
|
32
32
|
* @return A promise contains asynchronusly mapped array result
|
|
33
33
|
*/
|
|
34
|
-
|
|
34
|
+
declare function asyncMap<T, U>(array: T[], mapper: (value: T, index: number, array: T[]) => Promise<U>): Promise<U[]>;
|
|
35
|
+
|
|
36
|
+
export { asyncMap };
|
package/array/async-map.js
CHANGED
|
@@ -31,9 +31,10 @@
|
|
|
31
31
|
* @param mapper Callback async function to map the array
|
|
32
32
|
* @return A promise contains asynchronusly mapped array result
|
|
33
33
|
*/
|
|
34
|
-
|
|
34
|
+
async function asyncMap(array, mapper) {
|
|
35
35
|
const promises = array.map(mapper);
|
|
36
36
|
return await Promise.all(promises);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
export { asyncMap };
|
|
39
40
|
//# sourceMappingURL=async-map.js.map
|
package/array/async-map.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"file":"async-map.js","sources":["../../../../libs/js-utils/src/array/async-map.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCG;AACI,eAAe,QAAQ,CAAO,KAAU,EAAE,MAA2D,EAAA;IAC1G,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC;AAElC,IAAA,OAAO,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;AACpC;;;;"}
|
package/array/compact.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var isTruthy = require('../is-truthy.cjs');
|
|
4
|
+
|
|
5
5
|
/**
|
|
6
6
|
* #### Filters falsy values of the given array
|
|
7
7
|
* * does not modify the original array
|
|
@@ -30,5 +30,8 @@ const is_truthy_1 = require("@telperion/js-utils/is-truthy");
|
|
|
30
30
|
* @returns __a new__ compacted array
|
|
31
31
|
*/
|
|
32
32
|
function compact(arrayToCompact) {
|
|
33
|
-
return arrayToCompact.filter(
|
|
33
|
+
return arrayToCompact.filter(isTruthy.isTruthy);
|
|
34
34
|
}
|
|
35
|
+
|
|
36
|
+
exports.compact = compact;
|
|
37
|
+
//# sourceMappingURL=compact.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compact.cjs","sources":["../../../../libs/js-utils/src/array/compact.ts"],"sourcesContent":[null],"names":["isTruthy"],"mappings":";;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BG;AACG,SAAU,OAAO,CAAU,cAAmB,EAAA;AAClD,IAAA,OAAO,cAAc,CAAC,MAAM,CAACA,iBAAQ,CAAC;AACxC;;;;"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #### Filters falsy values of the given array
|
|
3
|
+
* * does not modify the original array
|
|
4
|
+
* * Values to be filtered: `[undefined, null, "", 0, false, NaN]`
|
|
5
|
+
*
|
|
6
|
+
* * * *
|
|
7
|
+
* Example usage:
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { compact } from "@telperion/js-utils/array";
|
|
10
|
+
*
|
|
11
|
+
* const arr = [undefined, "", false, 0, 1, "1"];
|
|
12
|
+
* const compacted = compact(arr); // [1, "1"];
|
|
13
|
+
*
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* Example as Array Prototype:
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import "@telperion/js-utils/array/proto/compact";
|
|
19
|
+
*
|
|
20
|
+
* const arr = [undefined, "", false, 0, 1, "1"];
|
|
21
|
+
* const compacted = arr.compact(); // [1, "1"];
|
|
22
|
+
* ```
|
|
23
|
+
* * * *
|
|
24
|
+
* @param arrayToCompact array to compact
|
|
25
|
+
* @typeparam T type of array
|
|
26
|
+
* @returns __a new__ compacted array
|
|
27
|
+
*/
|
|
28
|
+
declare function compact<T = any>(arrayToCompact: T[]): T[];
|
|
29
|
+
|
|
30
|
+
export { compact };
|
package/array/compact.d.ts
CHANGED
package/array/compact.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { isTruthy } from '
|
|
1
|
+
import { isTruthy } from '../is-truthy.js';
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* #### Filters falsy values of the given array
|
|
4
5
|
* * does not modify the original array
|
|
@@ -26,8 +27,9 @@ import { isTruthy } from '@telperion/js-utils/is-truthy';
|
|
|
26
27
|
* @typeparam T type of array
|
|
27
28
|
* @returns __a new__ compacted array
|
|
28
29
|
*/
|
|
29
|
-
|
|
30
|
+
function compact(arrayToCompact) {
|
|
30
31
|
return arrayToCompact.filter(isTruthy);
|
|
31
32
|
}
|
|
32
33
|
|
|
34
|
+
export { compact };
|
|
33
35
|
//# sourceMappingURL=compact.js.map
|
package/array/compact.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"file":"compact.js","sources":["../../../../libs/js-utils/src/array/compact.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BG;AACG,SAAU,OAAO,CAAU,cAAmB,EAAA;AAClD,IAAA,OAAO,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC;AACxC;;;;"}
|
package/array/difference.cjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.difference = difference;
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
4
3
|
function difference(base, substraction, allDiff = false) {
|
|
5
4
|
if (base instanceof Set) {
|
|
6
5
|
return new Set(difference(Array.from(base), substraction));
|
|
@@ -14,3 +13,6 @@ function difference(base, substraction, allDiff = false) {
|
|
|
14
13
|
return index === -1;
|
|
15
14
|
});
|
|
16
15
|
}
|
|
16
|
+
|
|
17
|
+
exports.difference = difference;
|
|
18
|
+
//# sourceMappingURL=difference.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"difference.cjs","sources":["../../../../libs/js-utils/src/array/difference.ts"],"sourcesContent":[null],"names":[],"mappings":";;AA+CM,SAAU,UAAU,CAAI,IAAkB,EAAE,YAA6B,EAAE,OAAO,GAAG,KAAK,EAAA;AAC9F,IAAA,IAAI,IAAI,YAAY,GAAG,EAAE;AACvB,QAAA,OAAO,IAAI,GAAG,CAAI,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC,CAAC;IAC/D;IAEA,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC;AAErC,IAAA,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,IAAG;QACzB,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;AAEjC,QAAA,IAAI,KAAK,GAAG,EAAE,IAAI,OAAO,EAAE;AACzB,YAAA,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;QACvB;AAEA,QAAA,OAAO,KAAK,KAAK,EAAE;AACrB,IAAA,CAAC,CAAC;AACJ;;;;"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Difference Substraction Type
|
|
3
|
+
*/
|
|
4
|
+
type Substraction<T = any> = T[] | Set<T>;
|
|
5
|
+
/**
|
|
6
|
+
* #### Difference
|
|
7
|
+
*
|
|
8
|
+
* Gets the difference of the two arrays or sets
|
|
9
|
+
*
|
|
10
|
+
* * * *
|
|
11
|
+
* Example:
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { difference } from "@telperion/js-utils/array";
|
|
14
|
+
*
|
|
15
|
+
* const base = ["a", "b", "c", "d", "a", "b", "c", "d"];
|
|
16
|
+
*
|
|
17
|
+
* difference(base, ["a", "b"]); // ["c", "d", "c", "d"]
|
|
18
|
+
* difference(base, ["a", "b"], true); // ["c", "d", "a", "b", "c", "d"]
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* Array Prototype Example:
|
|
22
|
+
* ```typescript
|
|
23
|
+
* import "@telperion/js-utils/array/proto/difference";
|
|
24
|
+
*
|
|
25
|
+
* const base = ["a", "b", "c", "d", "a", "b", "c", "d"];
|
|
26
|
+
*
|
|
27
|
+
* base.difference(["a", "b"]); // ["c", "d", "c", "d"]
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* Set Prototype Example:
|
|
31
|
+
* ```typescript
|
|
32
|
+
* import "@telperion/js-utils/set/proto/difference";
|
|
33
|
+
*
|
|
34
|
+
* const base = new Set(["a", "b", "c", "d"]);
|
|
35
|
+
*
|
|
36
|
+
* base.difference(["a", "b"]); // Set(["c", "d"])
|
|
37
|
+
* ```
|
|
38
|
+
* * * *
|
|
39
|
+
* @param base Base Set or Array
|
|
40
|
+
* @param substraction Set or Array to remove its values from the base
|
|
41
|
+
* @param allDiff By default all the same items encountered in substraction will be removed, set this argument as true to get real difference
|
|
42
|
+
* @returns Difference of base from substraction
|
|
43
|
+
*/
|
|
44
|
+
declare function difference<T>(base: T[], substraction: Substraction<T>, allDiff?: boolean): T[];
|
|
45
|
+
declare function difference<T>(base: Set<T>, substraction: Substraction<T>, allDiff?: boolean): Set<T>;
|
|
46
|
+
|
|
47
|
+
export { difference };
|
|
48
|
+
export type { Substraction };
|
package/array/difference.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Difference Substraction Type
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
type Substraction<T = any> = T[] | Set<T>;
|
|
5
5
|
/**
|
|
6
6
|
* #### Difference
|
|
7
7
|
*
|
|
@@ -41,5 +41,8 @@ export type Substraction<T = any> = T[] | Set<T>;
|
|
|
41
41
|
* @param allDiff By default all the same items encountered in substraction will be removed, set this argument as true to get real difference
|
|
42
42
|
* @returns Difference of base from substraction
|
|
43
43
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
declare function difference<T>(base: T[], substraction: Substraction<T>, allDiff?: boolean): T[];
|
|
45
|
+
declare function difference<T>(base: Set<T>, substraction: Substraction<T>, allDiff?: boolean): Set<T>;
|
|
46
|
+
|
|
47
|
+
export { difference };
|
|
48
|
+
export type { Substraction };
|
package/array/difference.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
function difference(base, substraction, allDiff = false) {
|
|
2
2
|
if (base instanceof Set) {
|
|
3
3
|
return new Set(difference(Array.from(base), substraction));
|
|
4
4
|
}
|
|
@@ -12,4 +12,5 @@ export function difference(base, substraction, allDiff = false) {
|
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
export { difference };
|
|
15
16
|
//# sourceMappingURL=difference.js.map
|
package/array/difference.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"file":"difference.js","sources":["../../../../libs/js-utils/src/array/difference.ts"],"sourcesContent":[null],"names":[],"mappings":"AA+CM,SAAU,UAAU,CAAI,IAAkB,EAAE,YAA6B,EAAE,OAAO,GAAG,KAAK,EAAA;AAC9F,IAAA,IAAI,IAAI,YAAY,GAAG,EAAE;AACvB,QAAA,OAAO,IAAI,GAAG,CAAI,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC,CAAC;IAC/D;IAEA,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC;AAErC,IAAA,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,IAAG;QACzB,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;AAEjC,QAAA,IAAI,KAAK,GAAG,EAAE,IAAI,OAAO,EAAE;AACzB,YAAA,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;QACvB;AAEA,QAAA,OAAO,KAAK,KAAK,EAAE;AACrB,IAAA,CAAC,CAAC;AACJ;;;;"}
|
package/array/find-by-key.cjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.findByKey = findByKey;
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
4
3
|
/**
|
|
5
4
|
* #### Find By Key
|
|
6
5
|
*
|
|
@@ -33,3 +32,6 @@ exports.findByKey = findByKey;
|
|
|
33
32
|
function findByKey(array, key, value) {
|
|
34
33
|
return array.find(item => item[key] === value);
|
|
35
34
|
}
|
|
35
|
+
|
|
36
|
+
exports.findByKey = findByKey;
|
|
37
|
+
//# sourceMappingURL=find-by-key.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-by-key.cjs","sources":["../../../../libs/js-utils/src/array/find-by-key.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BG;SACa,SAAS,CAAwB,KAAU,EAAE,GAAM,EAAE,KAAW,EAAA;AAC9E,IAAA,OAAO,KAAK,CAAC,IAAI,CAAE,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,KAAK,CAAE;AAClD;;;;"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #### Find By Key
|
|
3
|
+
*
|
|
4
|
+
* Finds an object in an array by matching the value set on the key
|
|
5
|
+
*
|
|
6
|
+
* * * *
|
|
7
|
+
* Example:
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { findByKey } from "@telperion/js-utils/array";
|
|
10
|
+
*
|
|
11
|
+
* const array = [{a: 1}, {a: 2}, {a: 3}];
|
|
12
|
+
*
|
|
13
|
+
* findByKey(array, "a", 2); // {a: 2}
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* Prototype Example:
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import "@telperion/js-utils/array/proto/find-by-key";
|
|
19
|
+
*
|
|
20
|
+
* const array = [{a: 1}, {a: 2}, {a: 3}];
|
|
21
|
+
*
|
|
22
|
+
* array.findByKey("a", 2); // {a: 2}
|
|
23
|
+
* ```
|
|
24
|
+
* * * *
|
|
25
|
+
* @param array Collection of the objects
|
|
26
|
+
* @param key Key to search the value on
|
|
27
|
+
* @param value Value to match for the key
|
|
28
|
+
* @return Found object or undefined
|
|
29
|
+
*/
|
|
30
|
+
declare function findByKey<T, K extends keyof T>(array: T[], key: K, value: T[K]): T | undefined;
|
|
31
|
+
|
|
32
|
+
export { findByKey };
|
package/array/find-by-key.d.ts
CHANGED
|
@@ -27,4 +27,6 @@
|
|
|
27
27
|
* @param value Value to match for the key
|
|
28
28
|
* @return Found object or undefined
|
|
29
29
|
*/
|
|
30
|
-
|
|
30
|
+
declare function findByKey<T, K extends keyof T>(array: T[], key: K, value: T[K]): T | undefined;
|
|
31
|
+
|
|
32
|
+
export { findByKey };
|
package/array/find-by-key.js
CHANGED
|
@@ -27,8 +27,9 @@
|
|
|
27
27
|
* @param value Value to match for the key
|
|
28
28
|
* @return Found object or undefined
|
|
29
29
|
*/
|
|
30
|
-
|
|
30
|
+
function findByKey(array, key, value) {
|
|
31
31
|
return array.find(item => item[key] === value);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
export { findByKey };
|
|
34
35
|
//# sourceMappingURL=find-by-key.js.map
|
package/array/find-by-key.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"file":"find-by-key.js","sources":["../../../../libs/js-utils/src/array/find-by-key.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BG;SACa,SAAS,CAAwB,KAAU,EAAE,GAAM,EAAE,KAAW,EAAA;AAC9E,IAAA,OAAO,KAAK,CAAC,IAAI,CAAE,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,KAAK,CAAE;AAClD;;;;"}
|
package/array/gather.cjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.gather = gather;
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
4
3
|
/**
|
|
5
4
|
* #### Groups array items by a specified key into a Map
|
|
6
5
|
*
|
|
@@ -58,3 +57,6 @@ function gather(array, key) {
|
|
|
58
57
|
return acc;
|
|
59
58
|
}, new Map());
|
|
60
59
|
}
|
|
60
|
+
|
|
61
|
+
exports.gather = gather;
|
|
62
|
+
//# sourceMappingURL=gather.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gather.cjs","sources":["../../../../libs/js-utils/src/array/gather.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CG;AACG,SAAU,MAAM,CAAgD,KAAU,EAAE,GAAM,EAAA;IACtF,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,KAAI;AAChC,QAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC;QAE1B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;AACtB,YAAA,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC;QACvB;QAEA,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAE,CAAC,IAAI,CAAC,IAAI,CAAC;AAE7B,QAAA,OAAO,GAAG;AACZ,IAAA,CAAC,EAAE,IAAI,GAAG,EAAa,CAAC;AAC1B;;;;"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #### Groups array items by a specified key into a Map
|
|
3
|
+
*
|
|
4
|
+
* Iterates over the array and groups items that share the same value for the given key.
|
|
5
|
+
* Returns a `Map` where each key is a unique value of the specified property and each value is an array of matching items.
|
|
6
|
+
*
|
|
7
|
+
* * * *
|
|
8
|
+
* Example usage:
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { gather } from "@telperion/js-utils/array";
|
|
11
|
+
*
|
|
12
|
+
* const users = [
|
|
13
|
+
* { role: "admin", name: "Alice" },
|
|
14
|
+
* { role: "user", name: "Bob" },
|
|
15
|
+
* { role: "admin", name: "Charlie" },
|
|
16
|
+
* ];
|
|
17
|
+
*
|
|
18
|
+
* const grouped = gather(users, "role");
|
|
19
|
+
* // Map {
|
|
20
|
+
* // "admin" => [{ role: "admin", name: "Alice" }, { role: "admin", name: "Charlie" }],
|
|
21
|
+
* // "user" => [{ role: "user", name: "Bob" }]
|
|
22
|
+
* // }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* Example as Array Prototype:
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import "@telperion/js-utils/array/proto/gather";
|
|
28
|
+
*
|
|
29
|
+
* const users = [
|
|
30
|
+
* { role: "admin", name: "Alice" },
|
|
31
|
+
* { role: "user", name: "Bob" },
|
|
32
|
+
* { role: "admin", name: "Charlie" },
|
|
33
|
+
* ];
|
|
34
|
+
*
|
|
35
|
+
* const grouped = users.gather("role");
|
|
36
|
+
* // Map {
|
|
37
|
+
* // "admin" => [{ role: "admin", name: "Alice" }, { role: "admin", name: "Charlie" }],
|
|
38
|
+
* // "user" => [{ role: "user", name: "Bob" }]
|
|
39
|
+
* // }
|
|
40
|
+
* ```
|
|
41
|
+
* * * *
|
|
42
|
+
* @param array Array of objects to group
|
|
43
|
+
* @param key Key to group items by
|
|
44
|
+
* @typeparam T Type of array items
|
|
45
|
+
* @typeparam P Key type
|
|
46
|
+
* @returns A Map grouping items by the specified key's value
|
|
47
|
+
*/
|
|
48
|
+
declare function gather<T extends Record<any, any>, P extends keyof T>(array: T[], key: P): Map<T[P], T[]>;
|
|
49
|
+
|
|
50
|
+
export { gather };
|
package/array/gather.d.ts
CHANGED
|
@@ -45,4 +45,6 @@
|
|
|
45
45
|
* @typeparam P Key type
|
|
46
46
|
* @returns A Map grouping items by the specified key's value
|
|
47
47
|
*/
|
|
48
|
-
|
|
48
|
+
declare function gather<T extends Record<any, any>, P extends keyof T>(array: T[], key: P): Map<T[P], T[]>;
|
|
49
|
+
|
|
50
|
+
export { gather };
|
package/array/gather.js
CHANGED
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
* @typeparam P Key type
|
|
46
46
|
* @returns A Map grouping items by the specified key's value
|
|
47
47
|
*/
|
|
48
|
-
|
|
48
|
+
function gather(array, key) {
|
|
49
49
|
return array.reduce((acc, item) => {
|
|
50
50
|
const groupKey = item[key];
|
|
51
51
|
if (!acc.has(groupKey)) {
|
|
@@ -56,4 +56,5 @@ export function gather(array, key) {
|
|
|
56
56
|
}, new Map());
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
export { gather };
|
|
59
60
|
//# sourceMappingURL=gather.js.map
|
package/array/gather.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"file":"gather.js","sources":["../../../../libs/js-utils/src/array/gather.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CG;AACG,SAAU,MAAM,CAAgD,KAAU,EAAE,GAAM,EAAA;IACtF,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,KAAI;AAChC,QAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC;QAE1B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;AACtB,YAAA,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC;QACvB;QAEA,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAE,CAAC,IAAI,CAAC,IAAI,CAAC;AAE7B,QAAA,OAAO,GAAG;AACZ,IAAA,CAAC,EAAE,IAAI,GAAG,EAAa,CAAC;AAC1B;;;;"}
|
package/array/index.cjs
CHANGED
|
@@ -1,15 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var array_arrayize = require('./arrayize.cjs');
|
|
4
|
+
var array_asyncMap = require('./async-map.cjs');
|
|
5
|
+
var array_compact = require('./compact.cjs');
|
|
6
|
+
var array_difference = require('./difference.cjs');
|
|
7
|
+
var array_findByKey = require('./find-by-key.cjs');
|
|
8
|
+
var array_gather = require('./gather.cjs');
|
|
9
|
+
var array_intersection = require('./intersection.cjs');
|
|
10
|
+
var array_limit = require('./limit.cjs');
|
|
11
|
+
var array_remove = require('./remove.cjs');
|
|
12
|
+
var array_replace = require('./replace.cjs');
|
|
13
|
+
var array_sliceAfter = require('./slice-after.cjs');
|
|
14
|
+
var array_sliceBefore = require('./slice-before.cjs');
|
|
15
|
+
var array_uniquify = require('./uniquify.cjs');
|
|
16
|
+
var array_uniquifyByKey = require('./uniquify-by-key.cjs');
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
exports.arrayize = array_arrayize.arrayize;
|
|
21
|
+
exports.asyncMap = array_asyncMap.asyncMap;
|
|
22
|
+
exports.compact = array_compact.compact;
|
|
23
|
+
exports.difference = array_difference.difference;
|
|
24
|
+
exports.findByKey = array_findByKey.findByKey;
|
|
25
|
+
exports.gather = array_gather.gather;
|
|
26
|
+
exports.intersection = array_intersection.intersection;
|
|
27
|
+
exports.limit = array_limit.limit;
|
|
28
|
+
exports.remove = array_remove.remove;
|
|
29
|
+
exports.replace = array_replace.replace;
|
|
30
|
+
exports.sliceAfter = array_sliceAfter.sliceAfter;
|
|
31
|
+
exports.sliceBefore = array_sliceBefore.sliceBefore;
|
|
32
|
+
exports.uniquify = array_uniquify.uniquify;
|
|
33
|
+
exports.uniquifyByKey = array_uniquifyByKey.uniquifyByKey;
|
|
34
|
+
//# sourceMappingURL=index.cjs.map
|