common-fp 0.1.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/dist/add.cjs +13 -0
- package/dist/add.d.cts +2 -0
- package/dist/add.d.ts +1 -0
- package/dist/add.mjs +13 -0
- package/dist/all.cjs +23 -0
- package/dist/all.d.cts +2 -0
- package/dist/all.d.ts +1 -0
- package/dist/all.mjs +23 -0
- package/dist/alter.cjs +24 -0
- package/dist/alter.d.cts +2 -0
- package/dist/alter.d.ts +1 -0
- package/dist/alter.mjs +24 -0
- package/dist/any.cjs +22 -0
- package/dist/any.d.cts +2 -0
- package/dist/any.d.ts +1 -0
- package/dist/any.mjs +22 -0
- package/dist/append-all.cjs +13 -0
- package/dist/append-all.d.cts +2 -0
- package/dist/append-all.d.ts +1 -0
- package/dist/append-all.mjs +13 -0
- package/dist/append-one.cjs +9 -0
- package/dist/append-one.d.cts +2 -0
- package/dist/append-one.d.ts +1 -0
- package/dist/append-one.mjs +9 -0
- package/dist/append.cjs +13 -0
- package/dist/append.d.cts +2 -0
- package/dist/append.d.ts +1 -0
- package/dist/append.mjs +13 -0
- package/dist/assign-defaults.cjs +43 -0
- package/dist/assign-defaults.d.cts +2 -0
- package/dist/assign-defaults.d.ts +1 -0
- package/dist/assign-defaults.mjs +43 -0
- package/dist/assign-overrides.cjs +43 -0
- package/dist/assign-overrides.d.cts +2 -0
- package/dist/assign-overrides.d.ts +1 -0
- package/dist/assign-overrides.mjs +43 -0
- package/dist/compare-by-path.cjs +24 -0
- package/dist/compare-by-path.d.cts +2 -0
- package/dist/compare-by-path.d.ts +1 -0
- package/dist/compare-by-path.mjs +24 -0
- package/dist/compare-by-prop.cjs +23 -0
- package/dist/compare-by-prop.d.cts +2 -0
- package/dist/compare-by-prop.d.ts +1 -0
- package/dist/compare-by-prop.mjs +23 -0
- package/dist/compose.cjs +15 -0
- package/dist/compose.d.cts +2 -0
- package/dist/compose.d.ts +1 -0
- package/dist/compose.mjs +15 -0
- package/dist/contained-in.cjs +26 -0
- package/dist/contained-in.d.cts +2 -0
- package/dist/contained-in.d.ts +1 -0
- package/dist/contained-in.mjs +26 -0
- package/dist/contains.cjs +28 -0
- package/dist/contains.d.cts +2 -0
- package/dist/contains.d.ts +1 -0
- package/dist/contains.mjs +28 -0
- package/dist/date-is-between.cjs +31 -0
- package/dist/date-is-between.d.cts +2 -0
- package/dist/date-is-between.d.ts +1 -0
- package/dist/date-is-between.mjs +31 -0
- package/dist/default-falsey-val-to.cjs +3 -0
- package/dist/default-falsey-val-to.d.cts +2 -0
- package/dist/default-falsey-val-to.d.ts +1 -0
- package/dist/default-falsey-val-to.mjs +3 -0
- package/dist/default-nullish-val-to.cjs +3 -0
- package/dist/default-nullish-val-to.d.cts +2 -0
- package/dist/default-nullish-val-to.d.ts +1 -0
- package/dist/default-nullish-val-to.mjs +3 -0
- package/dist/discard-first-while.cjs +18 -0
- package/dist/discard-first-while.d.cts +2 -0
- package/dist/discard-first-while.d.ts +1 -0
- package/dist/discard-first-while.mjs +18 -0
- package/dist/discard-first.cjs +16 -0
- package/dist/discard-first.d.cts +2 -0
- package/dist/discard-first.d.ts +1 -0
- package/dist/discard-first.mjs +16 -0
- package/dist/discard-last-while.cjs +17 -0
- package/dist/discard-last-while.d.cts +2 -0
- package/dist/discard-last-while.d.ts +1 -0
- package/dist/discard-last-while.mjs +17 -0
- package/dist/discard-last.cjs +16 -0
- package/dist/discard-last.d.cts +2 -0
- package/dist/discard-last.d.ts +1 -0
- package/dist/discard-last.mjs +16 -0
- package/dist/discard-range.cjs +31 -0
- package/dist/discard-range.d.cts +2 -0
- package/dist/discard-range.d.ts +1 -0
- package/dist/discard-range.mjs +31 -0
- package/dist/discard-when.cjs +55 -0
- package/dist/discard-when.d.cts +2 -0
- package/dist/discard-when.d.ts +1 -0
- package/dist/discard-when.mjs +55 -0
- package/dist/discard.cjs +57 -0
- package/dist/discard.d.cts +2 -0
- package/dist/discard.d.ts +1 -0
- package/dist/discard.mjs +57 -0
- package/dist/divide-by.cjs +13 -0
- package/dist/divide-by.d.cts +2 -0
- package/dist/divide-by.d.ts +1 -0
- package/dist/divide-by.mjs +13 -0
- package/dist/ends-with.cjs +13 -0
- package/dist/ends-with.d.cts +2 -0
- package/dist/ends-with.d.ts +1 -0
- package/dist/ends-with.mjs +13 -0
- package/dist/expand-end.cjs +16 -0
- package/dist/expand-end.d.cts +2 -0
- package/dist/expand-end.d.ts +1 -0
- package/dist/expand-end.mjs +16 -0
- package/dist/expand-start.cjs +16 -0
- package/dist/expand-start.d.cts +2 -0
- package/dist/expand-start.d.ts +1 -0
- package/dist/expand-start.mjs +16 -0
- package/dist/expand.cjs +22 -0
- package/dist/expand.d.cts +2 -0
- package/dist/expand.d.ts +1 -0
- package/dist/expand.mjs +22 -0
- package/dist/fill-range-with.cjs +18 -0
- package/dist/fill-range-with.d.cts +2 -0
- package/dist/fill-range-with.d.ts +1 -0
- package/dist/fill-range-with.mjs +18 -0
- package/dist/fill-with.cjs +34 -0
- package/dist/fill-with.d.cts +2 -0
- package/dist/fill-with.d.ts +1 -0
- package/dist/fill-with.mjs +34 -0
- package/dist/find-key-with-val.cjs +46 -0
- package/dist/find-key-with-val.d.cts +2 -0
- package/dist/find-key-with-val.d.ts +1 -0
- package/dist/find-key-with-val.mjs +46 -0
- package/dist/find-key.cjs +21 -0
- package/dist/find-key.d.cts +2 -0
- package/dist/find-key.d.ts +1 -0
- package/dist/find-key.mjs +21 -0
- package/dist/find-last-key-with-val.cjs +23 -0
- package/dist/find-last-key-with-val.d.cts +2 -0
- package/dist/find-last-key-with-val.d.ts +1 -0
- package/dist/find-last-key-with-val.mjs +23 -0
- package/dist/find-last-key.cjs +16 -0
- package/dist/find-last-key.d.cts +2 -0
- package/dist/find-last-key.d.ts +1 -0
- package/dist/find-last-key.mjs +16 -0
- package/dist/find-last.cjs +16 -0
- package/dist/find-last.d.cts +2 -0
- package/dist/find-last.d.ts +1 -0
- package/dist/find-last.mjs +16 -0
- package/dist/find.cjs +21 -0
- package/dist/find.d.cts +2 -0
- package/dist/find.d.ts +1 -0
- package/dist/find.mjs +21 -0
- package/dist/first.cjs +10 -0
- package/dist/first.d.cts +2 -0
- package/dist/first.d.ts +1 -0
- package/dist/first.mjs +10 -0
- package/dist/flatten-fully.cjs +9 -0
- package/dist/flatten-fully.d.cts +2 -0
- package/dist/flatten-fully.d.ts +1 -0
- package/dist/flatten-fully.mjs +9 -0
- package/dist/flatten-once.cjs +9 -0
- package/dist/flatten-once.d.cts +2 -0
- package/dist/flatten-once.d.ts +1 -0
- package/dist/flatten-once.mjs +9 -0
- package/dist/flatten-to-depth.cjs +15 -0
- package/dist/flatten-to-depth.d.cts +2 -0
- package/dist/flatten-to-depth.d.ts +1 -0
- package/dist/flatten-to-depth.mjs +15 -0
- package/dist/for-each.cjs +22 -0
- package/dist/for-each.d.cts +2 -0
- package/dist/for-each.d.ts +1 -0
- package/dist/for-each.mjs +22 -0
- package/dist/get-at-path.cjs +11 -0
- package/dist/get-at-path.d.cts +2 -0
- package/dist/get-at-path.d.ts +1 -0
- package/dist/get-at-path.mjs +11 -0
- package/dist/get-average-value.cjs +19 -0
- package/dist/get-average-value.d.cts +2 -0
- package/dist/get-average-value.d.ts +1 -0
- package/dist/get-average-value.mjs +19 -0
- package/dist/get-common-values.cjs +31 -0
- package/dist/get-common-values.d.cts +2 -0
- package/dist/get-common-values.d.ts +1 -0
- package/dist/get-common-values.mjs +31 -0
- package/dist/get-exclusive-values.cjs +41 -0
- package/dist/get-exclusive-values.d.cts +2 -0
- package/dist/get-exclusive-values.d.ts +1 -0
- package/dist/get-exclusive-values.mjs +41 -0
- package/dist/get-keys.cjs +23 -0
- package/dist/get-keys.d.cts +2 -0
- package/dist/get-keys.d.ts +1 -0
- package/dist/get-keys.mjs +23 -0
- package/dist/get-max-value.cjs +16 -0
- package/dist/get-max-value.d.cts +2 -0
- package/dist/get-max-value.d.ts +1 -0
- package/dist/get-max-value.mjs +16 -0
- package/dist/get-min-value.cjs +16 -0
- package/dist/get-min-value.d.cts +2 -0
- package/dist/get-min-value.d.ts +1 -0
- package/dist/get-min-value.mjs +16 -0
- package/dist/get-random-value.cjs +18 -0
- package/dist/get-random-value.d.cts +2 -0
- package/dist/get-random-value.d.ts +1 -0
- package/dist/get-random-value.mjs +18 -0
- package/dist/get-size.cjs +28 -0
- package/dist/get-size.d.cts +2 -0
- package/dist/get-size.d.ts +1 -0
- package/dist/get-size.mjs +28 -0
- package/dist/get-value-at-map-key.cjs +8 -0
- package/dist/get-value-at-map-key.d.cts +2 -0
- package/dist/get-value-at-map-key.d.ts +1 -0
- package/dist/get-value-at-map-key.mjs +8 -0
- package/dist/get-values.cjs +22 -0
- package/dist/get-values.d.cts +2 -0
- package/dist/get-values.d.ts +1 -0
- package/dist/get-values.mjs +22 -0
- package/dist/get.cjs +10 -0
- package/dist/get.d.cts +2 -0
- package/dist/get.d.ts +1 -0
- package/dist/get.mjs +10 -0
- package/dist/greater-than-or-equal-to.cjs +13 -0
- package/dist/greater-than-or-equal-to.d.cts +2 -0
- package/dist/greater-than-or-equal-to.d.ts +1 -0
- package/dist/greater-than-or-equal-to.mjs +13 -0
- package/dist/greater-than.cjs +13 -0
- package/dist/greater-than.d.cts +2 -0
- package/dist/greater-than.d.ts +1 -0
- package/dist/greater-than.mjs +13 -0
- package/dist/group-by.cjs +28 -0
- package/dist/group-by.d.cts +2 -0
- package/dist/group-by.d.ts +1 -0
- package/dist/group-by.mjs +28 -0
- package/dist/index.cjs +160 -0
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +158 -0
- package/dist/internal/contains-type-to-fn.cjs +33 -0
- package/dist/internal/contains-type-to-fn.mjs +33 -0
- package/dist/internal/get-at-path.cjs +12 -0
- package/dist/internal/get-at-path.mjs +12 -0
- package/dist/internal/validate-prune-arg.cjs +43 -0
- package/dist/internal/validate-prune-arg.mjs +43 -0
- package/dist/invert.cjs +29 -0
- package/dist/invert.d.cts +2 -0
- package/dist/invert.d.ts +1 -0
- package/dist/invert.mjs +29 -0
- package/dist/invoke-with.cjs +11 -0
- package/dist/invoke-with.d.cts +2 -0
- package/dist/invoke-with.d.ts +1 -0
- package/dist/invoke-with.mjs +11 -0
- package/dist/is-after.cjs +13 -0
- package/dist/is-after.d.cts +2 -0
- package/dist/is-after.d.ts +1 -0
- package/dist/is-after.mjs +13 -0
- package/dist/is-at-or-after.cjs +13 -0
- package/dist/is-at-or-after.d.cts +2 -0
- package/dist/is-at-or-after.d.ts +1 -0
- package/dist/is-at-or-after.mjs +13 -0
- package/dist/is-at-or-before.cjs +13 -0
- package/dist/is-at-or-before.d.cts +2 -0
- package/dist/is-at-or-before.d.ts +1 -0
- package/dist/is-at-or-before.mjs +13 -0
- package/dist/is-before.cjs +13 -0
- package/dist/is-before.d.cts +2 -0
- package/dist/is-before.d.ts +1 -0
- package/dist/is-before.mjs +13 -0
- package/dist/is-empty.cjs +28 -0
- package/dist/is-empty.d.cts +2 -0
- package/dist/is-empty.d.ts +1 -0
- package/dist/is-empty.mjs +28 -0
- package/dist/is-falsey.cjs +3 -0
- package/dist/is-falsey.d.cts +2 -0
- package/dist/is-falsey.d.ts +1 -0
- package/dist/is-falsey.mjs +3 -0
- package/dist/is-laden.cjs +28 -0
- package/dist/is-laden.d.cts +2 -0
- package/dist/is-laden.d.ts +1 -0
- package/dist/is-laden.mjs +28 -0
- package/dist/is-truthy.cjs +3 -0
- package/dist/is-truthy.d.cts +2 -0
- package/dist/is-truthy.d.ts +1 -0
- package/dist/is-truthy.mjs +3 -0
- package/dist/join-values.cjs +18 -0
- package/dist/join-values.d.cts +2 -0
- package/dist/join-values.d.ts +1 -0
- package/dist/join-values.mjs +18 -0
- package/dist/keep-first-while.cjs +18 -0
- package/dist/keep-first-while.d.cts +2 -0
- package/dist/keep-first-while.d.ts +1 -0
- package/dist/keep-first-while.mjs +18 -0
- package/dist/keep-first.cjs +14 -0
- package/dist/keep-first.d.cts +2 -0
- package/dist/keep-first.d.ts +1 -0
- package/dist/keep-first.mjs +14 -0
- package/dist/keep-last-while.cjs +18 -0
- package/dist/keep-last-while.d.cts +2 -0
- package/dist/keep-last-while.d.ts +1 -0
- package/dist/keep-last-while.mjs +18 -0
- package/dist/keep-last.cjs +14 -0
- package/dist/keep-last.d.cts +2 -0
- package/dist/keep-last.d.ts +1 -0
- package/dist/keep-last.mjs +14 -0
- package/dist/keep-range.cjs +14 -0
- package/dist/keep-range.d.cts +2 -0
- package/dist/keep-range.d.ts +1 -0
- package/dist/keep-range.mjs +14 -0
- package/dist/keep-when.cjs +54 -0
- package/dist/keep-when.d.cts +2 -0
- package/dist/keep-when.d.ts +1 -0
- package/dist/keep-when.mjs +54 -0
- package/dist/keep.cjs +63 -0
- package/dist/keep.d.cts +2 -0
- package/dist/keep.d.ts +1 -0
- package/dist/keep.mjs +63 -0
- package/dist/last.cjs +10 -0
- package/dist/last.d.cts +2 -0
- package/dist/last.d.ts +1 -0
- package/dist/last.mjs +10 -0
- package/dist/less-than-or-equal-to.cjs +13 -0
- package/dist/less-than-or-equal-to.d.cts +2 -0
- package/dist/less-than-or-equal-to.d.ts +1 -0
- package/dist/less-than-or-equal-to.mjs +13 -0
- package/dist/less-than.cjs +13 -0
- package/dist/less-than.d.cts +2 -0
- package/dist/less-than.d.ts +1 -0
- package/dist/less-than.mjs +13 -0
- package/dist/m-append-all.cjs +14 -0
- package/dist/m-append-all.d.cts +2 -0
- package/dist/m-append-all.d.ts +1 -0
- package/dist/m-append-all.mjs +14 -0
- package/dist/m-append-one.cjs +10 -0
- package/dist/m-append-one.d.cts +2 -0
- package/dist/m-append-one.d.ts +1 -0
- package/dist/m-append-one.mjs +10 -0
- package/dist/m-assign-defaults.cjs +51 -0
- package/dist/m-assign-defaults.d.cts +2 -0
- package/dist/m-assign-defaults.d.ts +1 -0
- package/dist/m-assign-defaults.mjs +51 -0
- package/dist/m-assign-overrides.cjs +47 -0
- package/dist/m-assign-overrides.d.cts +2 -0
- package/dist/m-assign-overrides.d.ts +1 -0
- package/dist/m-assign-overrides.mjs +47 -0
- package/dist/m-discard-first-while.cjs +19 -0
- package/dist/m-discard-first-while.d.cts +2 -0
- package/dist/m-discard-first-while.d.ts +1 -0
- package/dist/m-discard-first-while.mjs +19 -0
- package/dist/m-discard-first.cjs +16 -0
- package/dist/m-discard-first.d.cts +2 -0
- package/dist/m-discard-first.d.ts +1 -0
- package/dist/m-discard-first.mjs +16 -0
- package/dist/m-discard-last-while.cjs +20 -0
- package/dist/m-discard-last-while.d.cts +2 -0
- package/dist/m-discard-last-while.d.ts +1 -0
- package/dist/m-discard-last-while.mjs +20 -0
- package/dist/m-discard-last.cjs +16 -0
- package/dist/m-discard-last.d.cts +2 -0
- package/dist/m-discard-last.d.ts +1 -0
- package/dist/m-discard-last.mjs +16 -0
- package/dist/m-discard-range.cjs +17 -0
- package/dist/m-discard-range.d.cts +2 -0
- package/dist/m-discard-range.d.ts +1 -0
- package/dist/m-discard-range.mjs +17 -0
- package/dist/m-fill-range-with.cjs +17 -0
- package/dist/m-fill-range-with.d.cts +2 -0
- package/dist/m-fill-range-with.d.ts +1 -0
- package/dist/m-fill-range-with.mjs +17 -0
- package/dist/m-fill-with.cjs +32 -0
- package/dist/m-fill-with.d.cts +2 -0
- package/dist/m-fill-with.d.ts +1 -0
- package/dist/m-fill-with.mjs +32 -0
- package/dist/m-keep-first-while.cjs +19 -0
- package/dist/m-keep-first-while.d.cts +2 -0
- package/dist/m-keep-first-while.d.ts +1 -0
- package/dist/m-keep-first-while.mjs +19 -0
- package/dist/m-keep-first.cjs +14 -0
- package/dist/m-keep-first.d.cts +2 -0
- package/dist/m-keep-first.d.ts +1 -0
- package/dist/m-keep-first.mjs +14 -0
- package/dist/m-keep-last-while.cjs +19 -0
- package/dist/m-keep-last-while.d.cts +2 -0
- package/dist/m-keep-last-while.d.ts +1 -0
- package/dist/m-keep-last-while.mjs +19 -0
- package/dist/m-keep-last.cjs +14 -0
- package/dist/m-keep-last.d.cts +2 -0
- package/dist/m-keep-last.d.ts +1 -0
- package/dist/m-keep-last.mjs +14 -0
- package/dist/m-keep-range.cjs +18 -0
- package/dist/m-keep-range.d.cts +2 -0
- package/dist/m-keep-range.d.ts +1 -0
- package/dist/m-keep-range.mjs +18 -0
- package/dist/m-map-values.cjs +47 -0
- package/dist/m-map-values.d.cts +2 -0
- package/dist/m-map-values.d.ts +1 -0
- package/dist/m-map-values.mjs +47 -0
- package/dist/m-omit.cjs +62 -0
- package/dist/m-omit.d.cts +2 -0
- package/dist/m-omit.d.ts +1 -0
- package/dist/m-omit.mjs +62 -0
- package/dist/m-order.cjs +13 -0
- package/dist/m-order.d.cts +2 -0
- package/dist/m-order.d.ts +1 -0
- package/dist/m-order.mjs +13 -0
- package/dist/m-pick.cjs +67 -0
- package/dist/m-pick.d.cts +2 -0
- package/dist/m-pick.d.ts +1 -0
- package/dist/m-pick.mjs +67 -0
- package/dist/m-prepend-all.cjs +14 -0
- package/dist/m-prepend-all.d.cts +2 -0
- package/dist/m-prepend-all.d.ts +1 -0
- package/dist/m-prepend-all.mjs +14 -0
- package/dist/m-prepend-one.cjs +10 -0
- package/dist/m-prepend-one.d.cts +2 -0
- package/dist/m-prepend-one.d.ts +1 -0
- package/dist/m-prepend-one.mjs +10 -0
- package/dist/m-reverse.cjs +8 -0
- package/dist/m-reverse.d.cts +2 -0
- package/dist/m-reverse.d.ts +1 -0
- package/dist/m-reverse.mjs +8 -0
- package/dist/m-set-at-path.cjs +40 -0
- package/dist/m-set-at-path.d.cts +2 -0
- package/dist/m-set-at-path.d.ts +1 -0
- package/dist/m-set-at-path.mjs +40 -0
- package/dist/m-set.cjs +21 -0
- package/dist/m-set.d.cts +2 -0
- package/dist/m-set.d.ts +1 -0
- package/dist/m-set.mjs +21 -0
- package/dist/m-shuffle.cjs +20 -0
- package/dist/m-shuffle.d.cts +2 -0
- package/dist/m-shuffle.d.ts +1 -0
- package/dist/m-shuffle.mjs +20 -0
- package/dist/m-update.cjs +68 -0
- package/dist/m-update.d.cts +2 -0
- package/dist/m-update.d.ts +1 -0
- package/dist/m-update.mjs +68 -0
- package/dist/map-keys.cjs +36 -0
- package/dist/map-keys.d.cts +2 -0
- package/dist/map-keys.d.ts +1 -0
- package/dist/map-keys.mjs +36 -0
- package/dist/map-values.cjs +50 -0
- package/dist/map-values.d.cts +2 -0
- package/dist/map-values.d.ts +1 -0
- package/dist/map-values.mjs +50 -0
- package/dist/multiply-by.cjs +13 -0
- package/dist/multiply-by.d.cts +2 -0
- package/dist/multiply-by.d.ts +1 -0
- package/dist/multiply-by.mjs +13 -0
- package/dist/negate.cjs +9 -0
- package/dist/negate.d.cts +2 -0
- package/dist/negate.d.ts +1 -0
- package/dist/negate.mjs +9 -0
- package/dist/number-is-between.cjs +33 -0
- package/dist/number-is-between.d.cts +2 -0
- package/dist/number-is-between.d.ts +1 -0
- package/dist/number-is-between.mjs +33 -0
- package/dist/omit.cjs +52 -0
- package/dist/omit.d.cts +2 -0
- package/dist/omit.d.ts +1 -0
- package/dist/omit.mjs +52 -0
- package/dist/order.cjs +13 -0
- package/dist/order.d.cts +2 -0
- package/dist/order.d.ts +1 -0
- package/dist/order.mjs +13 -0
- package/dist/p-all.cjs +23 -0
- package/dist/p-all.d.cts +2 -0
- package/dist/p-all.d.ts +1 -0
- package/dist/p-all.mjs +23 -0
- package/dist/p-any.cjs +23 -0
- package/dist/p-any.d.cts +2 -0
- package/dist/p-any.d.ts +1 -0
- package/dist/p-any.mjs +23 -0
- package/dist/p-compose.cjs +18 -0
- package/dist/p-compose.d.cts +2 -0
- package/dist/p-compose.d.ts +1 -0
- package/dist/p-compose.mjs +18 -0
- package/dist/p-discard-when.cjs +64 -0
- package/dist/p-discard-when.d.cts +2 -0
- package/dist/p-discard-when.d.ts +1 -0
- package/dist/p-discard-when.mjs +64 -0
- package/dist/p-find.cjs +21 -0
- package/dist/p-find.d.cts +2 -0
- package/dist/p-find.d.ts +1 -0
- package/dist/p-find.mjs +21 -0
- package/dist/p-for-each.cjs +21 -0
- package/dist/p-for-each.d.cts +2 -0
- package/dist/p-for-each.d.ts +1 -0
- package/dist/p-for-each.mjs +21 -0
- package/dist/p-keep-when.cjs +64 -0
- package/dist/p-keep-when.d.cts +2 -0
- package/dist/p-keep-when.d.ts +1 -0
- package/dist/p-keep-when.mjs +64 -0
- package/dist/p-map-values.cjs +57 -0
- package/dist/p-map-values.d.cts +2 -0
- package/dist/p-map-values.d.ts +1 -0
- package/dist/p-map-values.mjs +57 -0
- package/dist/p-pass-through.cjs +12 -0
- package/dist/p-pass-through.d.cts +2 -0
- package/dist/p-pass-through.d.ts +1 -0
- package/dist/p-pass-through.mjs +12 -0
- package/dist/p-resolve-values.cjs +43 -0
- package/dist/p-resolve-values.d.cts +2 -0
- package/dist/p-resolve-values.d.ts +1 -0
- package/dist/p-resolve-values.mjs +43 -0
- package/dist/p-wait-ms.cjs +8 -0
- package/dist/p-wait-ms.d.cts +2 -0
- package/dist/p-wait-ms.d.ts +1 -0
- package/dist/p-wait-ms.mjs +8 -0
- package/dist/pass-through.cjs +9 -0
- package/dist/pass-through.d.cts +2 -0
- package/dist/pass-through.d.ts +1 -0
- package/dist/pass-through.mjs +9 -0
- package/dist/peek.cjs +13 -0
- package/dist/peek.d.cts +2 -0
- package/dist/peek.d.ts +1 -0
- package/dist/peek.mjs +13 -0
- package/dist/pick.cjs +50 -0
- package/dist/pick.d.cts +2 -0
- package/dist/pick.d.ts +1 -0
- package/dist/pick.mjs +50 -0
- package/dist/prepend-all.cjs +13 -0
- package/dist/prepend-all.d.cts +2 -0
- package/dist/prepend-all.d.ts +1 -0
- package/dist/prepend-all.mjs +13 -0
- package/dist/prepend-one.cjs +9 -0
- package/dist/prepend-one.d.cts +2 -0
- package/dist/prepend-one.d.ts +1 -0
- package/dist/prepend-one.mjs +9 -0
- package/dist/prepend.cjs +13 -0
- package/dist/prepend.d.cts +2 -0
- package/dist/prepend.d.ts +1 -0
- package/dist/prepend.mjs +13 -0
- package/dist/prune-end.cjs +18 -0
- package/dist/prune-end.d.cts +2 -0
- package/dist/prune-end.d.ts +1 -0
- package/dist/prune-end.mjs +18 -0
- package/dist/prune-start.cjs +18 -0
- package/dist/prune-start.d.cts +2 -0
- package/dist/prune-start.d.ts +1 -0
- package/dist/prune-start.mjs +18 -0
- package/dist/prune.cjs +21 -0
- package/dist/prune.d.cts +2 -0
- package/dist/prune.d.ts +1 -0
- package/dist/prune.mjs +21 -0
- package/dist/randomly-keep.cjs +83 -0
- package/dist/randomly-keep.d.cts +2 -0
- package/dist/randomly-keep.d.ts +1 -0
- package/dist/randomly-keep.mjs +83 -0
- package/dist/replace-all-matches.cjs +33 -0
- package/dist/replace-all-matches.d.cts +2 -0
- package/dist/replace-all-matches.d.ts +1 -0
- package/dist/replace-all-matches.mjs +33 -0
- package/dist/replace-first-match.cjs +38 -0
- package/dist/replace-first-match.d.cts +2 -0
- package/dist/replace-first-match.d.ts +1 -0
- package/dist/replace-first-match.mjs +38 -0
- package/dist/return-first-arg.cjs +4 -0
- package/dist/return-first-arg.d.cts +2 -0
- package/dist/return-first-arg.d.ts +1 -0
- package/dist/return-first-arg.mjs +4 -0
- package/dist/return-undefined.cjs +4 -0
- package/dist/return-undefined.d.cts +2 -0
- package/dist/return-undefined.d.ts +1 -0
- package/dist/return-undefined.mjs +4 -0
- package/dist/reverse.cjs +8 -0
- package/dist/reverse.d.cts +2 -0
- package/dist/reverse.d.ts +1 -0
- package/dist/reverse.mjs +8 -0
- package/dist/round-to-nearest.cjs +51 -0
- package/dist/round-to-nearest.d.cts +2 -0
- package/dist/round-to-nearest.d.ts +1 -0
- package/dist/round-to-nearest.mjs +51 -0
- package/dist/set.cjs +51 -0
- package/dist/set.d.cts +2 -0
- package/dist/set.d.ts +1 -0
- package/dist/set.mjs +51 -0
- package/dist/shuffle.cjs +21 -0
- package/dist/shuffle.d.cts +2 -0
- package/dist/shuffle.d.ts +1 -0
- package/dist/shuffle.mjs +21 -0
- package/dist/split-every.cjs +31 -0
- package/dist/split-every.d.cts +2 -0
- package/dist/split-every.d.ts +1 -0
- package/dist/split-every.mjs +31 -0
- package/dist/split.cjs +14 -0
- package/dist/split.d.cts +2 -0
- package/dist/split.d.ts +1 -0
- package/dist/split.mjs +14 -0
- package/dist/starts-with.cjs +13 -0
- package/dist/starts-with.d.cts +2 -0
- package/dist/starts-with.d.ts +1 -0
- package/dist/starts-with.mjs +13 -0
- package/dist/strict-equals.cjs +3 -0
- package/dist/strict-equals.d.cts +2 -0
- package/dist/strict-equals.d.ts +1 -0
- package/dist/strict-equals.mjs +3 -0
- package/dist/subtract.cjs +13 -0
- package/dist/subtract.d.cts +2 -0
- package/dist/subtract.d.ts +1 -0
- package/dist/subtract.mjs +13 -0
- package/dist/sum-values.cjs +20 -0
- package/dist/sum-values.d.cts +2 -0
- package/dist/sum-values.d.ts +1 -0
- package/dist/sum-values.mjs +20 -0
- package/dist/swap-first-two-args.cjs +15 -0
- package/dist/swap-first-two-args.d.cts +2 -0
- package/dist/swap-first-two-args.d.ts +1 -0
- package/dist/swap-first-two-args.mjs +15 -0
- package/dist/transpose.cjs +46 -0
- package/dist/transpose.d.cts +2 -0
- package/dist/transpose.d.ts +1 -0
- package/dist/transpose.mjs +46 -0
- package/dist/truncate-to-n-chars.cjs +17 -0
- package/dist/truncate-to-n-chars.d.cts +2 -0
- package/dist/truncate-to-n-chars.d.ts +1 -0
- package/dist/truncate-to-n-chars.mjs +17 -0
- package/dist/truncate-to-n-lines.cjs +58 -0
- package/dist/truncate-to-n-lines.d.cts +2 -0
- package/dist/truncate-to-n-lines.d.ts +1 -0
- package/dist/truncate-to-n-lines.mjs +58 -0
- package/dist/update.cjs +74 -0
- package/dist/update.d.cts +2 -0
- package/dist/update.d.ts +1 -0
- package/dist/update.mjs +74 -0
- package/dist/with-dates-ascending.cjs +3 -0
- package/dist/with-dates-ascending.d.cts +2 -0
- package/dist/with-dates-ascending.d.ts +1 -0
- package/dist/with-dates-ascending.mjs +3 -0
- package/dist/with-dates-descending.cjs +3 -0
- package/dist/with-dates-descending.d.cts +2 -0
- package/dist/with-dates-descending.d.ts +1 -0
- package/dist/with-dates-descending.mjs +3 -0
- package/dist/with-numbers-ascending.cjs +3 -0
- package/dist/with-numbers-ascending.d.cts +2 -0
- package/dist/with-numbers-ascending.d.ts +1 -0
- package/dist/with-numbers-ascending.mjs +3 -0
- package/dist/with-numbers-descending.cjs +3 -0
- package/dist/with-numbers-descending.d.cts +2 -0
- package/dist/with-numbers-descending.d.ts +1 -0
- package/dist/with-numbers-descending.mjs +3 -0
- package/dist/with-strings-ascending.cjs +4 -0
- package/dist/with-strings-ascending.d.cts +2 -0
- package/dist/with-strings-ascending.d.ts +1 -0
- package/dist/with-strings-ascending.mjs +4 -0
- package/dist/with-strings-descending.cjs +4 -0
- package/dist/with-strings-descending.d.cts +2 -0
- package/dist/with-strings-descending.d.ts +1 -0
- package/dist/with-strings-descending.mjs +4 -0
- package/license.txt +41 -0
- package/package.json +46 -0
- package/readme.md +108 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import assertArgIsType from '@common-fp/shared-internals/assert-arg-is-type'
|
|
2
|
+
import truncateToNChars from '@common-fp/shared-internals/truncate-to-n-chars'
|
|
3
|
+
|
|
4
|
+
const roundToNearest = precision => {
|
|
5
|
+
validatePrecision(precision)
|
|
6
|
+
const numPrecision =
|
|
7
|
+
precision.includes('.') ?
|
|
8
|
+
precision.length - 2 // 2 accounts for the leading "0."
|
|
9
|
+
: -precision.length + 1
|
|
10
|
+
|
|
11
|
+
return aNumber => {
|
|
12
|
+
assertArgIsType(aNumber, 'aNumber', 'number', 'roundToNearest')
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* implementation based off lodash. Essentially we're
|
|
16
|
+
* 1. shifting the exponent based off the precision passed
|
|
17
|
+
* 2. rounding the shifted result
|
|
18
|
+
* 3. shifting it back and returning the value
|
|
19
|
+
*
|
|
20
|
+
* per lodash this gets around pesky floating point issues
|
|
21
|
+
*/
|
|
22
|
+
const [base, exp] = aNumber.toExponential().split('e')
|
|
23
|
+
const shiftedNum = Math.round(base + 'e' + (Number(exp) + numPrecision))
|
|
24
|
+
|
|
25
|
+
const [shiftedBase, shiftedExp] = shiftedNum.toExponential().split('e')
|
|
26
|
+
return Number(shiftedBase + 'e' + (Number(shiftedExp) - numPrecision))
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function validatePrecision(precision) {
|
|
31
|
+
assertArgIsType(precision, 'precision', 'string', 'roundToNearest')
|
|
32
|
+
if (precision.includes('.')) {
|
|
33
|
+
if (!/^0\.0{0,9}1$/.test(precision)) {
|
|
34
|
+
const truncatedPrecision = truncateToNChars(15, precision)
|
|
35
|
+
throw new Error(
|
|
36
|
+
'With a decimal, roundToNearest requires a precision passing the regex /^0\\.0{0,9}1$/' +
|
|
37
|
+
`\n precision: ${truncatedPrecision}`
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
} else {
|
|
41
|
+
if (!/^10{0,9}$/.test(precision)) {
|
|
42
|
+
const truncatedPrecision = truncateToNChars(15, precision)
|
|
43
|
+
throw new Error(
|
|
44
|
+
'Without a decimal, roundToNearest requires a precision passing the regex /^10{0,9}$/' +
|
|
45
|
+
`\n precision: ${truncatedPrecision}`
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default roundToNearest
|
package/dist/set.cjs
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const ct = require('@common-fp/shared-internals/common-types')
|
|
2
|
+
const getFn = require('@common-fp/shared-internals/get-fn')
|
|
3
|
+
const getType = require('@common-fp/shared-internals/get-type')
|
|
4
|
+
|
|
5
|
+
const set = (key, val) => {
|
|
6
|
+
const keyType = getType(key)
|
|
7
|
+
|
|
8
|
+
return collection => {
|
|
9
|
+
const typeFn = getFn(typeToFn, collection, 'collection', 'set')
|
|
10
|
+
return typeFn(collection, key, val, keyType)
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const typeToFn = {
|
|
15
|
+
array: set_array,
|
|
16
|
+
map: set_map,
|
|
17
|
+
object: set_object,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function set_array(arr, key, val, keyType) {
|
|
21
|
+
if (!ct.objectKey.has(keyType)) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
"when calling set with an array, 'key' must be a number or string" +
|
|
24
|
+
`\n key type: ${keyType}`
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const result = [...arr]
|
|
29
|
+
|
|
30
|
+
result[key] = val
|
|
31
|
+
|
|
32
|
+
return result
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function set_map(aMap, key, val) {
|
|
36
|
+
const result = new Map(aMap)
|
|
37
|
+
return result.set(key, val)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function set_object(obj, key, val, keyType) {
|
|
41
|
+
if (!ct.objectKey.has(keyType)) {
|
|
42
|
+
throw new Error(
|
|
43
|
+
"when calling set with an object, 'key' must be a number or string" +
|
|
44
|
+
`\n key type: ${keyType}`
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return { ...obj, [key]: val }
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
module.exports = set
|
package/dist/set.d.cts
ADDED
package/dist/set.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@common-fp/common-fp-types/set'
|
package/dist/set.mjs
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as ct from '@common-fp/shared-internals/common-types'
|
|
2
|
+
import getFn from '@common-fp/shared-internals/get-fn'
|
|
3
|
+
import getType from '@common-fp/shared-internals/get-type'
|
|
4
|
+
|
|
5
|
+
const set = (key, val) => {
|
|
6
|
+
const keyType = getType(key)
|
|
7
|
+
|
|
8
|
+
return collection => {
|
|
9
|
+
const typeFn = getFn(typeToFn, collection, 'collection', 'set')
|
|
10
|
+
return typeFn(collection, key, val, keyType)
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const typeToFn = {
|
|
15
|
+
array: set_array,
|
|
16
|
+
map: set_map,
|
|
17
|
+
object: set_object,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function set_array(arr, key, val, keyType) {
|
|
21
|
+
if (!ct.objectKey.has(keyType)) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
"when calling set with an array, 'key' must be a number or string" +
|
|
24
|
+
`\n key type: ${keyType}`
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const result = [...arr]
|
|
29
|
+
|
|
30
|
+
result[key] = val
|
|
31
|
+
|
|
32
|
+
return result
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function set_map(aMap, key, val) {
|
|
36
|
+
const result = new Map(aMap)
|
|
37
|
+
return result.set(key, val)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function set_object(obj, key, val, keyType) {
|
|
41
|
+
if (!ct.objectKey.has(keyType)) {
|
|
42
|
+
throw new Error(
|
|
43
|
+
"when calling set with an object, 'key' must be a number or string" +
|
|
44
|
+
`\n key type: ${keyType}`
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return { ...obj, [key]: val }
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default set
|
package/dist/shuffle.cjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const assertArgIsType = require('@common-fp/shared-internals/assert-arg-is-type')
|
|
2
|
+
const getRandomInt = require('@common-fp/shared-internals/get-random-int')
|
|
3
|
+
|
|
4
|
+
const shuffle = anArray => {
|
|
5
|
+
assertArgIsType(anArray, 'anArray', 'array', 'shuffle')
|
|
6
|
+
|
|
7
|
+
const result = [...anArray]
|
|
8
|
+
const len = result.length
|
|
9
|
+
for (let i = 0; i < len - 1; i += 1) {
|
|
10
|
+
const randomI = getRandomInt(i, len - 1)
|
|
11
|
+
if (randomI === i) continue
|
|
12
|
+
|
|
13
|
+
const tmp = result[i]
|
|
14
|
+
result[i] = result[randomI]
|
|
15
|
+
result[randomI] = tmp
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return result
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = shuffle
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@common-fp/common-fp-types/shuffle'
|
package/dist/shuffle.mjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import assertArgIsType from '@common-fp/shared-internals/assert-arg-is-type'
|
|
2
|
+
import getRandomInt from '@common-fp/shared-internals/get-random-int'
|
|
3
|
+
|
|
4
|
+
const shuffle = anArray => {
|
|
5
|
+
assertArgIsType(anArray, 'anArray', 'array', 'shuffle')
|
|
6
|
+
|
|
7
|
+
const result = [...anArray]
|
|
8
|
+
const len = result.length
|
|
9
|
+
for (let i = 0; i < len - 1; i += 1) {
|
|
10
|
+
const randomI = getRandomInt(i, len - 1)
|
|
11
|
+
if (randomI === i) continue
|
|
12
|
+
|
|
13
|
+
const tmp = result[i]
|
|
14
|
+
result[i] = result[randomI]
|
|
15
|
+
result[randomI] = tmp
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return result
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default shuffle
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const assertArgIsInt = require('@common-fp/shared-internals/assert-arg-is-int')
|
|
2
|
+
const assertArgTypeIsOneOf = require('@common-fp/shared-internals/assert-arg-type-is-one-of')
|
|
3
|
+
const ct = require('@common-fp/shared-internals/common-types')
|
|
4
|
+
const getType = require('@common-fp/shared-internals/get-type')
|
|
5
|
+
|
|
6
|
+
const splitEvery = groupSize => {
|
|
7
|
+
assertArgIsInt(groupSize, 'groupSize', 'splitEvery', { positive: true })
|
|
8
|
+
|
|
9
|
+
return sequence => {
|
|
10
|
+
const seqType = getType(sequence)
|
|
11
|
+
assertArgTypeIsOneOf(seqType, 'sequence', ct.sequence, 'splitEvery')
|
|
12
|
+
|
|
13
|
+
if (!sequence.length) {
|
|
14
|
+
const emptySeq = seqType === 'string' ? '' : []
|
|
15
|
+
return [emptySeq]
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const numArrays = Math.ceil(sequence.length / groupSize)
|
|
19
|
+
const res = new Array(numArrays)
|
|
20
|
+
|
|
21
|
+
for (let i = 0; i < numArrays - 1; i += 1) {
|
|
22
|
+
res[i] = sequence.slice(i * groupSize, (i + 1) * groupSize)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
res[numArrays - 1] = sequence.slice((numArrays - 1) * groupSize)
|
|
26
|
+
|
|
27
|
+
return res
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = splitEvery
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@common-fp/common-fp-types/split-every'
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import assertArgIsInt from '@common-fp/shared-internals/assert-arg-is-int'
|
|
2
|
+
import assertArgTypeIsOneOf from '@common-fp/shared-internals/assert-arg-type-is-one-of'
|
|
3
|
+
import * as ct from '@common-fp/shared-internals/common-types'
|
|
4
|
+
import getType from '@common-fp/shared-internals/get-type'
|
|
5
|
+
|
|
6
|
+
const splitEvery = groupSize => {
|
|
7
|
+
assertArgIsInt(groupSize, 'groupSize', 'splitEvery', { positive: true })
|
|
8
|
+
|
|
9
|
+
return sequence => {
|
|
10
|
+
const seqType = getType(sequence)
|
|
11
|
+
assertArgTypeIsOneOf(seqType, 'sequence', ct.sequence, 'splitEvery')
|
|
12
|
+
|
|
13
|
+
if (!sequence.length) {
|
|
14
|
+
const emptySeq = seqType === 'string' ? '' : []
|
|
15
|
+
return [emptySeq]
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const numArrays = Math.ceil(sequence.length / groupSize)
|
|
19
|
+
const res = new Array(numArrays)
|
|
20
|
+
|
|
21
|
+
for (let i = 0; i < numArrays - 1; i += 1) {
|
|
22
|
+
res[i] = sequence.slice(i * groupSize, (i + 1) * groupSize)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
res[numArrays - 1] = sequence.slice((numArrays - 1) * groupSize)
|
|
26
|
+
|
|
27
|
+
return res
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default splitEvery
|
package/dist/split.cjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const assertArgIsOneOfType = require('@common-fp/shared-internals/assert-arg-is-one-of-type')
|
|
2
|
+
const assertArgIsType = require('@common-fp/shared-internals/assert-arg-is-type')
|
|
3
|
+
|
|
4
|
+
const split = separator => {
|
|
5
|
+
assertArgIsOneOfType(separator, 'separator', ['regexp', 'string'], 'split')
|
|
6
|
+
|
|
7
|
+
return aString => {
|
|
8
|
+
assertArgIsType(aString, 'aString', 'string', 'split')
|
|
9
|
+
|
|
10
|
+
return aString.split(separator)
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
module.exports = split
|
package/dist/split.d.cts
ADDED
package/dist/split.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@common-fp/common-fp-types/split'
|
package/dist/split.mjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import assertArgIsOneOfType from '@common-fp/shared-internals/assert-arg-is-one-of-type'
|
|
2
|
+
import assertArgIsType from '@common-fp/shared-internals/assert-arg-is-type'
|
|
3
|
+
|
|
4
|
+
const split = separator => {
|
|
5
|
+
assertArgIsOneOfType(separator, 'separator', ['regexp', 'string'], 'split')
|
|
6
|
+
|
|
7
|
+
return aString => {
|
|
8
|
+
assertArgIsType(aString, 'aString', 'string', 'split')
|
|
9
|
+
|
|
10
|
+
return aString.split(separator)
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default split
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const assertArgIsType = require('@common-fp/shared-internals/assert-arg-is-type')
|
|
2
|
+
|
|
3
|
+
const startsWith = prefix => {
|
|
4
|
+
assertArgIsType(prefix, 'prefix', 'string', 'startsWith')
|
|
5
|
+
|
|
6
|
+
return aString => {
|
|
7
|
+
assertArgIsType(aString, 'aString', 'string', 'startsWith')
|
|
8
|
+
|
|
9
|
+
return aString.startsWith(prefix)
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
module.exports = startsWith
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@common-fp/common-fp-types/starts-with'
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import assertArgIsType from '@common-fp/shared-internals/assert-arg-is-type'
|
|
2
|
+
|
|
3
|
+
const startsWith = prefix => {
|
|
4
|
+
assertArgIsType(prefix, 'prefix', 'string', 'startsWith')
|
|
5
|
+
|
|
6
|
+
return aString => {
|
|
7
|
+
assertArgIsType(aString, 'aString', 'string', 'startsWith')
|
|
8
|
+
|
|
9
|
+
return aString.startsWith(prefix)
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default startsWith
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@common-fp/common-fp-types/strict-equals'
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const assertArgIsType = require('@common-fp/shared-internals/assert-arg-is-type')
|
|
2
|
+
|
|
3
|
+
const subtract = right => {
|
|
4
|
+
assertArgIsType(right, 'right', 'number', 'subtract')
|
|
5
|
+
|
|
6
|
+
return left => {
|
|
7
|
+
assertArgIsType(left, 'left', 'number', 'subtract')
|
|
8
|
+
|
|
9
|
+
return left - right
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
module.exports = subtract
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@common-fp/common-fp-types/subtract'
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import assertArgIsType from '@common-fp/shared-internals/assert-arg-is-type'
|
|
2
|
+
|
|
3
|
+
const subtract = right => {
|
|
4
|
+
assertArgIsType(right, 'right', 'number', 'subtract')
|
|
5
|
+
|
|
6
|
+
return left => {
|
|
7
|
+
assertArgIsType(left, 'left', 'number', 'subtract')
|
|
8
|
+
|
|
9
|
+
return left - right
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default subtract
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const assertArgHasValuesOfType = require('@common-fp/shared-internals/assert-arg-has-values-of-type')
|
|
2
|
+
const assertArgTypeIsOneOf = require('@common-fp/shared-internals/assert-arg-type-is-one-of')
|
|
3
|
+
const ct = require('@common-fp/shared-internals/common-types')
|
|
4
|
+
const getIterator = require('@common-fp/shared-internals/get-iterator')
|
|
5
|
+
const getType = require('@common-fp/shared-internals/get-type')
|
|
6
|
+
|
|
7
|
+
const sumValues = collection => {
|
|
8
|
+
const collType = getType(collection)
|
|
9
|
+
assertArgTypeIsOneOf(collType, 'collection', ct.collection, 'sumValues')
|
|
10
|
+
assertArgHasValuesOfType(collection, 'collection', 'number', 'sumValues')
|
|
11
|
+
|
|
12
|
+
const values = getIterator('values', collection, collType)
|
|
13
|
+
let sum = 0
|
|
14
|
+
for (const num of values) {
|
|
15
|
+
sum += num
|
|
16
|
+
}
|
|
17
|
+
return sum
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
module.exports = sumValues
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@common-fp/common-fp-types/sum-values'
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import assertArgHasValuesOfType from '@common-fp/shared-internals/assert-arg-has-values-of-type'
|
|
2
|
+
import assertArgTypeIsOneOf from '@common-fp/shared-internals/assert-arg-type-is-one-of'
|
|
3
|
+
import * as ct from '@common-fp/shared-internals/common-types'
|
|
4
|
+
import getIterator from '@common-fp/shared-internals/get-iterator'
|
|
5
|
+
import getType from '@common-fp/shared-internals/get-type'
|
|
6
|
+
|
|
7
|
+
const sumValues = collection => {
|
|
8
|
+
const collType = getType(collection)
|
|
9
|
+
assertArgTypeIsOneOf(collType, 'collection', ct.collection, 'sumValues')
|
|
10
|
+
assertArgHasValuesOfType(collection, 'collection', 'number', 'sumValues')
|
|
11
|
+
|
|
12
|
+
const values = getIterator('values', collection, collType)
|
|
13
|
+
let sum = 0
|
|
14
|
+
for (const num of values) {
|
|
15
|
+
sum += num
|
|
16
|
+
}
|
|
17
|
+
return sum
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default sumValues
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const swapFirstTwoArgs =
|
|
2
|
+
fn =>
|
|
3
|
+
(...args) => {
|
|
4
|
+
if (!args.length) return fn()
|
|
5
|
+
|
|
6
|
+
// don't change the number of arguments passed to the function, just
|
|
7
|
+
// pass undefined
|
|
8
|
+
if (args.length === 1) return fn(undefined)
|
|
9
|
+
|
|
10
|
+
return args.length === 2 ?
|
|
11
|
+
fn(args[1], args[0])
|
|
12
|
+
: fn(args[1], args[0], ...args.slice(2))
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
module.exports = swapFirstTwoArgs
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@common-fp/common-fp-types/swap-first-two-args'
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const swapFirstTwoArgs =
|
|
2
|
+
fn =>
|
|
3
|
+
(...args) => {
|
|
4
|
+
if (!args.length) return fn()
|
|
5
|
+
|
|
6
|
+
// don't change the number of arguments passed to the function, just
|
|
7
|
+
// pass undefined
|
|
8
|
+
if (args.length === 1) return fn(undefined)
|
|
9
|
+
|
|
10
|
+
return args.length === 2 ?
|
|
11
|
+
fn(args[1], args[0])
|
|
12
|
+
: fn(args[1], args[0], ...args.slice(2))
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default swapFirstTwoArgs
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const assertArgIsArrayOfType = require('@common-fp/shared-internals/assert-arg-is-array-of-type')
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* commonly known as _.zip
|
|
5
|
+
* https://lodash.com/docs/4.17.15#zip
|
|
6
|
+
*
|
|
7
|
+
* wiki article
|
|
8
|
+
* https://en.wikipedia.org/wiki/Transpose
|
|
9
|
+
*/
|
|
10
|
+
const transpose = anArray => {
|
|
11
|
+
assertArgIsArrayOfType(anArray, 'anArray', 'array', 'transpose')
|
|
12
|
+
if (!anArray.length) return []
|
|
13
|
+
|
|
14
|
+
validateArraysHaveSameLength(anArray)
|
|
15
|
+
|
|
16
|
+
const numCols = anArray[0].length
|
|
17
|
+
const numRows = anArray.length
|
|
18
|
+
const result = new Array(numCols)
|
|
19
|
+
|
|
20
|
+
for (let col = 0; col < numCols; col += 1) {
|
|
21
|
+
const group = new Array(numRows)
|
|
22
|
+
|
|
23
|
+
for (let row = 0; row < numRows; row += 1) {
|
|
24
|
+
group[row] = anArray[row][col]
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
result[col] = group
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return result
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function validateArraysHaveSameLength(anArray) {
|
|
34
|
+
const expectedLength = anArray[0].length
|
|
35
|
+
|
|
36
|
+
const allArraysHaveSameLength = anArray
|
|
37
|
+
.slice(1)
|
|
38
|
+
.every(arr => arr.length === expectedLength)
|
|
39
|
+
if (!allArraysHaveSameLength) {
|
|
40
|
+
const errMsg =
|
|
41
|
+
"transpose requires 'anArray' to contain arrays of equal length"
|
|
42
|
+
throw new Error(errMsg)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
module.exports = transpose
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@common-fp/common-fp-types/transpose'
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import assertArgIsArrayOfType from '@common-fp/shared-internals/assert-arg-is-array-of-type'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* commonly known as _.zip
|
|
5
|
+
* https://lodash.com/docs/4.17.15#zip
|
|
6
|
+
*
|
|
7
|
+
* wiki article
|
|
8
|
+
* https://en.wikipedia.org/wiki/Transpose
|
|
9
|
+
*/
|
|
10
|
+
const transpose = anArray => {
|
|
11
|
+
assertArgIsArrayOfType(anArray, 'anArray', 'array', 'transpose')
|
|
12
|
+
if (!anArray.length) return []
|
|
13
|
+
|
|
14
|
+
validateArraysHaveSameLength(anArray)
|
|
15
|
+
|
|
16
|
+
const numCols = anArray[0].length
|
|
17
|
+
const numRows = anArray.length
|
|
18
|
+
const result = new Array(numCols)
|
|
19
|
+
|
|
20
|
+
for (let col = 0; col < numCols; col += 1) {
|
|
21
|
+
const group = new Array(numRows)
|
|
22
|
+
|
|
23
|
+
for (let row = 0; row < numRows; row += 1) {
|
|
24
|
+
group[row] = anArray[row][col]
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
result[col] = group
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return result
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function validateArraysHaveSameLength(anArray) {
|
|
34
|
+
const expectedLength = anArray[0].length
|
|
35
|
+
|
|
36
|
+
const allArraysHaveSameLength = anArray
|
|
37
|
+
.slice(1)
|
|
38
|
+
.every(arr => arr.length === expectedLength)
|
|
39
|
+
if (!allArraysHaveSameLength) {
|
|
40
|
+
const errMsg =
|
|
41
|
+
"transpose requires 'anArray' to contain arrays of equal length"
|
|
42
|
+
throw new Error(errMsg)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default transpose
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const assertArgIsType = require('@common-fp/shared-internals/assert-arg-is-type')
|
|
2
|
+
const assertArgIsInt = require('@common-fp/shared-internals/assert-arg-is-int')
|
|
3
|
+
const truncateToNCharsInternal = require('@common-fp/shared-internals/truncate-to-n-chars')
|
|
4
|
+
|
|
5
|
+
const truncateToNChars = n => {
|
|
6
|
+
assertArgIsInt(n, 'n', 'truncateToNChars', {
|
|
7
|
+
nonNegative: true,
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
return aString => {
|
|
11
|
+
assertArgIsType(aString, 'aString', 'string', 'truncateToNChars')
|
|
12
|
+
|
|
13
|
+
return truncateToNCharsInternal(n, aString)
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = truncateToNChars
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@common-fp/common-fp-types/truncate-to-n-chars'
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import assertArgIsType from '@common-fp/shared-internals/assert-arg-is-type'
|
|
2
|
+
import assertArgIsInt from '@common-fp/shared-internals/assert-arg-is-int'
|
|
3
|
+
import truncateToNCharsInternal from '@common-fp/shared-internals/truncate-to-n-chars'
|
|
4
|
+
|
|
5
|
+
const truncateToNChars = n => {
|
|
6
|
+
assertArgIsInt(n, 'n', 'truncateToNChars', {
|
|
7
|
+
nonNegative: true,
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
return aString => {
|
|
11
|
+
assertArgIsType(aString, 'aString', 'string', 'truncateToNChars')
|
|
12
|
+
|
|
13
|
+
return truncateToNCharsInternal(n, aString)
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default truncateToNChars
|