@asd14/m 6.6.0 → 7.3.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/LICENSE +1 -1
- package/README.md +9 -10
- package/dist/all/all.js +14 -27
- package/dist/all/all.js.map +1 -0
- package/dist/all/all.test.js +18 -24
- package/dist/all/all.test.js.map +1 -0
- package/dist/any/any.js +16 -29
- package/dist/any/any.js.map +1 -0
- package/dist/any/any.test.js +16 -21
- package/dist/any/any.test.js.map +1 -0
- package/dist/append/append.js +8 -18
- package/dist/append/append.js.map +1 -0
- package/dist/append/append.test.js +10 -15
- package/dist/append/append.test.js.map +1 -0
- package/dist/bottom/bottom.js +8 -16
- package/dist/bottom/bottom.js.map +1 -0
- package/dist/bottom/bottom.test.js +16 -21
- package/dist/bottom/bottom.test.js.map +1 -0
- package/dist/cases/cases.js +11 -24
- package/dist/cases/cases.js.map +1 -0
- package/dist/cases/cases.test.js +8 -13
- package/dist/cases/cases.test.js.map +1 -0
- package/dist/clone/clone.js +20 -33
- package/dist/clone/clone.js.map +1 -0
- package/dist/clone/clone.test.js +16 -21
- package/dist/clone/clone.test.js.map +1 -0
- package/dist/compact/compact.js +21 -35
- package/dist/compact/compact.js.map +1 -0
- package/dist/compact/compact.test.js +17 -21
- package/dist/compact/compact.test.js.map +1 -0
- package/dist/contains/contains.js +6 -13
- package/dist/contains/contains.js.map +1 -0
- package/dist/contains/contains.test.js +9 -14
- package/dist/contains/contains.test.js.map +1 -0
- package/dist/converge/converge.js +11 -22
- package/dist/converge/converge.js.map +1 -0
- package/dist/converge/converge.test.js +18 -24
- package/dist/converge/converge.test.js.map +1 -0
- package/dist/count/count.js +22 -40
- package/dist/count/count.js.map +1 -0
- package/dist/count/count.test.js +26 -34
- package/dist/count/count.test.js.map +1 -0
- package/dist/curry/curry.js +5 -15
- package/dist/curry/curry.js.map +1 -0
- package/dist/curry/curry.test.js +9 -48
- package/dist/curry/curry.test.js.map +1 -0
- package/dist/debounce/debounce.js +2 -8
- package/dist/debounce/debounce.js.map +1 -0
- package/dist/debounce/debounce.test.js +9 -14
- package/dist/debounce/debounce.test.js.map +1 -0
- package/dist/dec/dec.js +5 -13
- package/dist/dec/dec.js.map +1 -0
- package/dist/dec/dec.test.js +6 -11
- package/dist/dec/dec.test.js.map +1 -0
- package/dist/deep-equal/deep-equal.bench.js +28 -37
- package/dist/deep-equal/deep-equal.bench.js.map +1 -0
- package/dist/deep-equal/deep-equal.js +5 -83
- package/dist/deep-equal/deep-equal.js.map +1 -0
- package/dist/deep-equal/deep-equal.own.js +117 -0
- package/dist/deep-equal/deep-equal.own.js.map +1 -0
- package/dist/deep-equal/deep-equal.test.js +34 -32
- package/dist/deep-equal/deep-equal.test.js.map +1 -0
- package/dist/distinct/distinct.bench.js +13 -19
- package/dist/distinct/distinct.bench.js.map +1 -0
- package/dist/distinct/distinct.js +13 -24
- package/dist/distinct/distinct.js.map +1 -0
- package/dist/distinct/distinct.test.js +20 -82
- package/dist/distinct/distinct.test.js.map +1 -0
- package/dist/drop-last/drop-last.js +9 -17
- package/dist/drop-last/drop-last.js.map +1 -0
- package/dist/drop-last/drop-last.test.js +11 -16
- package/dist/drop-last/drop-last.test.js.map +1 -0
- package/dist/elapsed-time/elapsed-time.js +3 -11
- package/dist/elapsed-time/elapsed-time.js.map +1 -0
- package/dist/elapsed-time/elapsed-time.test.js +6 -11
- package/dist/elapsed-time/elapsed-time.test.js.map +1 -0
- package/dist/ends-with/ends-with.js +7 -14
- package/dist/ends-with/ends-with.js.map +1 -0
- package/dist/ends-with/ends-with.test.js +10 -15
- package/dist/ends-with/ends-with.test.js.map +1 -0
- package/dist/escape/escape.js +5 -12
- package/dist/escape/escape.js.map +1 -0
- package/dist/escape-html/escape-html.js +3 -11
- package/dist/escape-html/escape-html.js.map +1 -0
- package/dist/escape-html/escape-html.test.js +6 -11
- package/dist/escape-html/escape-html.test.js.map +1 -0
- package/dist/escape-reg-exp/escape-reg-exp.js +4 -11
- package/dist/escape-reg-exp/escape-reg-exp.js.map +1 -0
- package/dist/escape-reg-exp/escape-reg-exp.test.js +7 -12
- package/dist/escape-reg-exp/escape-reg-exp.test.js.map +1 -0
- package/dist/filter/filter.js +15 -28
- package/dist/filter/filter.js.map +1 -0
- package/dist/filter/filter.test.js +14 -21
- package/dist/filter/filter.test.js.map +1 -0
- package/dist/find/find.js +18 -32
- package/dist/find/find.js.map +1 -0
- package/dist/find/find.test.js +23 -19
- package/dist/find/find.test.js.map +1 -0
- package/dist/find-index/find-index.js +13 -26
- package/dist/find-index/find-index.js.map +1 -0
- package/dist/find-index/find-index.test.js +12 -17
- package/dist/find-index/find-index.test.js.map +1 -0
- package/dist/first/first.js +4 -12
- package/dist/first/first.js.map +1 -0
- package/dist/first/first.test.js +11 -16
- package/dist/first/first.test.js.map +1 -0
- package/dist/flatten/flatten.js +23 -36
- package/dist/flatten/flatten.js.map +1 -0
- package/dist/flatten/flatten.test.js +11 -16
- package/dist/flatten/flatten.test.js.map +1 -0
- package/dist/for-each/for-each.js +10 -21
- package/dist/for-each/for-each.js.map +1 -0
- package/dist/for-each/for-each.test.js +8 -14
- package/dist/for-each/for-each.test.js.map +1 -0
- package/dist/group-by/group-by.js +8 -15
- package/dist/group-by/group-by.js.map +1 -0
- package/dist/group-by/group-by.test.js +7 -12
- package/dist/group-by/group-by.test.js.map +1 -0
- package/dist/gt/gt.js +3 -10
- package/dist/gt/gt.js.map +1 -0
- package/dist/gt/gt.test.js +9 -14
- package/dist/gt/gt.test.js.map +1 -0
- package/dist/has-key/has-key.js +6 -14
- package/dist/has-key/has-key.js.map +1 -0
- package/dist/has-key/has-key.test.js +8 -13
- package/dist/has-key/has-key.test.js.map +1 -0
- package/dist/hist/hist.js +14 -21
- package/dist/hist/hist.js.map +1 -0
- package/dist/hist/hist.test.js +8 -13
- package/dist/hist/hist.test.js.map +1 -0
- package/dist/i/i.js +4 -12
- package/dist/i/i.js.map +1 -0
- package/dist/i/i.test.js +10 -15
- package/dist/i/i.test.js.map +1 -0
- package/dist/inc/inc.js +4 -12
- package/dist/inc/inc.js.map +1 -0
- package/dist/inc/inc.test.js +6 -11
- package/dist/inc/inc.test.js.map +1 -0
- package/dist/index-by/index-by.js +8 -15
- package/dist/index-by/index-by.js.map +1 -0
- package/dist/index-by/index-by.test.js +7 -12
- package/dist/index-by/index-by.test.js.map +1 -0
- package/dist/index.js +98 -1023
- package/dist/index.js.map +1 -0
- package/dist/index.test.js +6 -9
- package/dist/index.test.js.map +1 -0
- package/dist/intersect/intersect.js +11 -22
- package/dist/intersect/intersect.js.map +1 -0
- package/dist/intersect/intersect.test.js +40 -106
- package/dist/intersect/intersect.test.js.map +1 -0
- package/dist/is/is.js +18 -36
- package/dist/is/is.js.map +1 -0
- package/dist/is/is.test.js +26 -31
- package/dist/is/is.test.js.map +1 -0
- package/dist/is-between/is-between.js +4 -12
- package/dist/is-between/is-between.js.map +1 -0
- package/dist/is-between/is-between.test.js +10 -15
- package/dist/is-between/is-between.test.js.map +1 -0
- package/dist/is-empty/is-empty.js +16 -28
- package/dist/is-empty/is-empty.js.map +1 -0
- package/dist/is-empty/is-empty.test.js +23 -28
- package/dist/is-empty/is-empty.test.js.map +1 -0
- package/dist/is-equal/is-equal.js +3 -10
- package/dist/is-equal/is-equal.js.map +1 -0
- package/dist/is-equal/is-equal.test.js +12 -17
- package/dist/is-equal/is-equal.test.js.map +1 -0
- package/dist/is-match/is-match.js +13 -26
- package/dist/is-match/is-match.js.map +1 -0
- package/dist/is-match/is-match.test.js +26 -24
- package/dist/is-match/is-match.test.js.map +1 -0
- package/dist/is-uri/is-uri.js +6 -17
- package/dist/is-uri/is-uri.js.map +1 -0
- package/dist/is-uri/is-uri.test.js +15 -85
- package/dist/is-uri/is-uri.test.js.map +1 -0
- package/dist/join/join.js +11 -22
- package/dist/join/join.js.map +1 -0
- package/dist/join/join.test.js +42 -108
- package/dist/join/join.test.js.map +1 -0
- package/dist/keys/keys.js +7 -17
- package/dist/keys/keys.js.map +1 -0
- package/dist/keys/keys.test.js +9 -14
- package/dist/keys/keys.test.js.map +1 -0
- package/dist/last/last.js +6 -12
- package/dist/last/last.js.map +1 -0
- package/dist/last/last.test.js +10 -15
- package/dist/last/last.test.js.map +1 -0
- package/dist/lt/lt.js +7 -13
- package/dist/lt/lt.js.map +1 -0
- package/dist/lt/lt.test.js +8 -13
- package/dist/lt/lt.test.js.map +1 -0
- package/dist/map/map.js +13 -24
- package/dist/map/map.js.map +1 -0
- package/dist/map/map.test.js +13 -17
- package/dist/map/map.test.js.map +1 -0
- package/dist/map-matrix/map-matrix.js +14 -25
- package/dist/map-matrix/map-matrix.js.map +1 -0
- package/dist/map-matrix/map-matrix.test.js +9 -13
- package/dist/map-matrix/map-matrix.test.js.map +1 -0
- package/dist/max/max.js +26 -40
- package/dist/max/max.js.map +1 -0
- package/dist/max/max.test.js +14 -20
- package/dist/max/max.test.js.map +1 -0
- package/dist/merge/merge.js +18 -34
- package/dist/merge/merge.js.map +1 -0
- package/dist/merge/merge.test.js +12 -17
- package/dist/merge/merge.test.js.map +1 -0
- package/dist/min/min.js +26 -40
- package/dist/min/min.js.map +1 -0
- package/dist/min/min.test.js +13 -19
- package/dist/min/min.test.js.map +1 -0
- package/dist/move/move.js +15 -25
- package/dist/move/move.js.map +1 -0
- package/dist/move/move.test.js +10 -15
- package/dist/move/move.test.js.map +1 -0
- package/dist/mutate/mutate.js +31 -51
- package/dist/mutate/mutate.js.map +1 -0
- package/dist/mutate/mutate.test.js +19 -23
- package/dist/mutate/mutate.test.js.map +1 -0
- package/dist/page/page.js +6 -14
- package/dist/page/page.js.map +1 -0
- package/dist/page/page.test.js +9 -14
- package/dist/page/page.test.js.map +1 -0
- package/dist/partition/partition.js +17 -31
- package/dist/partition/partition.js.map +1 -0
- package/dist/partition/partition.test.js +14 -20
- package/dist/partition/partition.test.js.map +1 -0
- package/dist/pick/pick.js +12 -20
- package/dist/pick/pick.js.map +1 -0
- package/dist/pick/pick.test.js +8 -13
- package/dist/pick/pick.test.js.map +1 -0
- package/dist/pipe/pipe.js +4 -12
- package/dist/pipe/pipe.js.map +1 -0
- package/dist/pipe/pipe.test.js +9 -13
- package/dist/pipe/pipe.test.js.map +1 -0
- package/dist/pipe-p/pipe-p.js +4 -10
- package/dist/pipe-p/pipe-p.js.map +1 -0
- package/dist/pipe-p/pipe-p.test.js +10 -15
- package/dist/pipe-p/pipe-p.test.js.map +1 -0
- package/dist/pluck/pluck.js +18 -26
- package/dist/pluck/pluck.js.map +1 -0
- package/dist/pluck/pluck.test.js +10 -15
- package/dist/pluck/pluck.test.js.map +1 -0
- package/dist/prepend/prepend.js +11 -21
- package/dist/prepend/prepend.js.map +1 -0
- package/dist/prepend/prepend.test.js +10 -15
- package/dist/prepend/prepend.test.js.map +1 -0
- package/dist/proto-chain/proto-chain.js +9 -17
- package/dist/proto-chain/proto-chain.js.map +1 -0
- package/dist/proto-chain/proto-chain.test.js +8 -13
- package/dist/proto-chain/proto-chain.test.js.map +1 -0
- package/dist/push/push.js +7 -15
- package/dist/push/push.js.map +1 -0
- package/dist/push/push.test.js +9 -14
- package/dist/push/push.test.js.map +1 -0
- package/dist/raise/raise.js +2 -8
- package/dist/raise/raise.js.map +1 -0
- package/dist/raise/raise.test.js +6 -11
- package/dist/raise/raise.test.js.map +1 -0
- package/dist/random/random.js +3 -11
- package/dist/random/random.js.map +1 -0
- package/dist/random/random.test.js +16 -17
- package/dist/random/random.test.js.map +1 -0
- package/dist/read/read.js +23 -40
- package/dist/read/read.js.map +1 -0
- package/dist/read/read.test.js +63 -179
- package/dist/read/read.test.js.map +1 -0
- package/dist/reduce/reduce.js +17 -28
- package/dist/reduce/reduce.js.map +1 -0
- package/dist/reduce/reduce.test.js +14 -19
- package/dist/reduce/reduce.test.js.map +1 -0
- package/dist/remove/remove.js +27 -42
- package/dist/remove/remove.js.map +1 -0
- package/dist/remove/remove.test.js +14 -21
- package/dist/remove/remove.test.js.map +1 -0
- package/dist/rename/rename.js +26 -40
- package/dist/rename/rename.js.map +1 -0
- package/dist/rename/rename.test.js +42 -103
- package/dist/rename/rename.test.js.map +1 -0
- package/dist/rename-file/rename-file.js +14 -28
- package/dist/rename-file/rename-file.js.map +1 -0
- package/dist/rename-file/rename-file.test.js +11 -16
- package/dist/rename-file/rename-file.test.js.map +1 -0
- package/dist/repeat/repeat.js +10 -21
- package/dist/repeat/repeat.js.map +1 -0
- package/dist/repeat/repeat.test.js +10 -14
- package/dist/repeat/repeat.test.js.map +1 -0
- package/dist/replace/replace.js +17 -27
- package/dist/replace/replace.js.map +1 -0
- package/dist/replace/replace.test.js +17 -22
- package/dist/replace/replace.test.js.map +1 -0
- package/dist/same/same.js +4 -12
- package/dist/same/same.js.map +1 -0
- package/dist/same/same.test.js +6 -11
- package/dist/same/same.test.js.map +1 -0
- package/dist/sequence/sequence.js +10 -21
- package/dist/sequence/sequence.js.map +1 -0
- package/dist/sequence/sequence.test.js +17 -22
- package/dist/sequence/sequence.test.js.map +1 -0
- package/dist/sort/sort-with.js +15 -27
- package/dist/sort/sort-with.js.map +1 -0
- package/dist/sort/sort.js +19 -31
- package/dist/sort/sort.js.map +1 -0
- package/dist/sort/sort.test.js +298 -368
- package/dist/sort/sort.test.js.map +1 -0
- package/dist/split/split.js +15 -25
- package/dist/split/split.js.map +1 -0
- package/dist/split/split.test.js +14 -59
- package/dist/split/split.test.js.map +1 -0
- package/dist/split-in-groups-of/split-in-groups-of.js +10 -20
- package/dist/split-in-groups-of/split-in-groups-of.js.map +1 -0
- package/dist/split-in-groups-of/split-in-groups-of.test.js +17 -77
- package/dist/split-in-groups-of/split-in-groups-of.test.js.map +1 -0
- package/dist/spy/spy.js +5 -13
- package/dist/spy/spy.js.map +1 -0
- package/dist/spy/spy.test.js +25 -70
- package/dist/spy/spy.test.js.map +1 -0
- package/dist/starts-with/starts-with.js +5 -12
- package/dist/starts-with/starts-with.js.map +1 -0
- package/dist/starts-with/starts-with.test.js +11 -16
- package/dist/starts-with/starts-with.test.js.map +1 -0
- package/dist/throttle/throttle.js +2 -8
- package/dist/throttle/throttle.js.map +1 -0
- package/dist/throttle/throttle.test.js +11 -16
- package/dist/throttle/throttle.test.js.map +1 -0
- package/dist/to-lower/to-lower.js +4 -12
- package/dist/to-lower/to-lower.js.map +1 -0
- package/dist/to-lower/to-lower.test.js +7 -12
- package/dist/to-lower/to-lower.test.js.map +1 -0
- package/dist/to-upper/to-upper.js +4 -12
- package/dist/to-upper/to-upper.js.map +1 -0
- package/dist/to-upper/to-upper.test.js +7 -12
- package/dist/to-upper/to-upper.test.js.map +1 -0
- package/dist/toggle/toggle.js +12 -22
- package/dist/toggle/toggle.js.map +1 -0
- package/dist/toggle/toggle.test.js +8 -13
- package/dist/toggle/toggle.test.js.map +1 -0
- package/dist/top/top.js +10 -16
- package/dist/top/top.js.map +1 -0
- package/dist/top/top.test.js +16 -21
- package/dist/top/top.test.js.map +1 -0
- package/dist/trim/trim.js +9 -15
- package/dist/trim/trim.js.map +1 -0
- package/dist/trim/trim.test.js +8 -13
- package/dist/trim/trim.test.js.map +1 -0
- package/dist/try-catch/try-catch.js +6 -12
- package/dist/try-catch/try-catch.js.map +1 -0
- package/dist/try-catch/try-catch.test.js +10 -16
- package/dist/try-catch/try-catch.test.js.map +1 -0
- package/dist/type/type.js +5 -11
- package/dist/type/type.js.map +1 -0
- package/dist/type/type.test.js +17 -22
- package/dist/type/type.test.js.map +1 -0
- package/dist/unite/unite.js +5 -12
- package/dist/unite/unite.js.map +1 -0
- package/dist/unite/unite.test.js +7 -37
- package/dist/unite/unite.test.js.map +1 -0
- package/dist/update/update.js +27 -45
- package/dist/update/update.js.map +1 -0
- package/dist/update/update.test.js +17 -21
- package/dist/update/update.test.js.map +1 -0
- package/dist/upsert/upsert.js +11 -20
- package/dist/upsert/upsert.js.map +1 -0
- package/dist/upsert/upsert.test.js +12 -17
- package/dist/upsert/upsert.test.js.map +1 -0
- package/dist/values/values.js +8 -19
- package/dist/values/values.js.map +1 -0
- package/dist/values/values.test.js +9 -14
- package/dist/values/values.test.js.map +1 -0
- package/dist/when/when.js +16 -27
- package/dist/when/when.js.map +1 -0
- package/dist/when/when.test.js +18 -24
- package/dist/when/when.test.js.map +1 -0
- package/dist/write/write.js +8 -16
- package/dist/write/write.js.map +1 -0
- package/dist/write/write.test.js +9 -14
- package/dist/write/write.test.js.map +1 -0
- package/dist/zip-to-object/zip-to-object.js +5 -11
- package/dist/zip-to-object/zip-to-object.js.map +1 -0
- package/dist/zip-to-object/zip-to-object.test.js +8 -13
- package/dist/zip-to-object/zip-to-object.test.js.map +1 -0
- package/package.json +33 -32
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://circleci.com/gh/asd-xiv/m)
|
|
4
4
|
[](https://badge.fury.io/js/%40asd14%2Fm)
|
|
5
|
-
[](https://david-dm.org/asd14-xyz/m)
|
|
6
5
|
[](https://coveralls.io/github/asd-xiv/m)
|
|
7
6
|
|
|
8
7
|
# m
|
|
@@ -13,12 +12,12 @@
|
|
|
13
12
|
|
|
14
13
|
<!-- vim-markdown-toc GFM -->
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
- [Install](#install)
|
|
16
|
+
- [Use](#use)
|
|
17
|
+
- ["With" pattern](#with-pattern)
|
|
18
|
+
- [|> pipe](#-pipe)
|
|
19
|
+
- [Develop](#develop)
|
|
20
|
+
- [Changelog](#changelog)
|
|
22
21
|
|
|
23
22
|
<!-- vim-markdown-toc -->
|
|
24
23
|
|
|
@@ -106,9 +105,9 @@ A series of transformations over an initial input can be written as `x -> f -> g
|
|
|
106
105
|
|
|
107
106
|
Given that:
|
|
108
107
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
108
|
+
- we read from left to right
|
|
109
|
+
- [left/back is in the past, right/front is the future](https://medium.com/@cwodtke/the-intuitive-and-the-unlearnable-cccffd9a762)
|
|
110
|
+
- a lot of piping going on in your terminal
|
|
112
111
|
|
|
113
112
|
it makes sense to choose the _syntax_ more aligned with our intuition and context. The transformations are applied in a certain order with time as a medium - `input -> t0 -> t1 -> tn -> output`.
|
|
114
113
|
|
package/dist/all/all.js
CHANGED
|
@@ -1,26 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import { pipe } from "../pipe/pipe.js";
|
|
3
|
+
import { curry } from "../curry/curry.js";
|
|
4
|
+
import { isMatch } from "../is-match/is-match.js";
|
|
2
5
|
|
|
3
|
-
var
|
|
6
|
+
var _all = function _all(_fn, _input) {
|
|
7
|
+
var input = Array.isArray(_input) ? _input : [_input];
|
|
8
|
+
var fn = Array.isArray(_fn) ? pipe.apply(void 0, _toConsumableArray(_fn)) : _fn;
|
|
4
9
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
});
|
|
8
|
-
exports.allWith = exports.all = void 0;
|
|
9
|
-
|
|
10
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
-
|
|
12
|
-
var _pipe = require("../pipe/pipe");
|
|
13
|
-
|
|
14
|
-
var _curry = require("../curry/curry");
|
|
15
|
-
|
|
16
|
-
var _isMatch = require("../is-match/is-match");
|
|
17
|
-
|
|
18
|
-
var _all = function _all(_fn, _source) {
|
|
19
|
-
var source = Array.isArray(_source) ? _source : [_source];
|
|
20
|
-
var fn = Array.isArray(_fn) ? _pipe.pipe.apply(void 0, (0, _toConsumableArray2.default)(_fn)) : _fn;
|
|
21
|
-
|
|
22
|
-
for (var i = 0, length = source.length; i < length; i++) {
|
|
23
|
-
if (fn(source[i]) !== true) {
|
|
10
|
+
for (var i = 0, length = input.length; i < length; i++) {
|
|
11
|
+
if (fn(input[i]) !== true) {
|
|
24
12
|
return false;
|
|
25
13
|
}
|
|
26
14
|
}
|
|
@@ -28,8 +16,8 @@ var _all = function _all(_fn, _source) {
|
|
|
28
16
|
return true;
|
|
29
17
|
};
|
|
30
18
|
|
|
31
|
-
var _allWith = function _allWith(subset,
|
|
32
|
-
return _all(
|
|
19
|
+
var _allWith = function _allWith(subset, input) {
|
|
20
|
+
return _all(isMatch(subset), input);
|
|
33
21
|
};
|
|
34
22
|
/**
|
|
35
23
|
* Test if all elements of array satisfy a function
|
|
@@ -56,7 +44,7 @@ var _allWith = function _allWith(subset, source) {
|
|
|
56
44
|
*/
|
|
57
45
|
|
|
58
46
|
|
|
59
|
-
var all =
|
|
47
|
+
export var all = curry(_all);
|
|
60
48
|
/**
|
|
61
49
|
* Test if all elements in array match object
|
|
62
50
|
*
|
|
@@ -82,6 +70,5 @@ var all = (0, _curry.curry)(_all);
|
|
|
82
70
|
* // => false
|
|
83
71
|
*/
|
|
84
72
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
exports.allWith = allWith;
|
|
73
|
+
export var allWith = curry(_allWith);
|
|
74
|
+
//# sourceMappingURL=all.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/all/all.js"],"names":["pipe","curry","isMatch","_all","_fn","_input","input","Array","isArray","fn","i","length","_allWith","subset","all","allWith"],"mappings":";AAAA,SAASA,IAAT,QAAqB,iBAArB;AACA,SAASC,KAAT,QAAsB,mBAAtB;AACA,SAASC,OAAT,QAAwB,yBAAxB;;AAEA,IAAMC,IAAI,GAAG,SAAPA,IAAO,CAACC,GAAD,EAAMC,MAAN,EAAiB;AAC5B,MAAMC,KAAK,GAAGC,KAAK,CAACC,OAAN,CAAcH,MAAd,IAAwBA,MAAxB,GAAiC,CAACA,MAAD,CAA/C;AACA,MAAMI,EAAE,GAAGF,KAAK,CAACC,OAAN,CAAcJ,GAAd,IAAqBJ,IAAI,MAAJ,4BAAQI,GAAR,EAArB,GAAoCA,GAA/C;;AAEA,OAAK,IAAIM,CAAC,GAAG,CAAR,EAAWC,MAAM,GAAGL,KAAK,CAACK,MAA/B,EAAuCD,CAAC,GAAGC,MAA3C,EAAmDD,CAAC,EAApD,EAAwD;AACtD,QAAID,EAAE,CAACH,KAAK,CAACI,CAAD,CAAN,CAAF,KAAiB,IAArB,EAA2B;AACzB,aAAO,KAAP;AACD;AACF;;AAED,SAAO,IAAP;AACD,CAXD;;AAaA,IAAME,QAAQ,GAAG,SAAXA,QAAW,CAACC,MAAD,EAASP,KAAT;AAAA,SAAmBH,IAAI,CAACD,OAAO,CAACW,MAAD,CAAR,EAAkBP,KAAlB,CAAvB;AAAA,CAAjB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,IAAMQ,GAAG,GAAGb,KAAK,CAACE,IAAD,CAAjB;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,IAAMY,OAAO,GAAGd,KAAK,CAACW,QAAD,CAArB","sourcesContent":["import { pipe } from \"../pipe/pipe.js\"\nimport { curry } from \"../curry/curry.js\"\nimport { isMatch } from \"../is-match/is-match.js\"\n\nconst _all = (_fn, _input) => {\n const input = Array.isArray(_input) ? _input : [_input]\n const fn = Array.isArray(_fn) ? pipe(..._fn) : _fn\n\n for (let i = 0, length = input.length; i < length; i++) {\n if (fn(input[i]) !== true) {\n return false\n }\n }\n\n return true\n}\n\nconst _allWith = (subset, input) => _all(isMatch(subset), input)\n\n/**\n * Test if all elements of array satisfy a function\n *\n * @param {Function|Function[]} fn Test function called on each elements\n * @param {Array} source Source array to iterate over\n *\n * @returns {boolean} True if all elements pass, otherwise false\n *\n * @name all\n * @tag Array\n * @signature (fn: Function|Function[], source: Array): Boolean\n *\n * @see {@link allWith}\n * @see {@link any}\n * @see {@link anyWith}\n *\n * @example\n * all(isNumber)([1, 2, 3])\n * // => true\n *\n * all(is, [1, \"asd\", null])\n * // => false\n */\nexport const all = curry(_all)\n\n/**\n * Test if all elements in array match object\n *\n * @param {object} subset Match object\n * @param {Array} source Source array to iterate over\n *\n * @returns {boolean} True if all elements match, otherwise false\n *\n * @name allWith\n * @tag Array\n * @signature (subset: Object, source: Array): Boolean\n *\n * @see {@link all}\n * @see {@link any}\n * @see {@link anyWith}\n * @see {@link isMatch}\n *\n * @example\n * allWith(isNumber)([1, 2, 3])\n * // => true\n *\n * allWith(is, [1, \"asd\", null])\n * // => false\n */\nexport const allWith = curry(_allWith)\n"],"file":"all.js"}
|
package/dist/all/all.test.js
CHANGED
|
@@ -1,42 +1,35 @@
|
|
|
1
|
-
|
|
1
|
+
import test from "tape";
|
|
2
|
+
import { all, allWith } from "./all.js";
|
|
3
|
+
import { is } from "../is/is.js";
|
|
4
|
+
import { read } from "../read/read.js";
|
|
2
5
|
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
var _tape = _interopRequireDefault(require("tape"));
|
|
6
|
-
|
|
7
|
-
var _all = require("./all");
|
|
8
|
-
|
|
9
|
-
var _is = require("../is/is");
|
|
10
|
-
|
|
11
|
-
var _read = require("../read/read");
|
|
12
|
-
|
|
13
|
-
var isEven = function isEven(source) {
|
|
14
|
-
return source % 2 === 0;
|
|
6
|
+
var isEven = function isEven(input) {
|
|
7
|
+
return input % 2 === 0;
|
|
15
8
|
};
|
|
16
9
|
|
|
17
|
-
(
|
|
18
|
-
t.equal(
|
|
19
|
-
t.equal(
|
|
20
|
-
return
|
|
10
|
+
test("all(With)", function (t) {
|
|
11
|
+
t.equal(all(isEven, [2, 6, 4]), true, "Check all number are even");
|
|
12
|
+
t.equal(all(function (item) {
|
|
13
|
+
return is(item.id);
|
|
21
14
|
}, [{}, {
|
|
22
15
|
id: 2
|
|
23
16
|
}, {}]), false, 'Check all elements have "id" property');
|
|
24
|
-
t.equal(
|
|
17
|
+
t.equal(all([read("id"), is], [{}, {
|
|
25
18
|
id: 2
|
|
26
19
|
}, {}]), false, 'Check all elements have "id" property using pipe functions');
|
|
27
20
|
t.end();
|
|
28
21
|
});
|
|
29
|
-
(
|
|
30
|
-
t.equal(
|
|
22
|
+
test("allWith", function (t) {
|
|
23
|
+
t.equal(allWith({
|
|
31
24
|
id: function id(value) {
|
|
32
|
-
return
|
|
25
|
+
return is(value);
|
|
33
26
|
}
|
|
34
27
|
}, [{}, {
|
|
35
28
|
id: 2
|
|
36
29
|
}, {}]), false, 'Not all elements have "id" property via match subset');
|
|
37
|
-
t.equal(
|
|
30
|
+
t.equal(allWith({
|
|
38
31
|
id: function id(value) {
|
|
39
|
-
return
|
|
32
|
+
return is(value);
|
|
40
33
|
}
|
|
41
34
|
}, [{
|
|
42
35
|
id: 1
|
|
@@ -47,4 +40,5 @@ var isEven = function isEven(source) {
|
|
|
47
40
|
name: "test"
|
|
48
41
|
}]), true, 'All elements have "id" property via match subset');
|
|
49
42
|
t.end();
|
|
50
|
-
});
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=all.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/all/all.test.js"],"names":["test","all","allWith","is","read","isEven","input","t","equal","item","id","end","value","name"],"mappings":"AAAA,OAAOA,IAAP,MAAiB,MAAjB;AACA,SAASC,GAAT,EAAcC,OAAd,QAA6B,UAA7B;AAEA,SAASC,EAAT,QAAmB,aAAnB;AACA,SAASC,IAAT,QAAqB,iBAArB;;AAEA,IAAMC,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;AAAA,SAAIA,KAAK,GAAG,CAAR,KAAc,CAAlB;AAAA,CAApB;;AAEAN,IAAI,CAAC,WAAD,EAAc,UAAAO,CAAC,EAAI;AACrBA,EAAAA,CAAC,CAACC,KAAF,CAAQP,GAAG,CAACI,MAAD,EAAS,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAAT,CAAX,EAAgC,IAAhC,EAAsC,2BAAtC;AAEAE,EAAAA,CAAC,CAACC,KAAF,CACEP,GAAG,CAAC,UAAAQ,IAAI;AAAA,WAAIN,EAAE,CAACM,IAAI,CAACC,EAAN,CAAN;AAAA,GAAL,EAAsB,CAAC,EAAD,EAAK;AAAEA,IAAAA,EAAE,EAAE;AAAN,GAAL,EAAgB,EAAhB,CAAtB,CADL,EAEE,KAFF,EAGE,uCAHF;AAMAH,EAAAA,CAAC,CAACC,KAAF,CACEP,GAAG,CAAC,CAACG,IAAI,CAAC,IAAD,CAAL,EAAaD,EAAb,CAAD,EAAmB,CAAC,EAAD,EAAK;AAAEO,IAAAA,EAAE,EAAE;AAAN,GAAL,EAAgB,EAAhB,CAAnB,CADL,EAEE,KAFF,EAGE,4DAHF;AAMAH,EAAAA,CAAC,CAACI,GAAF;AACD,CAhBG,CAAJ;AAkBAX,IAAI,CAAC,SAAD,EAAY,UAAAO,CAAC,EAAI;AACnBA,EAAAA,CAAC,CAACC,KAAF,CACEN,OAAO,CACL;AACEQ,IAAAA,EAAE,EAAE,YAAAE,KAAK;AAAA,aAAIT,EAAE,CAACS,KAAD,CAAN;AAAA;AADX,GADK,EAIL,CAAC,EAAD,EAAK;AAAEF,IAAAA,EAAE,EAAE;AAAN,GAAL,EAAgB,EAAhB,CAJK,CADT,EAOE,KAPF,EAQE,sDARF;AAWAH,EAAAA,CAAC,CAACC,KAAF,CACEN,OAAO,CACL;AACEQ,IAAAA,EAAE,EAAE,YAAAE,KAAK;AAAA,aAAIT,EAAE,CAACS,KAAD,CAAN;AAAA;AADX,GADK,EAIL,CAAC;AAAEF,IAAAA,EAAE,EAAE;AAAN,GAAD,EAAY;AAAEA,IAAAA,EAAE,EAAE;AAAN,GAAZ,EAAuB;AAAEA,IAAAA,EAAE,EAAE,CAAN;AAASG,IAAAA,IAAI,EAAE;AAAf,GAAvB,CAJK,CADT,EAOE,IAPF,EAQE,kDARF;AAWAN,EAAAA,CAAC,CAACI,GAAF;AACD,CAxBG,CAAJ","sourcesContent":["import test from \"tape\"\nimport { all, allWith } from \"./all.js\"\n\nimport { is } from \"../is/is.js\"\nimport { read } from \"../read/read.js\"\n\nconst isEven = input => input % 2 === 0\n\ntest(\"all(With)\", t => {\n t.equal(all(isEven, [2, 6, 4]), true, \"Check all number are even\")\n\n t.equal(\n all(item => is(item.id), [{}, { id: 2 }, {}]),\n false,\n 'Check all elements have \"id\" property'\n )\n\n t.equal(\n all([read(\"id\"), is], [{}, { id: 2 }, {}]),\n false,\n 'Check all elements have \"id\" property using pipe functions'\n )\n\n t.end()\n})\n\ntest(\"allWith\", t => {\n t.equal(\n allWith(\n {\n id: value => is(value),\n },\n [{}, { id: 2 }, {}]\n ),\n false,\n 'Not all elements have \"id\" property via match subset'\n )\n\n t.equal(\n allWith(\n {\n id: value => is(value),\n },\n [{ id: 1 }, { id: 2 }, { id: 3, name: \"test\" }]\n ),\n true,\n 'All elements have \"id\" property via match subset'\n )\n\n t.end()\n})\n"],"file":"all.test.js"}
|
package/dist/any/any.js
CHANGED
|
@@ -1,27 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import { pipe } from "../pipe/pipe.js";
|
|
3
|
+
import { curry } from "../curry/curry.js";
|
|
4
|
+
import { isMatch } from "../is-match/is-match.js";
|
|
2
5
|
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.anyWith = exports.any = void 0;
|
|
9
|
-
|
|
10
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
-
|
|
12
|
-
var _pipe = require("../pipe/pipe");
|
|
13
|
-
|
|
14
|
-
var _curry = require("../curry/curry");
|
|
15
|
-
|
|
16
|
-
var _isMatch = require("../is-match/is-match");
|
|
17
|
-
|
|
18
|
-
var _any = function _any(_fn, _source) {
|
|
19
|
-
var source = Array.isArray(_source) ? _source : [_source];
|
|
20
|
-
var fn = Array.isArray(_fn) ? _pipe.pipe.apply(void 0, (0, _toConsumableArray2.default)(_fn)) : _fn;
|
|
6
|
+
var _any = function _any(_fn, _input) {
|
|
7
|
+
var input = Array.isArray(_input) ? _input : [_input];
|
|
8
|
+
var fn = Array.isArray(_fn) ? pipe.apply(void 0, _toConsumableArray(_fn)) : _fn;
|
|
21
9
|
var shouldCompare = typeof fn !== "function";
|
|
22
10
|
|
|
23
|
-
for (var i = 0, length =
|
|
24
|
-
if (shouldCompare ? fn ===
|
|
11
|
+
for (var i = 0, length = input.length; i < length; i++) {
|
|
12
|
+
if (shouldCompare ? fn === input[i] : fn(input[i]) === true) {
|
|
25
13
|
return true;
|
|
26
14
|
}
|
|
27
15
|
}
|
|
@@ -29,14 +17,14 @@ var _any = function _any(_fn, _source) {
|
|
|
29
17
|
return false;
|
|
30
18
|
};
|
|
31
19
|
|
|
32
|
-
var _anyWith = function _anyWith(subset,
|
|
33
|
-
return _any(
|
|
20
|
+
var _anyWith = function _anyWith(subset, input) {
|
|
21
|
+
return _any(isMatch(subset), input);
|
|
34
22
|
};
|
|
35
23
|
/**
|
|
36
24
|
* Test if at least one element in array matches predicate
|
|
37
25
|
*
|
|
38
|
-
* @param {
|
|
39
|
-
* @param {Array}
|
|
26
|
+
* @param {Function|Function[]} fn Predicate function
|
|
27
|
+
* @param {Array} source Source array to iterate over
|
|
40
28
|
*
|
|
41
29
|
* @returns {boolean} True if at least one element passes, otherwise false
|
|
42
30
|
*
|
|
@@ -58,7 +46,7 @@ var _anyWith = function _anyWith(subset, source) {
|
|
|
58
46
|
*/
|
|
59
47
|
|
|
60
48
|
|
|
61
|
-
var any =
|
|
49
|
+
export var any = curry(_any);
|
|
62
50
|
/**
|
|
63
51
|
* Test if at least one element in array matches object
|
|
64
52
|
*
|
|
@@ -85,6 +73,5 @@ var any = (0, _curry.curry)(_any);
|
|
|
85
73
|
* // => false
|
|
86
74
|
*/
|
|
87
75
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
exports.anyWith = anyWith;
|
|
76
|
+
export var anyWith = curry(_anyWith);
|
|
77
|
+
//# sourceMappingURL=any.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/any/any.js"],"names":["pipe","curry","isMatch","_any","_fn","_input","input","Array","isArray","fn","shouldCompare","i","length","_anyWith","subset","any","anyWith"],"mappings":";AAAA,SAASA,IAAT,QAAqB,iBAArB;AACA,SAASC,KAAT,QAAsB,mBAAtB;AACA,SAASC,OAAT,QAAwB,yBAAxB;;AAEA,IAAMC,IAAI,GAAG,SAAPA,IAAO,CAACC,GAAD,EAAMC,MAAN,EAAiB;AAC5B,MAAMC,KAAK,GAAGC,KAAK,CAACC,OAAN,CAAcH,MAAd,IAAwBA,MAAxB,GAAiC,CAACA,MAAD,CAA/C;AACA,MAAMI,EAAE,GAAGF,KAAK,CAACC,OAAN,CAAcJ,GAAd,IAAqBJ,IAAI,MAAJ,4BAAQI,GAAR,EAArB,GAAoCA,GAA/C;AACA,MAAMM,aAAa,GAAG,OAAOD,EAAP,KAAc,UAApC;;AAEA,OAAK,IAAIE,CAAC,GAAG,CAAR,EAAWC,MAAM,GAAGN,KAAK,CAACM,MAA/B,EAAuCD,CAAC,GAAGC,MAA3C,EAAmDD,CAAC,EAApD,EAAwD;AACtD,QAAID,aAAa,GAAGD,EAAE,KAAKH,KAAK,CAACK,CAAD,CAAf,GAAqBF,EAAE,CAACH,KAAK,CAACK,CAAD,CAAN,CAAF,KAAiB,IAAvD,EAA6D;AAC3D,aAAO,IAAP;AACD;AACF;;AAED,SAAO,KAAP;AACD,CAZD;;AAcA,IAAME,QAAQ,GAAG,SAAXA,QAAW,CAACC,MAAD,EAASR,KAAT;AAAA,SAAmBH,IAAI,CAACD,OAAO,CAACY,MAAD,CAAR,EAAkBR,KAAlB,CAAvB;AAAA,CAAjB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,IAAMS,GAAG,GAAGd,KAAK,CAACE,IAAD,CAAjB;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,IAAMa,OAAO,GAAGf,KAAK,CAACY,QAAD,CAArB","sourcesContent":["import { pipe } from \"../pipe/pipe.js\"\nimport { curry } from \"../curry/curry.js\"\nimport { isMatch } from \"../is-match/is-match.js\"\n\nconst _any = (_fn, _input) => {\n const input = Array.isArray(_input) ? _input : [_input]\n const fn = Array.isArray(_fn) ? pipe(..._fn) : _fn\n const shouldCompare = typeof fn !== \"function\"\n\n for (let i = 0, length = input.length; i < length; i++) {\n if (shouldCompare ? fn === input[i] : fn(input[i]) === true) {\n return true\n }\n }\n\n return false\n}\n\nconst _anyWith = (subset, input) => _any(isMatch(subset), input)\n\n/**\n * Test if at least one element in array matches predicate\n *\n * @param {Function|Function[]} fn Predicate function\n * @param {Array} source Source array to iterate over\n *\n * @returns {boolean} True if at least one element passes, otherwise false\n *\n * @name any\n * @alias has\n * @tag Array\n * @signature (fn: Function|Function[], source: Array): Boolean\n *\n * @see {@link anyWith}\n * @see {@link all}\n * @see {@link allWith}\n *\n * @example\n * any(isNumber)([1, \"string\", NaN])\n * // => true\n *\n * any([get(\"id\"), is], [{title: \"\"}, {}])\n * // => false\n */\nexport const any = curry(_any)\n\n/**\n * Test if at least one element in array matches object\n *\n * @param {object} subset Match object\n * @param {Array} source Source array to iterate over\n *\n * @returns {boolean} True if at least one element pass, otherwise false\n *\n * @name anyWith\n * @alias hasWith\n * @tag Array\n * @signature (subset: Object, source: Array): Boolean\n *\n * @see {@link any}\n * @see {@link all}\n * @see {@link allWith}\n * @see {@link isMatch}\n *\n * @example\n * anyWith({ comments: is })([{id: 1}, {id: 2, comments: []}])\n * // => true\n *\n * anyWith({ tags: is })([{id: 1}, {id: 2, comments: []}])\n * // => false\n */\nexport const anyWith = curry(_anyWith)\n"],"file":"any.js"}
|
package/dist/any/any.test.js
CHANGED
|
@@ -1,32 +1,26 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _tape = _interopRequireDefault(require("tape"));
|
|
6
|
-
|
|
7
|
-
var _any = require("./any");
|
|
8
|
-
|
|
9
|
-
var _read = require("../read/read");
|
|
10
|
-
|
|
11
1
|
/* eslint-disable unicorn/no-null */
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
import test from "tape";
|
|
3
|
+
import { any, anyWith } from "./any.js";
|
|
4
|
+
import { read } from "../read/read.js";
|
|
5
|
+
|
|
6
|
+
var isNumber = function isNumber(input) {
|
|
7
|
+
return Number.isFinite(input);
|
|
14
8
|
};
|
|
15
9
|
|
|
16
|
-
(
|
|
17
|
-
t.equal(
|
|
18
|
-
t.equal(
|
|
19
|
-
t.equal(
|
|
10
|
+
test("any", function (t) {
|
|
11
|
+
t.equal(any(1, [1, "string", Number.NaN]), true, "Check any element is equal to primitive");
|
|
12
|
+
t.equal(any(isNumber, [1, "string", Number.NaN]), true, "Check any element is number");
|
|
13
|
+
t.equal(any([read("boolFlag"), function (item) {
|
|
20
14
|
return item === true;
|
|
21
15
|
}], [null, "2", {
|
|
22
16
|
boolFlag: true
|
|
23
17
|
}]), true, "Check any element has a field using piped functions");
|
|
24
|
-
t.equal(
|
|
25
|
-
t.equal(
|
|
18
|
+
t.equal(any(isNumber, [null, "2", {}]), false, "Check any element is number");
|
|
19
|
+
t.equal(any(isNumber, 2), true, "Check non array input");
|
|
26
20
|
t.end();
|
|
27
21
|
});
|
|
28
|
-
(
|
|
29
|
-
t.equal(
|
|
22
|
+
test("anyWith", function (t) {
|
|
23
|
+
t.equal(anyWith({
|
|
30
24
|
id: isNumber,
|
|
31
25
|
name: "lorem"
|
|
32
26
|
}, [{
|
|
@@ -41,4 +35,5 @@ var isNumber = function isNumber(source) {
|
|
|
41
35
|
foo: "bar"
|
|
42
36
|
}]), true, "Array should contain object that satisfies conditions");
|
|
43
37
|
t.end();
|
|
44
|
-
});
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=any.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/any/any.test.js"],"names":["test","any","anyWith","read","isNumber","input","Number","isFinite","t","equal","NaN","item","boolFlag","end","id","name","foo"],"mappings":"AAAA;AAEA,OAAOA,IAAP,MAAiB,MAAjB;AAEA,SAASC,GAAT,EAAcC,OAAd,QAA6B,UAA7B;AACA,SAASC,IAAT,QAAqB,iBAArB;;AAEA,IAAMC,QAAQ,GAAG,SAAXA,QAAW,CAAAC,KAAK;AAAA,SAAIC,MAAM,CAACC,QAAP,CAAgBF,KAAhB,CAAJ;AAAA,CAAtB;;AAEAL,IAAI,CAAC,KAAD,EAAQ,UAAAQ,CAAC,EAAI;AACfA,EAAAA,CAAC,CAACC,KAAF,CACER,GAAG,CAAC,CAAD,EAAI,CAAC,CAAD,EAAI,QAAJ,EAAcK,MAAM,CAACI,GAArB,CAAJ,CADL,EAEE,IAFF,EAGE,yCAHF;AAMAF,EAAAA,CAAC,CAACC,KAAF,CACER,GAAG,CAACG,QAAD,EAAW,CAAC,CAAD,EAAI,QAAJ,EAAcE,MAAM,CAACI,GAArB,CAAX,CADL,EAEE,IAFF,EAGE,6BAHF;AAMAF,EAAAA,CAAC,CAACC,KAAF,CACER,GAAG,CACD,CAACE,IAAI,CAAC,UAAD,CAAL,EAAmB,UAAAQ,IAAI;AAAA,WAAIA,IAAI,KAAK,IAAb;AAAA,GAAvB,CADC,EAED,CAAC,IAAD,EAAO,GAAP,EAAY;AAAEC,IAAAA,QAAQ,EAAE;AAAZ,GAAZ,CAFC,CADL,EAKE,IALF,EAME,qDANF;AASAJ,EAAAA,CAAC,CAACC,KAAF,CAAQR,GAAG,CAACG,QAAD,EAAW,CAAC,IAAD,EAAO,GAAP,EAAY,EAAZ,CAAX,CAAX,EAAwC,KAAxC,EAA+C,6BAA/C;AAEAI,EAAAA,CAAC,CAACC,KAAF,CAAQR,GAAG,CAACG,QAAD,EAAW,CAAX,CAAX,EAA0B,IAA1B,EAAgC,uBAAhC;AAEAI,EAAAA,CAAC,CAACK,GAAF;AACD,CA3BG,CAAJ;AA6BAb,IAAI,CAAC,SAAD,EAAY,UAAAQ,CAAC,EAAI;AACnBA,EAAAA,CAAC,CAACC,KAAF,CACEP,OAAO,CACL;AACEY,IAAAA,EAAE,EAAEV,QADN;AAEEW,IAAAA,IAAI,EAAE;AAFR,GADK,EAKL,CACE;AAAED,IAAAA,EAAE,EAAE,MAAN;AAAcC,IAAAA,IAAI,EAAE;AAApB,GADF,EAEE;AAAED,IAAAA,EAAE,EAAE,CAAN;AAASC,IAAAA,IAAI,EAAE;AAAf,GAFF,EAGE;AAAED,IAAAA,EAAE,EAAE,CAAN;AAASC,IAAAA,IAAI,EAAE,OAAf;AAAwBC,IAAAA,GAAG,EAAE;AAA7B,GAHF,CALK,CADT,EAYE,IAZF,EAaE,uDAbF;AAgBAR,EAAAA,CAAC,CAACK,GAAF;AACD,CAlBG,CAAJ","sourcesContent":["/* eslint-disable unicorn/no-null */\n\nimport test from \"tape\"\n\nimport { any, anyWith } from \"./any.js\"\nimport { read } from \"../read/read.js\"\n\nconst isNumber = input => Number.isFinite(input)\n\ntest(\"any\", t => {\n t.equal(\n any(1, [1, \"string\", Number.NaN]),\n true,\n \"Check any element is equal to primitive\"\n )\n\n t.equal(\n any(isNumber, [1, \"string\", Number.NaN]),\n true,\n \"Check any element is number\"\n )\n\n t.equal(\n any(\n [read(\"boolFlag\"), item => item === true],\n [null, \"2\", { boolFlag: true }]\n ),\n true,\n \"Check any element has a field using piped functions\"\n )\n\n t.equal(any(isNumber, [null, \"2\", {}]), false, \"Check any element is number\")\n\n t.equal(any(isNumber, 2), true, \"Check non array input\")\n\n t.end()\n})\n\ntest(\"anyWith\", t => {\n t.equal(\n anyWith(\n {\n id: isNumber,\n name: \"lorem\",\n },\n [\n { id: \"uuid\", name: \"lorem\" },\n { id: 2, name: \"foo\" },\n { id: 3, name: \"lorem\", foo: \"bar\" },\n ]\n ),\n true,\n \"Array should contain object that satisfies conditions\"\n )\n\n t.end()\n})\n"],"file":"any.test.js"}
|
package/dist/append/append.js
CHANGED
|
@@ -1,22 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import { curry } from "../curry/curry.js";
|
|
2
3
|
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.append = void 0;
|
|
9
|
-
|
|
10
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
-
|
|
12
|
-
var _curry = require("../curry/curry");
|
|
13
|
-
|
|
14
|
-
var _append = function _append(subset, source) {
|
|
15
|
-
if (Array.isArray(source)) {
|
|
16
|
-
return [].concat((0, _toConsumableArray2.default)(source), (0, _toConsumableArray2.default)(Array.isArray(subset) ? subset : [subset]));
|
|
4
|
+
var _append = function _append(subset, input) {
|
|
5
|
+
if (Array.isArray(input)) {
|
|
6
|
+
return [].concat(_toConsumableArray(input), _toConsumableArray(Array.isArray(subset) ? subset : [subset]));
|
|
17
7
|
}
|
|
18
8
|
|
|
19
|
-
return
|
|
9
|
+
return input + subset;
|
|
20
10
|
};
|
|
21
11
|
/**
|
|
22
12
|
* Add array or element at the end of array
|
|
@@ -39,5 +29,5 @@ var _append = function _append(subset, source) {
|
|
|
39
29
|
*/
|
|
40
30
|
|
|
41
31
|
|
|
42
|
-
var append =
|
|
43
|
-
|
|
32
|
+
export var append = curry(_append);
|
|
33
|
+
//# sourceMappingURL=append.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/append/append.js"],"names":["curry","_append","subset","input","Array","isArray","append"],"mappings":";AAAA,SAASA,KAAT,QAAsB,mBAAtB;;AAEA,IAAMC,OAAO,GAAG,SAAVA,OAAU,CAACC,MAAD,EAASC,KAAT,EAAmB;AACjC,MAAIC,KAAK,CAACC,OAAN,CAAcF,KAAd,CAAJ,EAA0B;AACxB,wCAAWA,KAAX,sBAAsBC,KAAK,CAACC,OAAN,CAAcH,MAAd,IAAwBA,MAAxB,GAAiC,CAACA,MAAD,CAAvD;AACD;;AAED,SAAOC,KAAK,GAAGD,MAAf;AACD,CAND;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,IAAMI,MAAM,GAAGN,KAAK,CAACC,OAAD,CAApB","sourcesContent":["import { curry } from \"../curry/curry.js\"\n\nconst _append = (subset, input) => {\n if (Array.isArray(input)) {\n return [...input, ...(Array.isArray(subset) ? subset : [subset])]\n }\n\n return input + subset\n}\n\n/**\n * Add array or element at the end of array\n *\n * @param {any|Array} subset Content to add\n * @param {Array} source Source array to append to\n *\n * @returns {Array}\n *\n * @name append\n * @tag Array\n * @signature (subset: String, source: String) => String\n * @signature (subset: mixed|Array, source: Array) => Array\n *\n * @see {@link prepend}\n *\n * @example\n * append([1])([4, 5])\n * // => [1, 4, 5]\n */\nexport const append = curry(_append)\n"],"file":"append.js"}
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
(0, _tape.default)("append", function (t) {
|
|
10
|
-
t.deepEquals((0, _append.append)([1, 2])([2, 3]), [2, 3, 1, 2], "Append 2 arrays - curried");
|
|
11
|
-
t.deepEquals((0, _append.append)([1, 2], [2, 3]), [2, 3, 1, 2], "Append 2 arrays - uncurried");
|
|
12
|
-
t.deepEquals((0, _append.append)("test", [2, 3]), [2, 3, "test"], "Append non-array to arrays");
|
|
13
|
-
t.deepEquals((0, _append.append)(" ipsum", "lorem"), "lorem ipsum", "Append 2 strings");
|
|
14
|
-
t.deepEquals((0, _append.append)([], []), [], "Append 2 empty arrays");
|
|
1
|
+
import test from "tape";
|
|
2
|
+
import { append } from "./append.js";
|
|
3
|
+
test("append", function (t) {
|
|
4
|
+
t.deepEquals(append([1, 2])([2, 3]), [2, 3, 1, 2], "Append 2 arrays - curried");
|
|
5
|
+
t.deepEquals(append([1, 2], [2, 3]), [2, 3, 1, 2], "Append 2 arrays - uncurried");
|
|
6
|
+
t.deepEquals(append("test", [2, 3]), [2, 3, "test"], "Append non-array to arrays");
|
|
7
|
+
t.deepEquals(append(" ipsum", "lorem"), "lorem ipsum", "Append 2 strings");
|
|
8
|
+
t.deepEquals(append([], []), [], "Append 2 empty arrays");
|
|
15
9
|
t.end();
|
|
16
|
-
});
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=append.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/append/append.test.js"],"names":["test","append","t","deepEquals","end"],"mappings":"AAAA,OAAOA,IAAP,MAAiB,MAAjB;AAEA,SAASC,MAAT,QAAuB,aAAvB;AAEAD,IAAI,CAAC,QAAD,EAAW,UAAAE,CAAC,EAAI;AAClBA,EAAAA,CAAC,CAACC,UAAF,CACEF,MAAM,CAAC,CAAC,CAAD,EAAI,CAAJ,CAAD,CAAN,CAAe,CAAC,CAAD,EAAI,CAAJ,CAAf,CADF,EAEE,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CAFF,EAGE,2BAHF;AAMAC,EAAAA,CAAC,CAACC,UAAF,CACEF,MAAM,CAAC,CAAC,CAAD,EAAI,CAAJ,CAAD,EAAS,CAAC,CAAD,EAAI,CAAJ,CAAT,CADR,EAEE,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CAFF,EAGE,6BAHF;AAMAC,EAAAA,CAAC,CAACC,UAAF,CACEF,MAAM,CAAC,MAAD,EAAS,CAAC,CAAD,EAAI,CAAJ,CAAT,CADR,EAEE,CAAC,CAAD,EAAI,CAAJ,EAAO,MAAP,CAFF,EAGE,4BAHF;AAMAC,EAAAA,CAAC,CAACC,UAAF,CAAaF,MAAM,CAAC,QAAD,EAAW,OAAX,CAAnB,EAAwC,aAAxC,EAAuD,kBAAvD;AAEAC,EAAAA,CAAC,CAACC,UAAF,CAAaF,MAAM,CAAC,EAAD,EAAK,EAAL,CAAnB,EAA6B,EAA7B,EAAiC,uBAAjC;AAEAC,EAAAA,CAAC,CAACE,GAAF;AACD,CAxBG,CAAJ","sourcesContent":["import test from \"tape\"\n\nimport { append } from \"./append.js\"\n\ntest(\"append\", t => {\n t.deepEquals(\n append([1, 2])([2, 3]),\n [2, 3, 1, 2],\n \"Append 2 arrays - curried\"\n )\n\n t.deepEquals(\n append([1, 2], [2, 3]),\n [2, 3, 1, 2],\n \"Append 2 arrays - uncurried\"\n )\n\n t.deepEquals(\n append(\"test\", [2, 3]),\n [2, 3, \"test\"],\n \"Append non-array to arrays\"\n )\n\n t.deepEquals(append(\" ipsum\", \"lorem\"), \"lorem ipsum\", \"Append 2 strings\")\n\n t.deepEquals(append([], []), [], \"Append 2 empty arrays\")\n\n t.end()\n})\n"],"file":"append.test.js"}
|
package/dist/bottom/bottom.js
CHANGED
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { is } from "../is/is.js";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.bottom = void 0;
|
|
7
|
-
|
|
8
|
-
var _is = require("../is/is");
|
|
9
|
-
|
|
10
|
-
var _bottom = function _bottom(limit, source) {
|
|
11
|
-
if (!Array.isArray(source) && typeof source !== "string" || source.length <= 1) {
|
|
3
|
+
var _bottom = function _bottom(limit, input) {
|
|
4
|
+
if (!Array.isArray(input) && typeof input !== "string" || input.length <= 1) {
|
|
12
5
|
return [];
|
|
13
6
|
}
|
|
14
7
|
|
|
15
|
-
return
|
|
8
|
+
return input.slice(is(limit) ? limit >= input.length ? 0 : input.length - limit : 1);
|
|
16
9
|
};
|
|
17
10
|
/**
|
|
18
11
|
* Get all but first element from array
|
|
@@ -42,15 +35,15 @@ var _bottom = function _bottom(limit, source) {
|
|
|
42
35
|
*/
|
|
43
36
|
|
|
44
37
|
|
|
45
|
-
var bottom = function bottom() {
|
|
38
|
+
export var bottom = function bottom() {
|
|
46
39
|
for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
47
40
|
params[_key] = arguments[_key];
|
|
48
41
|
}
|
|
49
42
|
|
|
50
43
|
// @signature (limit: Integer) => (source: Array): Array
|
|
51
44
|
if (params.length === 1 && typeof params[0] === "number") {
|
|
52
|
-
return function (
|
|
53
|
-
return _bottom(params[0],
|
|
45
|
+
return function (input) {
|
|
46
|
+
return _bottom(params[0], input);
|
|
54
47
|
};
|
|
55
48
|
} // @signature (source: Array): Array
|
|
56
49
|
|
|
@@ -62,5 +55,4 @@ var bottom = function bottom() {
|
|
|
62
55
|
|
|
63
56
|
return _bottom.apply(void 0, params);
|
|
64
57
|
};
|
|
65
|
-
|
|
66
|
-
exports.bottom = bottom;
|
|
58
|
+
//# sourceMappingURL=bottom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/bottom/bottom.js"],"names":["is","_bottom","limit","input","Array","isArray","length","slice","bottom","params","undefined"],"mappings":"AAAA,SAASA,EAAT,QAAmB,aAAnB;;AAEA,IAAMC,OAAO,GAAG,SAAVA,OAAU,CAACC,KAAD,EAAQC,KAAR,EAAkB;AAChC,MACG,CAACC,KAAK,CAACC,OAAN,CAAcF,KAAd,CAAD,IAAyB,OAAOA,KAAP,KAAiB,QAA3C,IACAA,KAAK,CAACG,MAAN,IAAgB,CAFlB,EAGE;AACA,WAAO,EAAP;AACD;;AAED,SAAOH,KAAK,CAACI,KAAN,CACLP,EAAE,CAACE,KAAD,CAAF,GAAaA,KAAK,IAAIC,KAAK,CAACG,MAAf,GAAwB,CAAxB,GAA4BH,KAAK,CAACG,MAAN,GAAeJ,KAAxD,GAAiE,CAD5D,CAAP;AAGD,CAXD;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,IAAMM,MAAM,GAAG,SAATA,MAAS,GAAe;AAAA,oCAAXC,MAAW;AAAXA,IAAAA,MAAW;AAAA;;AACnC;AACA,MAAIA,MAAM,CAACH,MAAP,KAAkB,CAAlB,IAAuB,OAAOG,MAAM,CAAC,CAAD,CAAb,KAAqB,QAAhD,EAA0D;AACxD,WAAO,UAAAN,KAAK;AAAA,aAAIF,OAAO,CAACQ,MAAM,CAAC,CAAD,CAAP,EAAYN,KAAZ,CAAX;AAAA,KAAZ;AACD,GAJkC,CAMnC;;;AACA,MAAIM,MAAM,CAACH,MAAP,KAAkB,CAAlB,IAAuB,OAAOG,MAAM,CAAC,CAAD,CAAb,KAAqB,QAAhD,EAA0D;AACxD,WAAOR,OAAO,CAACS,SAAD,EAAYD,MAAM,CAAC,CAAD,CAAlB,CAAd;AACD,GATkC,CAWnC;;;AACA,SAAOR,OAAO,MAAP,SAAWQ,MAAX,CAAP;AACD,CAbM","sourcesContent":["import { is } from \"../is/is.js\"\n\nconst _bottom = (limit, input) => {\n if (\n (!Array.isArray(input) && typeof input !== \"string\") ||\n input.length <= 1\n ) {\n return []\n }\n\n return input.slice(\n is(limit) ? (limit >= input.length ? 0 : input.length - limit) : 1\n )\n}\n\n/**\n * Get all but first element from array\n *\n * @param {number} limit How many elements from the bottom\n * @param {Array} source The source\n * @param {...any} params\n *\n * @returns {any}\n *\n * @tag Array\n * @signature (limit: integer, source: Array): Array\n * @signature (source: Array): Array\n *\n * @example\n * bottom([1, 2, 3])\n * // => [1, 2]\n *\n * bottom([1]), bottom([])\n * // => []\n *\n * bottom(2, [2, 3])\n * // => [2, 3]\n *\n * bottom(2)([1, 2, 3])\n * // => [2, 3]\n */\nexport const bottom = (...params) => {\n // @signature (limit: Integer) => (source: Array): Array\n if (params.length === 1 && typeof params[0] === \"number\") {\n return input => _bottom(params[0], input)\n }\n\n // @signature (source: Array): Array\n if (params.length === 1 && typeof params[0] !== \"number\") {\n return _bottom(undefined, params[0])\n }\n\n // @signature (limit: integer, source: Array): Array\n return _bottom(...params)\n}\n"],"file":"bottom.js"}
|
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
t.deepEquals((
|
|
11
|
-
t.deepEquals((
|
|
12
|
-
t.deepEquals((
|
|
13
|
-
t.deepEquals((
|
|
14
|
-
t.deepEquals((
|
|
15
|
-
t.deepEquals((0, _bottom.bottom)("asd", []), [], "Non-numeric Limit should return []");
|
|
16
|
-
t.deepEquals((0, _bottom.bottom)(2)([1, 2, 3]), [2, 3], "Limit and [], curried");
|
|
17
|
-
t.deepEquals((0, _bottom.bottom)(2, [1, 2, 3]), [2, 3], "Limit and [], un-curried");
|
|
18
|
-
t.deepEquals((0, _bottom.bottom)(2)("asd"), "sd", "Limit and string, curried");
|
|
19
|
-
t.deepEquals((0, _bottom.bottom)(2, "asd"), "sd", "Limit and string, un-curried");
|
|
20
|
-
t.deepEquals((0, _bottom.bottom)(3, [1, 2]), [1, 2], "Limit grater than max elements should return all elements");
|
|
1
|
+
import test from "tape";
|
|
2
|
+
import { bottom } from "./bottom.js";
|
|
3
|
+
test("bottom", function (t) {
|
|
4
|
+
t.deepEquals(bottom([1, 2, 3]), [2, 3], "3 length [] should return [] with last 2 elm");
|
|
5
|
+
t.deepEquals(bottom([1, 2]), [2], "2 length [] should return [] with 1 elm");
|
|
6
|
+
t.deepEquals(bottom([1]), [], "1 length [] should return empty []");
|
|
7
|
+
t.deepEquals(bottom([]), [], "Empty [] should return empty []");
|
|
8
|
+
t.deepEquals(bottom(2, 2), [], "Non-array should return empty []");
|
|
9
|
+
t.deepEquals(bottom("asd", []), [], "Non-numeric Limit should return []");
|
|
10
|
+
t.deepEquals(bottom(2)([1, 2, 3]), [2, 3], "Limit and [], curried");
|
|
11
|
+
t.deepEquals(bottom(2, [1, 2, 3]), [2, 3], "Limit and [], un-curried");
|
|
12
|
+
t.deepEquals(bottom(2)("asd"), "sd", "Limit and string, curried");
|
|
13
|
+
t.deepEquals(bottom(2, "asd"), "sd", "Limit and string, un-curried");
|
|
14
|
+
t.deepEquals(bottom(3, [1, 2]), [1, 2], "Limit grater than max elements should return all elements");
|
|
21
15
|
t.end();
|
|
22
|
-
});
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=bottom.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/bottom/bottom.test.js"],"names":["test","bottom","t","deepEquals","end"],"mappings":"AAAA,OAAOA,IAAP,MAAiB,MAAjB;AAEA,SAASC,MAAT,QAAuB,aAAvB;AAEAD,IAAI,CAAC,QAAD,EAAW,UAAAE,CAAC,EAAI;AAClBA,EAAAA,CAAC,CAACC,UAAF,CACEF,MAAM,CAAC,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAAD,CADR,EAEE,CAAC,CAAD,EAAI,CAAJ,CAFF,EAGE,8CAHF;AAKAC,EAAAA,CAAC,CAACC,UAAF,CAAaF,MAAM,CAAC,CAAC,CAAD,EAAI,CAAJ,CAAD,CAAnB,EAA6B,CAAC,CAAD,CAA7B,EAAkC,yCAAlC;AACAC,EAAAA,CAAC,CAACC,UAAF,CAAaF,MAAM,CAAC,CAAC,CAAD,CAAD,CAAnB,EAA0B,EAA1B,EAA8B,oCAA9B;AAEAC,EAAAA,CAAC,CAACC,UAAF,CAAaF,MAAM,CAAC,EAAD,CAAnB,EAAyB,EAAzB,EAA6B,iCAA7B;AACAC,EAAAA,CAAC,CAACC,UAAF,CAAaF,MAAM,CAAC,CAAD,EAAI,CAAJ,CAAnB,EAA2B,EAA3B,EAA+B,kCAA/B;AACAC,EAAAA,CAAC,CAACC,UAAF,CAAaF,MAAM,CAAC,KAAD,EAAQ,EAAR,CAAnB,EAAgC,EAAhC,EAAoC,oCAApC;AAEAC,EAAAA,CAAC,CAACC,UAAF,CAAaF,MAAM,CAAC,CAAD,CAAN,CAAU,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAAV,CAAb,EAAmC,CAAC,CAAD,EAAI,CAAJ,CAAnC,EAA2C,uBAA3C;AACAC,EAAAA,CAAC,CAACC,UAAF,CAAaF,MAAM,CAAC,CAAD,EAAI,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAAJ,CAAnB,EAAmC,CAAC,CAAD,EAAI,CAAJ,CAAnC,EAA2C,0BAA3C;AACAC,EAAAA,CAAC,CAACC,UAAF,CAAaF,MAAM,CAAC,CAAD,CAAN,CAAU,KAAV,CAAb,EAA+B,IAA/B,EAAqC,2BAArC;AACAC,EAAAA,CAAC,CAACC,UAAF,CAAaF,MAAM,CAAC,CAAD,EAAI,KAAJ,CAAnB,EAA+B,IAA/B,EAAqC,8BAArC;AAEAC,EAAAA,CAAC,CAACC,UAAF,CACEF,MAAM,CAAC,CAAD,EAAI,CAAC,CAAD,EAAI,CAAJ,CAAJ,CADR,EAEE,CAAC,CAAD,EAAI,CAAJ,CAFF,EAGE,2DAHF;AAMAC,EAAAA,CAAC,CAACE,GAAF;AACD,CAzBG,CAAJ","sourcesContent":["import test from \"tape\"\n\nimport { bottom } from \"./bottom.js\"\n\ntest(\"bottom\", t => {\n t.deepEquals(\n bottom([1, 2, 3]),\n [2, 3],\n \"3 length [] should return [] with last 2 elm\"\n )\n t.deepEquals(bottom([1, 2]), [2], \"2 length [] should return [] with 1 elm\")\n t.deepEquals(bottom([1]), [], \"1 length [] should return empty []\")\n\n t.deepEquals(bottom([]), [], \"Empty [] should return empty []\")\n t.deepEquals(bottom(2, 2), [], \"Non-array should return empty []\")\n t.deepEquals(bottom(\"asd\", []), [], \"Non-numeric Limit should return []\")\n\n t.deepEquals(bottom(2)([1, 2, 3]), [2, 3], \"Limit and [], curried\")\n t.deepEquals(bottom(2, [1, 2, 3]), [2, 3], \"Limit and [], un-curried\")\n t.deepEquals(bottom(2)(\"asd\"), \"sd\", \"Limit and string, curried\")\n t.deepEquals(bottom(2, \"asd\"), \"sd\", \"Limit and string, un-curried\")\n\n t.deepEquals(\n bottom(3, [1, 2]),\n [1, 2],\n \"Limit grater than max elements should return all elements\"\n )\n\n t.end()\n})\n"],"file":"bottom.test.js"}
|
package/dist/cases/cases.js
CHANGED
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.cases = void 0;
|
|
9
|
-
|
|
10
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
-
|
|
12
|
-
var _toArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toArray"));
|
|
13
|
-
|
|
14
|
-
var _when = require("../when/when");
|
|
15
|
-
|
|
16
|
-
var _i = require("../i/i");
|
|
17
|
-
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import _toArray from "@babel/runtime/helpers/toArray";
|
|
3
|
+
import { when } from "../when/when.js";
|
|
4
|
+
import { i } from "../i/i.js";
|
|
18
5
|
/**
|
|
19
6
|
* Functional case statement.
|
|
20
7
|
*
|
|
@@ -38,15 +25,15 @@ var _i = require("../i/i");
|
|
|
38
25
|
* ], x => x + 1)(2)
|
|
39
26
|
* // => 3
|
|
40
27
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
28
|
+
|
|
29
|
+
export var cases = function cases(_ref) {
|
|
30
|
+
var _ref2 = _toArray(_ref),
|
|
31
|
+
_ref2$ = _slicedToArray(_ref2[0], 2),
|
|
44
32
|
conditionFn = _ref2$[0],
|
|
45
33
|
thenFn = _ref2$[1],
|
|
46
34
|
rest = _ref2.slice(1);
|
|
47
35
|
|
|
48
|
-
var otherwise = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
|
|
49
|
-
return
|
|
36
|
+
var otherwise = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : i;
|
|
37
|
+
return when(conditionFn, thenFn, rest.length === 0 ? otherwise : cases(rest, otherwise));
|
|
50
38
|
};
|
|
51
|
-
|
|
52
|
-
exports.cases = cases;
|
|
39
|
+
//# sourceMappingURL=cases.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/cases/cases.js"],"names":["when","i","cases","conditionFn","thenFn","rest","otherwise","length"],"mappings":";;AAAA,SAASA,IAAT,QAAqB,iBAArB;AACA,SAASC,CAAT,QAAkB,WAAlB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,IAAMC,KAAK,GAAG,SAARA,KAAQ;AAAA;AAAA;AAAA,MAAGC,WAAH;AAAA,MAAgBC,MAAhB;AAAA,MAA4BC,IAA5B;;AAAA,MAAmCC,SAAnC,uEAA+CL,CAA/C;AAAA,SACnBD,IAAI,CACFG,WADE,EAEFC,MAFE,EAGFC,IAAI,CAACE,MAAL,KAAgB,CAAhB,GAAoBD,SAApB,GAAgCJ,KAAK,CAACG,IAAD,EAAOC,SAAP,CAHnC,CADe;AAAA,CAAd","sourcesContent":["import { when } from \"../when/when.js\"\nimport { i } from \"../i/i.js\"\n\n/**\n * Functional case statement.\n *\n * @param {Array<Function, Function>} conditions List of 2-tuples of functions (if, then)\n * @param {Function} [otherwise=i] Function to call if no condition matches, Defaults to identity.\n * @param {any} source Value to check\n *\n * @returns {any}\n * The result of calling the first matching then function or the\n * otherwise function on the input.\n *\n * @name cases\n * @tag Core\n *\n * @see {@link when}\n *\n * @example\n * cases([\n * [x === 0, x => x * 2],\n * [x === 1, x => x],\n * ], x => x + 1)(2)\n * // => 3\n */\nexport const cases = ([[conditionFn, thenFn], ...rest], otherwise = i) =>\n when(\n conditionFn,\n thenFn,\n rest.length === 0 ? otherwise : cases(rest, otherwise)\n )\n"],"file":"cases.js"}
|
package/dist/cases/cases.test.js
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var _tape = _interopRequireDefault(require("tape"));
|
|
6
|
-
|
|
7
|
-
var _cases = require("./cases");
|
|
8
|
-
|
|
9
|
-
(0, _tape.default)("cases", function (t) {
|
|
10
|
-
t.equal((0, _cases.cases)([[function (x) {
|
|
1
|
+
import test from "tape";
|
|
2
|
+
import { cases } from "./cases.js";
|
|
3
|
+
test("cases", function (t) {
|
|
4
|
+
t.equal(cases([[function (x) {
|
|
11
5
|
return x % 2 === 0;
|
|
12
6
|
}, function (x) {
|
|
13
7
|
return x * 2;
|
|
@@ -20,7 +14,7 @@ var _cases = require("./cases");
|
|
|
20
14
|
}, function (x) {
|
|
21
15
|
return x / 2;
|
|
22
16
|
}]])(2), 4, "cases should evaluate the first matching function over the input");
|
|
23
|
-
t.equal(
|
|
17
|
+
t.equal(cases([[function (x) {
|
|
24
18
|
return x % 2 === 0;
|
|
25
19
|
}, function (x) {
|
|
26
20
|
return x * 2;
|
|
@@ -29,7 +23,7 @@ var _cases = require("./cases");
|
|
|
29
23
|
}, function (x) {
|
|
30
24
|
return x / 2;
|
|
31
25
|
}]])(3), 3, "cases should return the original value otherwise");
|
|
32
|
-
t.equal(
|
|
26
|
+
t.equal(cases([[function (x) {
|
|
33
27
|
return x % 2 === 0;
|
|
34
28
|
}, function (x) {
|
|
35
29
|
return x * 2;
|
|
@@ -41,4 +35,5 @@ var _cases = require("./cases");
|
|
|
41
35
|
return x * 3;
|
|
42
36
|
})(3), 9, "cases allows passing an alternative otherwise handler");
|
|
43
37
|
t.end();
|
|
44
|
-
});
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=cases.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/cases/cases.test.js"],"names":["test","cases","t","equal","x","end"],"mappings":"AAAA,OAAOA,IAAP,MAAiB,MAAjB;AAEA,SAASC,KAAT,QAAsB,YAAtB;AAEAD,IAAI,CAAC,OAAD,EAAU,UAAAE,CAAC,EAAI;AACjBA,EAAAA,CAAC,CAACC,KAAF,CACEF,KAAK,CAAC,CACJ,CAAC,UAAAG,CAAC;AAAA,WAAIA,CAAC,GAAG,CAAJ,KAAU,CAAd;AAAA,GAAF,EAAmB,UAAAA,CAAC;AAAA,WAAIA,CAAC,GAAG,CAAR;AAAA,GAApB,CADI,EAEJ,CAAC,UAAAA,CAAC;AAAA,WAAIA,CAAC,GAAG,CAAJ,KAAU,CAAd;AAAA,GAAF,EAAmB,UAAAA,CAAC;AAAA,WAAIA,CAAC,GAAG,CAAR;AAAA,GAApB,CAFI,EAGJ,CAAC,UAAAA,CAAC;AAAA,WAAIA,CAAC,KAAK,CAAV;AAAA,GAAF,EAAe,UAAAA,CAAC;AAAA,WAAIA,CAAC,GAAG,CAAR;AAAA,GAAhB,CAHI,CAAD,CAAL,CAIG,CAJH,CADF,EAME,CANF,EAOE,kEAPF;AAUAF,EAAAA,CAAC,CAACC,KAAF,CACEF,KAAK,CAAC,CACJ,CAAC,UAAAG,CAAC;AAAA,WAAIA,CAAC,GAAG,CAAJ,KAAU,CAAd;AAAA,GAAF,EAAmB,UAAAA,CAAC;AAAA,WAAIA,CAAC,GAAG,CAAR;AAAA,GAApB,CADI,EAEJ,CAAC,UAAAA,CAAC;AAAA,WAAIA,CAAC,KAAK,CAAV;AAAA,GAAF,EAAe,UAAAA,CAAC;AAAA,WAAIA,CAAC,GAAG,CAAR;AAAA,GAAhB,CAFI,CAAD,CAAL,CAGG,CAHH,CADF,EAKE,CALF,EAME,kDANF;AASAF,EAAAA,CAAC,CAACC,KAAF,CACEF,KAAK,CACH,CACE,CAAC,UAAAG,CAAC;AAAA,WAAIA,CAAC,GAAG,CAAJ,KAAU,CAAd;AAAA,GAAF,EAAmB,UAAAA,CAAC;AAAA,WAAIA,CAAC,GAAG,CAAR;AAAA,GAApB,CADF,EAEE,CAAC,UAAAA,CAAC;AAAA,WAAIA,CAAC,KAAK,CAAV;AAAA,GAAF,EAAe,UAAAA,CAAC;AAAA,WAAIA,CAAC,GAAG,CAAR;AAAA,GAAhB,CAFF,CADG,EAKH,UAAAA,CAAC;AAAA,WAAIA,CAAC,GAAG,CAAR;AAAA,GALE,CAAL,CAME,CANF,CADF,EAQE,CARF,EASE,uDATF;AAYAF,EAAAA,CAAC,CAACG,GAAF;AACD,CAjCG,CAAJ","sourcesContent":["import test from \"tape\"\n\nimport { cases } from \"./cases.js\"\n\ntest(\"cases\", t => {\n t.equal(\n cases([\n [x => x % 2 === 0, x => x * 2],\n [x => x % 2 === 1, x => x + 5],\n [x => x === 2, x => x / 2],\n ])(2),\n 4,\n \"cases should evaluate the first matching function over the input\"\n )\n\n t.equal(\n cases([\n [x => x % 2 === 0, x => x * 2],\n [x => x === 2, x => x / 2],\n ])(3),\n 3,\n \"cases should return the original value otherwise\"\n )\n\n t.equal(\n cases(\n [\n [x => x % 2 === 0, x => x * 2],\n [x => x === 2, x => x / 2],\n ],\n x => x * 3\n )(3),\n 9,\n \"cases allows passing an alternative otherwise handler\"\n )\n\n t.end()\n})\n"],"file":"cases.test.js"}
|