@asd14/m 7.4.0 → 7.7.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/README.md +38 -28
- package/dist/all/all.js +15 -21
- package/dist/all/all.js.map +1 -1
- package/dist/all/all.test.js +58 -36
- package/dist/all/all.test.js.map +1 -1
- package/dist/any/any.js +16 -22
- package/dist/any/any.js.map +1 -1
- package/dist/any/any.test.js +54 -33
- package/dist/any/any.test.js.map +1 -1
- package/dist/append/append.js +9 -11
- package/dist/append/append.js.map +1 -1
- package/dist/append/append.test.js +37 -7
- package/dist/append/append.test.js.map +1 -1
- package/dist/bottom/bottom.js +23 -29
- package/dist/bottom/bottom.js.map +1 -1
- package/dist/bottom/bottom.test.js +53 -13
- package/dist/bottom/bottom.test.js.map +1 -1
- package/dist/cases/cases.js +5 -13
- package/dist/cases/cases.js.map +1 -1
- package/dist/cases/cases.test.js +67 -35
- package/dist/cases/cases.test.js.map +1 -1
- package/dist/clone/clone.js +21 -30
- package/dist/clone/clone.js.map +1 -1
- package/dist/clone/clone.test.js +38 -37
- package/dist/clone/clone.test.js.map +1 -1
- package/dist/compact/compact.js +39 -39
- package/dist/compact/compact.js.map +1 -1
- package/dist/compact/compact.test.js +83 -43
- package/dist/compact/compact.test.js.map +1 -1
- package/dist/contains/contains.js +6 -10
- package/dist/contains/contains.js.map +1 -1
- package/dist/contains/contains.test.js +7 -6
- package/dist/contains/contains.test.js.map +1 -1
- package/dist/converge/converge.js +34 -37
- package/dist/converge/converge.js.map +1 -1
- package/dist/converge/converge.test.js +62 -25
- package/dist/converge/converge.test.js.map +1 -1
- package/dist/count/count.js +36 -51
- package/dist/count/count.js.map +1 -1
- package/dist/count/count.test.js +97 -67
- package/dist/count/count.test.js.map +1 -1
- package/dist/curry/curry.js +20 -18
- package/dist/curry/curry.js.map +1 -1
- package/dist/curry/curry.test.js +8 -9
- package/dist/curry/curry.test.js.map +1 -1
- package/dist/debounce/debounce.js +15 -19
- package/dist/debounce/debounce.js.map +1 -1
- package/dist/debounce/debounce.test.js +43 -46
- package/dist/debounce/debounce.test.js.map +1 -1
- package/dist/dec/dec.js +3 -3
- package/dist/dec/dec.js.map +1 -1
- package/dist/dec/dec.test.js +4 -3
- package/dist/dec/dec.test.js.map +1 -1
- package/dist/deep-equal/deep-equal.bench.js +100 -64
- package/dist/deep-equal/deep-equal.bench.js.map +1 -1
- package/dist/deep-equal/deep-equal.js +14 -16
- package/dist/deep-equal/deep-equal.js.map +1 -1
- package/dist/deep-equal/deep-equal.own.js +57 -78
- package/dist/deep-equal/deep-equal.own.js.map +1 -1
- package/dist/deep-equal/deep-equal.test.js +127 -82
- package/dist/deep-equal/deep-equal.test.js.map +1 -1
- package/dist/distinct/distinct.bench.js +46 -31
- package/dist/distinct/distinct.bench.js.map +1 -1
- package/dist/distinct/distinct.js +15 -24
- package/dist/distinct/distinct.js.map +1 -1
- package/dist/distinct/distinct.test.js +37 -14
- package/dist/distinct/distinct.test.js.map +1 -1
- package/dist/drop-last/drop-last.js +8 -12
- package/dist/drop-last/drop-last.js.map +1 -1
- package/dist/drop-last/drop-last.test.js +34 -8
- package/dist/drop-last/drop-last.test.js.map +1 -1
- package/dist/elapsed-time/elapsed-time.js +17 -18
- package/dist/elapsed-time/elapsed-time.js.map +1 -1
- package/dist/elapsed-time/elapsed-time.test.js +9 -8
- package/dist/elapsed-time/elapsed-time.test.js.map +1 -1
- package/dist/ends-with/ends-with.js +10 -16
- package/dist/ends-with/ends-with.js.map +1 -1
- package/dist/ends-with/ends-with.test.js +8 -7
- package/dist/ends-with/ends-with.test.js.map +1 -1
- package/dist/escape/escape.js +3 -4
- package/dist/escape/escape.js.map +1 -1
- package/dist/escape-html/escape-html.js +12 -11
- package/dist/escape-html/escape-html.js.map +1 -1
- package/dist/escape-html/escape-html.test.js +6 -5
- package/dist/escape-html/escape-html.test.js.map +1 -1
- package/dist/escape-reg-exp/escape-reg-exp.js +1 -2
- package/dist/escape-reg-exp/escape-reg-exp.js.map +1 -1
- package/dist/escape-reg-exp/escape-reg-exp.test.js +9 -8
- package/dist/escape-reg-exp/escape-reg-exp.test.js.map +1 -1
- package/dist/filter/filter.js +16 -21
- package/dist/filter/filter.js.map +1 -1
- package/dist/filter/filter.test.js +94 -57
- package/dist/filter/filter.test.js.map +1 -1
- package/dist/find/find.js +38 -50
- package/dist/find/find.js.map +1 -1
- package/dist/find/find.test.js +73 -64
- package/dist/find/find.test.js.map +1 -1
- package/dist/find-index/find-index.js +16 -20
- package/dist/find-index/find-index.js.map +1 -1
- package/dist/find-index/find-index.test.js +48 -38
- package/dist/find-index/find-index.test.js.map +1 -1
- package/dist/first/first.js +3 -3
- package/dist/first/first.js.map +1 -1
- package/dist/first/first.test.js +13 -8
- package/dist/first/first.test.js.map +1 -1
- package/dist/flatten/flatten.js +19 -34
- package/dist/flatten/flatten.js.map +1 -1
- package/dist/flatten/flatten.test.js +59 -24
- package/dist/flatten/flatten.test.js.map +1 -1
- package/dist/for-each/for-each.js +10 -12
- package/dist/for-each/for-each.js.map +1 -1
- package/dist/for-each/for-each.test.js +36 -16
- package/dist/for-each/for-each.test.js.map +1 -1
- package/dist/group-by/group-by.js +13 -17
- package/dist/group-by/group-by.js.map +1 -1
- package/dist/group-by/group-by.test.js +83 -49
- package/dist/group-by/group-by.test.js.map +1 -1
- package/dist/gt/gt.js +3 -6
- package/dist/gt/gt.js.map +1 -1
- package/dist/gt/gt.test.js +7 -6
- package/dist/gt/gt.test.js.map +1 -1
- package/dist/has-key/has-key.js +3 -4
- package/dist/has-key/has-key.js.map +1 -1
- package/dist/has-key/has-key.test.js +10 -9
- package/dist/has-key/has-key.test.js.map +1 -1
- package/dist/hist/hist.js +22 -34
- package/dist/hist/hist.js.map +1 -1
- package/dist/hist/hist.test.js +43 -28
- package/dist/hist/hist.test.js.map +1 -1
- package/dist/i/i.js +3 -3
- package/dist/i/i.js.map +1 -1
- package/dist/i/i.test.js +17 -12
- package/dist/i/i.test.js.map +1 -1
- package/dist/inc/inc.js +3 -3
- package/dist/inc/inc.js.map +1 -1
- package/dist/inc/inc.test.js +4 -3
- package/dist/inc/inc.test.js.map +1 -1
- package/dist/index-by/index-by.js +12 -17
- package/dist/index-by/index-by.js.map +1 -1
- package/dist/index-by/index-by.test.js +44 -36
- package/dist/index-by/index-by.test.js.map +1 -1
- package/dist/index.js +13 -12
- package/dist/index.js.map +1 -1
- package/dist/index.test.js +7 -7
- package/dist/index.test.js.map +1 -1
- package/dist/intersect/intersect.js +41 -54
- package/dist/intersect/intersect.js.map +1 -1
- package/dist/intersect/intersect.test.js +74 -38
- package/dist/intersect/intersect.test.js.map +1 -1
- package/dist/is/is.js +13 -20
- package/dist/is/is.js.map +1 -1
- package/dist/is/is.test.js +25 -25
- package/dist/is/is.test.js.map +1 -1
- package/dist/is-between/is-between.js +9 -13
- package/dist/is-between/is-between.js.map +1 -1
- package/dist/is-between/is-between.test.js +14 -13
- package/dist/is-between/is-between.test.js.map +1 -1
- package/dist/is-empty/is-empty.js +23 -44
- package/dist/is-empty/is-empty.js.map +1 -1
- package/dist/is-empty/is-empty.test.js +31 -27
- package/dist/is-empty/is-empty.test.js.map +1 -1
- package/dist/is-equal/is-equal.js +3 -6
- package/dist/is-equal/is-equal.js.map +1 -1
- package/dist/is-equal/is-equal.test.js +19 -15
- package/dist/is-equal/is-equal.test.js.map +1 -1
- package/dist/is-match/is-match.js +16 -25
- package/dist/is-match/is-match.js.map +1 -1
- package/dist/is-match/is-match.test.js +67 -64
- package/dist/is-match/is-match.test.js.map +1 -1
- package/dist/is-uri/is-uri.js +3 -4
- package/dist/is-uri/is-uri.js.map +1 -1
- package/dist/is-uri/is-uri.test.js +13 -13
- package/dist/is-uri/is-uri.test.js.map +1 -1
- package/dist/join/join.js +42 -53
- package/dist/join/join.js.map +1 -1
- package/dist/join/join.test.js +94 -40
- package/dist/join/join.test.js.map +1 -1
- package/dist/keys/keys.js +34 -24
- package/dist/keys/keys.js.map +1 -1
- package/dist/keys/keys.test.js +21 -9
- package/dist/keys/keys.test.js.map +1 -1
- package/dist/last/last.js +3 -4
- package/dist/last/last.js.map +1 -1
- package/dist/last/last.test.js +14 -7
- package/dist/last/last.test.js.map +1 -1
- package/dist/lt/lt.js +3 -4
- package/dist/lt/lt.js.map +1 -1
- package/dist/lt/lt.test.js +6 -5
- package/dist/lt/lt.test.js.map +1 -1
- package/dist/map/map.js +12 -15
- package/dist/map/map.js.map +1 -1
- package/dist/map/map.test.js +61 -21
- package/dist/map/map.test.js.map +1 -1
- package/dist/map-matrix/map-matrix.js +12 -19
- package/dist/map-matrix/map-matrix.js.map +1 -1
- package/dist/map-matrix/map-matrix.test.js +76 -16
- package/dist/map-matrix/map-matrix.test.js.map +1 -1
- package/dist/max/max.js +27 -39
- package/dist/max/max.js.map +1 -1
- package/dist/max/max.test.js +43 -23
- package/dist/max/max.test.js.map +1 -1
- package/dist/merge/merge.js +53 -63
- package/dist/merge/merge.js.map +1 -1
- package/dist/merge/merge.test.js +57 -49
- package/dist/merge/merge.test.js.map +1 -1
- package/dist/min/min.js +27 -39
- package/dist/min/min.js.map +1 -1
- package/dist/min/min.test.js +38 -22
- package/dist/min/min.test.js.map +1 -1
- package/dist/move/move.js +23 -37
- package/dist/move/move.js.map +1 -1
- package/dist/move/move.test.js +58 -15
- package/dist/move/move.test.js.map +1 -1
- package/dist/mutate/mutate.js +76 -84
- package/dist/mutate/mutate.js.map +1 -1
- package/dist/mutate/mutate.test.js +107 -89
- package/dist/mutate/mutate.test.js.map +1 -1
- package/dist/page/page.js +7 -14
- package/dist/page/page.js.map +1 -1
- package/dist/page/page.test.js +66 -15
- package/dist/page/page.test.js.map +1 -1
- package/dist/partition/partition.js +20 -26
- package/dist/partition/partition.js.map +1 -1
- package/dist/partition/partition.test.js +96 -35
- package/dist/partition/partition.test.js.map +1 -1
- package/dist/pick/pick.js +20 -26
- package/dist/pick/pick.js.map +1 -1
- package/dist/pick/pick.test.js +22 -12
- package/dist/pick/pick.test.js.map +1 -1
- package/dist/pipe/pipe.js +15 -14
- package/dist/pipe/pipe.js.map +1 -1
- package/dist/pipe/pipe.test.js +9 -11
- package/dist/pipe/pipe.test.js.map +1 -1
- package/dist/pipe-p/pipe-p.js +18 -21
- package/dist/pipe-p/pipe-p.js.map +1 -1
- package/dist/pipe-p/pipe-p.test.js +21 -24
- package/dist/pipe-p/pipe-p.test.js.map +1 -1
- package/dist/pluck/pluck.js +27 -38
- package/dist/pluck/pluck.js.map +1 -1
- package/dist/pluck/pluck.test.js +57 -37
- package/dist/pluck/pluck.test.js.map +1 -1
- package/dist/prepend/prepend.js +9 -11
- package/dist/prepend/prepend.js.map +1 -1
- package/dist/prepend/prepend.test.js +37 -7
- package/dist/prepend/prepend.test.js.map +1 -1
- package/dist/proto-chain/proto-chain.js +8 -8
- package/dist/proto-chain/proto-chain.js.map +1 -1
- package/dist/proto-chain/proto-chain.test.js +21 -20
- package/dist/proto-chain/proto-chain.test.js.map +1 -1
- package/dist/push/push.js +9 -12
- package/dist/push/push.js.map +1 -1
- package/dist/push/push.test.js +19 -8
- package/dist/push/push.test.js.map +1 -1
- package/dist/raise/raise.js +3 -3
- package/dist/raise/raise.js.map +1 -1
- package/dist/raise/raise.test.js +6 -5
- package/dist/raise/raise.test.js.map +1 -1
- package/dist/random/random.js +4 -5
- package/dist/random/random.js.map +1 -1
- package/dist/random/random.test.js +11 -12
- package/dist/random/random.test.js.map +1 -1
- package/dist/read/read.js +41 -48
- package/dist/read/read.js.map +1 -1
- package/dist/read/read.test.js +106 -60
- package/dist/read/read.test.js.map +1 -1
- package/dist/reduce/reduce.js +24 -29
- package/dist/reduce/reduce.js.map +1 -1
- package/dist/reduce/reduce.test.js +43 -32
- package/dist/reduce/reduce.test.js.map +1 -1
- package/dist/remove/remove.js +39 -50
- package/dist/remove/remove.js.map +1 -1
- package/dist/remove/remove.test.js +92 -54
- package/dist/remove/remove.test.js.map +1 -1
- package/dist/rename/rename.js +40 -63
- package/dist/rename/rename.js.map +1 -1
- package/dist/rename/rename.test.js +45 -39
- package/dist/rename/rename.test.js.map +1 -1
- package/dist/rename-file/rename-file.js +6 -11
- package/dist/rename-file/rename-file.js.map +1 -1
- package/dist/rename-file/rename-file.test.js +9 -8
- package/dist/rename-file/rename-file.test.js.map +1 -1
- package/dist/repeat/repeat.js +23 -30
- package/dist/repeat/repeat.js.map +1 -1
- package/dist/repeat/repeat.test.js +28 -11
- package/dist/repeat/repeat.test.js.map +1 -1
- package/dist/replace/replace.js +29 -42
- package/dist/replace/replace.js.map +1 -1
- package/dist/replace/replace.test.js +127 -82
- package/dist/replace/replace.test.js.map +1 -1
- package/dist/same/same.js +5 -5
- package/dist/same/same.js.map +1 -1
- package/dist/same/same.test.js +5 -4
- package/dist/same/same.test.js.map +1 -1
- package/dist/sequence/sequence.js +31 -40
- package/dist/sequence/sequence.js.map +1 -1
- package/dist/sequence/sequence.test.js +132 -80
- package/dist/sequence/sequence.test.js.map +1 -1
- package/dist/sort/sort-with.js +90 -98
- package/dist/sort/sort-with.js.map +1 -1
- package/dist/sort/sort.js +24 -32
- package/dist/sort/sort.js.map +1 -1
- package/dist/sort/sort.test.js +407 -294
- package/dist/sort/sort.test.js.map +1 -1
- package/dist/split/split.js +22 -29
- package/dist/split/split.js.map +1 -1
- package/dist/split/split.test.js +29 -12
- package/dist/split/split.test.js.map +1 -1
- package/dist/split-in-groups-of/split-in-groups-of.js +29 -38
- package/dist/split-in-groups-of/split-in-groups-of.js.map +1 -1
- package/dist/split-in-groups-of/split-in-groups-of.test.js +84 -15
- package/dist/split-in-groups-of/split-in-groups-of.test.js.map +1 -1
- package/dist/spy/spy.js +19 -22
- package/dist/spy/spy.js.map +1 -1
- package/dist/spy/spy.test.js +32 -28
- package/dist/spy/spy.test.js.map +1 -1
- package/dist/starts-with/starts-with.js +7 -12
- package/dist/starts-with/starts-with.js.map +1 -1
- package/dist/starts-with/starts-with.test.js +12 -8
- package/dist/starts-with/starts-with.test.js.map +1 -1
- package/dist/throttle/throttle.js +24 -31
- package/dist/throttle/throttle.js.map +1 -1
- package/dist/throttle/throttle.test.js +35 -37
- package/dist/throttle/throttle.test.js.map +1 -1
- package/dist/to-lower/to-lower.js +3 -3
- package/dist/to-lower/to-lower.js.map +1 -1
- package/dist/to-lower/to-lower.test.js +5 -4
- package/dist/to-lower/to-lower.test.js.map +1 -1
- package/dist/to-upper/to-upper.js +3 -3
- package/dist/to-upper/to-upper.js.map +1 -1
- package/dist/to-upper/to-upper.test.js +5 -4
- package/dist/to-upper/to-upper.test.js.map +1 -1
- package/dist/toggle/toggle.js +9 -11
- package/dist/toggle/toggle.js.map +1 -1
- package/dist/toggle/toggle.test.js +24 -5
- package/dist/toggle/toggle.test.js.map +1 -1
- package/dist/top/top.js +23 -35
- package/dist/top/top.js.map +1 -1
- package/dist/top/top.test.js +47 -13
- package/dist/top/top.test.js.map +1 -1
- package/dist/trim/trim.js +19 -26
- package/dist/trim/trim.js.map +1 -1
- package/dist/trim/trim.test.js +6 -5
- package/dist/trim/trim.test.js.map +1 -1
- package/dist/try-catch/try-catch.js +15 -14
- package/dist/try-catch/try-catch.js.map +1 -1
- package/dist/try-catch/try-catch.test.js +9 -8
- package/dist/try-catch/try-catch.test.js.map +1 -1
- package/dist/type/type.js +3 -4
- package/dist/type/type.js.map +1 -1
- package/dist/type/type.test.js +16 -16
- package/dist/type/type.test.js.map +1 -1
- package/dist/unite/unite.js +3 -6
- package/dist/unite/unite.js.map +1 -1
- package/dist/unite/unite.test.js +8 -3
- package/dist/unite/unite.test.js.map +1 -1
- package/dist/update/update.js +74 -81
- package/dist/update/update.js.map +1 -1
- package/dist/update/update.test.js +92 -79
- package/dist/update/update.test.js.map +1 -1
- package/dist/upsert/upsert.js +14 -18
- package/dist/upsert/upsert.js.map +1 -1
- package/dist/upsert/upsert.test.js +57 -42
- package/dist/upsert/upsert.test.js.map +1 -1
- package/dist/values/values.js +38 -29
- package/dist/values/values.js.map +1 -1
- package/dist/values/values.test.js +21 -9
- package/dist/values/values.test.js.map +1 -1
- package/dist/when/when.js +27 -37
- package/dist/when/when.js.map +1 -1
- package/dist/when/when.test.js +23 -15
- package/dist/when/when.test.js.map +1 -1
- package/dist/write/write.js +6 -12
- package/dist/write/write.js.map +1 -1
- package/dist/write/write.test.js +14 -13
- package/dist/write/write.test.js.map +1 -1
- package/dist/zip-to-object/zip-to-object.js +8 -11
- package/dist/zip-to-object/zip-to-object.js.map +1 -1
- package/dist/zip-to-object/zip-to-object.test.js +29 -12
- package/dist/zip-to-object/zip-to-object.test.js.map +1 -1
- package/package.json +47 -38
package/dist/count/count.test.js
CHANGED
|
@@ -1,75 +1,105 @@
|
|
|
1
|
-
/* eslint-disable unicorn/no-null */
|
|
2
|
-
import test from "tape";
|
|
1
|
+
/* eslint-disable unicorn/no-null */ import test from "tape";
|
|
3
2
|
import { is } from "../is/is.js";
|
|
4
3
|
import { read } from "../read/read.js";
|
|
5
4
|
import { gt } from "../gt/gt.js";
|
|
6
5
|
import { count, countBy, countWith } from "./count.js";
|
|
7
|
-
test("count", function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
test("count", function(t) {
|
|
7
|
+
t.equal(count([
|
|
8
|
+
1,
|
|
9
|
+
2,
|
|
10
|
+
3,
|
|
11
|
+
null
|
|
12
|
+
]), 4, "Given array, should return length");
|
|
13
|
+
t.equal(count([]), 0, "Given empty array, should return 0");
|
|
14
|
+
t.equal(count({
|
|
15
|
+
a: 1,
|
|
16
|
+
b: 2
|
|
17
|
+
}), 2, "Given object, should return number of key/value pairs");
|
|
18
|
+
t.equal(count({}), 0, "Given empty object, should return 0");
|
|
19
|
+
t.equal(count("xyz"), 3, "Given string, should return length");
|
|
20
|
+
t.equal(count(3), 0, "Given number, should return 0");
|
|
21
|
+
t.equal(count(null), 0, "Given number, should return 0");
|
|
22
|
+
t.equal(count(), 0, "Given number, should return 0");
|
|
23
|
+
t.end();
|
|
20
24
|
});
|
|
21
|
-
test("countBy", function
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
25
|
+
test("countBy", function(t) {
|
|
26
|
+
t.equal(countBy(is)([
|
|
27
|
+
1,
|
|
28
|
+
2,
|
|
29
|
+
3,
|
|
30
|
+
null
|
|
31
|
+
]), 3, "Count items with predicate and array - curried");
|
|
32
|
+
t.equal(countBy(is, [
|
|
33
|
+
1,
|
|
34
|
+
2,
|
|
35
|
+
3,
|
|
36
|
+
null
|
|
37
|
+
]), 3, "Count items with predicate and array - uncurried");
|
|
38
|
+
t.equal(countBy(is, []), 0, "Count items with predicate and empty array");
|
|
39
|
+
t.equal(countBy([
|
|
40
|
+
read("score"),
|
|
41
|
+
gt(5)
|
|
42
|
+
], [
|
|
43
|
+
{
|
|
44
|
+
name: "Bob",
|
|
45
|
+
score: 1,
|
|
46
|
+
subject: "CS"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: "Alice",
|
|
50
|
+
score: 10,
|
|
51
|
+
subject: "Math"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "Hatter",
|
|
55
|
+
score: 10,
|
|
56
|
+
subject: "Math"
|
|
57
|
+
},
|
|
58
|
+
]), 2, "Count items that match subset");
|
|
59
|
+
t.end();
|
|
39
60
|
});
|
|
40
|
-
test("countWith", function
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
61
|
+
test("countWith", function(t) {
|
|
62
|
+
t.equal(countWith({
|
|
63
|
+
subject: "Math",
|
|
64
|
+
score: gt(5)
|
|
65
|
+
})([
|
|
66
|
+
{
|
|
67
|
+
name: "Bob",
|
|
68
|
+
score: 1,
|
|
69
|
+
subject: "CS"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "Alice",
|
|
73
|
+
score: 10,
|
|
74
|
+
subject: "Math"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: "Hatter",
|
|
78
|
+
score: 10,
|
|
79
|
+
subject: "Math"
|
|
80
|
+
},
|
|
81
|
+
]), 2, "Count items that match subset - curried");
|
|
82
|
+
t.equal(countWith({
|
|
83
|
+
subject: "Math",
|
|
84
|
+
score: gt(5)
|
|
85
|
+
}, [
|
|
86
|
+
{
|
|
87
|
+
name: "Bob",
|
|
88
|
+
score: 1,
|
|
89
|
+
subject: "CS"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: "Alice",
|
|
93
|
+
score: 10,
|
|
94
|
+
subject: "Math"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: "Hatter",
|
|
98
|
+
score: 10,
|
|
99
|
+
subject: "Math"
|
|
100
|
+
},
|
|
101
|
+
]), 2, "Count items that match subset - uncurried");
|
|
102
|
+
t.end();
|
|
74
103
|
});
|
|
104
|
+
|
|
75
105
|
//# sourceMappingURL=count.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/count/count.test.js"],"
|
|
1
|
+
{"version":3,"sources":["../../src/count/count.test.js"],"sourcesContent":["/* eslint-disable unicorn/no-null */\n\nimport test from \"tape\"\n\nimport { is } from \"../is/is.js\"\nimport { read } from \"../read/read.js\"\nimport { gt } from \"../gt/gt.js\"\n\nimport { count, countBy, countWith } from \"./count.js\"\n\ntest(\"count\", t => {\n t.equal(count([1, 2, 3, null]), 4, \"Given array, should return length\")\n\n t.equal(count([]), 0, \"Given empty array, should return 0\")\n\n t.equal(\n count({ a: 1, b: 2 }),\n 2,\n \"Given object, should return number of key/value pairs\"\n )\n\n t.equal(count({}), 0, \"Given empty object, should return 0\")\n\n t.equal(count(\"xyz\"), 3, \"Given string, should return length\")\n\n t.equal(count(3), 0, \"Given number, should return 0\")\n\n t.equal(count(null), 0, \"Given number, should return 0\")\n\n t.equal(count(), 0, \"Given number, should return 0\")\n\n t.end()\n})\n\ntest(\"countBy\", t => {\n t.equal(\n countBy(is)([1, 2, 3, null]),\n 3,\n \"Count items with predicate and array - curried\"\n )\n\n t.equal(\n countBy(is, [1, 2, 3, null]),\n 3,\n \"Count items with predicate and array - uncurried\"\n )\n\n t.equal(countBy(is, []), 0, \"Count items with predicate and empty array\")\n\n t.equal(\n countBy(\n [read(\"score\"), gt(5)],\n [\n { name: \"Bob\", score: 1, subject: \"CS\" },\n { name: \"Alice\", score: 10, subject: \"Math\" },\n { name: \"Hatter\", score: 10, subject: \"Math\" },\n ]\n ),\n 2,\n \"Count items that match subset\"\n )\n\n t.end()\n})\n\ntest(\"countWith\", t => {\n t.equal(\n countWith({\n subject: \"Math\",\n score: gt(5),\n })([\n { name: \"Bob\", score: 1, subject: \"CS\" },\n { name: \"Alice\", score: 10, subject: \"Math\" },\n { name: \"Hatter\", score: 10, subject: \"Math\" },\n ]),\n 2,\n \"Count items that match subset - curried\"\n )\n\n t.equal(\n countWith(\n {\n subject: \"Math\",\n score: gt(5),\n },\n [\n { name: \"Bob\", score: 1, subject: \"CS\" },\n { name: \"Alice\", score: 10, subject: \"Math\" },\n { name: \"Hatter\", score: 10, subject: \"Math\" },\n ]\n ),\n 2,\n \"Count items that match subset - uncurried\"\n )\n\n t.end()\n})\n"],"names":["test","is","read","gt","count","countBy","countWith","t","equal","a","b","end","name","score","subject"],"mappings":"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"}
|
package/dist/curry/curry.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import * as swcHelpers from "@swc/helpers";
|
|
2
|
+
var _this = this;
|
|
3
3
|
/**
|
|
4
4
|
* Partially apply a function
|
|
5
5
|
*
|
|
@@ -17,22 +17,24 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
|
17
17
|
* const sum = (a, b) => a + b
|
|
18
18
|
*
|
|
19
19
|
* curry(sum)(1)(2) = 3
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
20
|
+
*/ export var curry = function(fn) {
|
|
21
|
+
return function() {
|
|
22
|
+
for(var _len1 = arguments.length, params = new Array(_len1), _key1 = 0; _key1 < _len1; _key1++){
|
|
23
|
+
params[_key1] = arguments[_key1];
|
|
24
|
+
}
|
|
25
|
+
var _this1 = _this;
|
|
26
|
+
var _params = params.length === 0 ? [
|
|
27
|
+
undefined
|
|
28
|
+
] : params;
|
|
29
|
+
return _params.length >= fn.length ? fn.apply(void 0, swcHelpers.toConsumableArray(_params)) : function() {
|
|
30
|
+
for(var _len = arguments.length, rest = new Array(_len), _key = 0; _key < _len; _key++){
|
|
31
|
+
rest[_key] = arguments[_key];
|
|
32
|
+
}
|
|
33
|
+
return curry(fn).apply(_this1, swcHelpers.toConsumableArray(_params).concat(swcHelpers.toConsumableArray(rest.length === 0 ? [
|
|
34
|
+
undefined
|
|
35
|
+
] : rest)));
|
|
36
|
+
};
|
|
35
37
|
};
|
|
36
|
-
};
|
|
37
38
|
};
|
|
39
|
+
|
|
38
40
|
//# sourceMappingURL=curry.js.map
|
package/dist/curry/curry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/curry/curry.js"],"
|
|
1
|
+
{"version":3,"sources":["../../src/curry/curry.js"],"sourcesContent":["/**\n * Partially apply a function\n *\n * @signature (...params: mixed[]): Function|any\n *\n * @param {Function} fn The function to apply\n * @param {any} params The arguments to apply, in order\n *\n * @returns {Function|any} If the number of arguments provided is sufficient\n * to call the function, call the function and return the result. Otherwise,\n * return a new function which takes additional parameters, returning the result\n * of calling `curry` on the function with the provided parameters.\n *\n * @example\n * const sum = (a, b) => a + b\n *\n * curry(sum)(1)(2) = 3\n */\nexport const curry =\n fn =>\n (...params) => {\n const _params = params.length === 0 ? [undefined] : params\n\n return _params.length >= fn.length\n ? fn(..._params)\n : (...rest) =>\n curry(fn)(..._params, ...(rest.length === 0 ? [undefined] : rest))\n }\n"],"names":["curry","fn","params","_params","length","undefined","rest"],"mappings":";;AAAA,EAiBG,AAjBH;;;;;;;;;;;;;;;;;CAiBG,AAjBH,EAiBG,CACH,MAAM,CAAC,GAAK,CAACA,KAAK,GAChBC,QACA,CADAA,EAAE;IACF,MAAM,CAAN,QAAQ,GAAO,CAAC;0CAAZC,MAAM;YAANA,MAAM;;;QACR,GAAK,CAACC,OAAO,GAAGD,MAAM,CAACE,MAAM,KAAK,CAAC,GAAG,CAACC;YAAAA,SAAS;QAAA,CAAC,GAAGH,MAAM;QAE1D,MAAM,CAACC,OAAO,CAACC,MAAM,IAAIH,EAAE,CAACG,MAAM,GAC9BH,EAAE,CAAFA,KAAc,CAAdA,IAAI,CAAJA,CAAE,+BAAIE,OAAO,KACb,QAAQ;6CAAJG,IAAI;gBAAJA,IAAI;;YACNN,MAAMC,CAAND,KAAK,CAACC,EAAE,EAARD,KAAkE,sCAArDG,OAAO,sCAAMG,IAAI,CAACF,MAAM,KAAK,CAAC,GAAG,CAACC;gBAAAA,SAAS;YAAA,CAAC,GAAGC,IAAI;;IACxE,CAAC"}
|
package/dist/curry/curry.test.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import test from "tape";
|
|
2
2
|
import { curry } from "./curry.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return a + b;
|
|
3
|
+
var sum = function(a, b) {
|
|
4
|
+
return a + b;
|
|
6
5
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
t.end();
|
|
6
|
+
test("curry", function(t) {
|
|
7
|
+
t.equal(curry(sum)(2, 3), 5, "given [sum function, accepting two parameters, called with numeric values for both] should [return the sum of passed values]");
|
|
8
|
+
t.equal(curry(sum)(2)(3), 5, "given [sum function, accepting two parameters, called with numeric values in curried form] should [return the sum of passed values]");
|
|
9
|
+
t.equal(curry(sum)()(), Number.NaN, "given [sum function, accepting two parameters, called with no parameters two times in curried form] should [return NaN]");
|
|
10
|
+
t.end();
|
|
13
11
|
});
|
|
12
|
+
|
|
14
13
|
//# sourceMappingURL=curry.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/curry/curry.test.js"],"
|
|
1
|
+
{"version":3,"sources":["../../src/curry/curry.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { curry } from \"./curry.js\"\n\nconst sum = (a, b) => a + b\n\ntest(\"curry\", t => {\n t.equal(\n curry(sum)(2, 3),\n 5,\n \"given [sum function, accepting two parameters, called with numeric values for both] should [return the sum of passed values]\"\n )\n\n t.equal(\n curry(sum)(2)(3),\n 5,\n \"given [sum function, accepting two parameters, called with numeric values in curried form] should [return the sum of passed values]\"\n )\n\n t.equal(\n curry(sum)()(),\n Number.NaN,\n \"given [sum function, accepting two parameters, called with no parameters two times in curried form] should [return NaN]\"\n )\n\n t.end()\n})\n"],"names":["test","curry","sum","a","b","t","equal","Number","NaN","end"],"mappings":"AAAA,MAAM,CAACA,IAAI,MAAM,CAAM;AAEvB,MAAM,GAAGC,KAAK,QAAQ,CAAY;AAElC,GAAK,CAACC,GAAG,GAAG,QAAQ,CAAPC,CAAC,EAAEC,CAAC;IAAKD,MACtB,CADsBA,CAAC,GAAGC,CAAC;;AAE3BJ,IAAI,CAAC,CAAO,QAAEK,QACb,CADaA,CAAC,EAAI,CAAC;IAClBA,CAAC,CAACC,KAAK,CACLL,KAAK,CAACC,GAAG,EAAE,CAAC,EAAE,CAAC,GACf,CAAC,EACD,CAA8H;IAGhIG,CAAC,CAACC,KAAK,CACLL,KAAK,CAACC,GAAG,EAAE,CAAC,EAAE,CAAC,GACf,CAAC,EACD,CAAqI;IAGvIG,CAAC,CAACC,KAAK,CACLL,KAAK,CAACC,GAAG,OACTK,MAAM,CAACC,GAAG,EACV,CAAyH;IAG3HH,CAAC,CAACI,GAAG;AACP,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as swcHelpers from "@swc/helpers";
|
|
1
2
|
/**
|
|
2
3
|
* Create a wrapper functions that is invoked only after some time since the last call.
|
|
3
4
|
*
|
|
@@ -16,25 +17,20 @@
|
|
|
16
17
|
*
|
|
17
18
|
* // render
|
|
18
19
|
* <input onChange={debouncedAutocomplete} ... />
|
|
19
|
-
*/
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
clearTimeout(finalRunTimer);
|
|
33
|
-
finalRunTimer = setTimeout(function () {
|
|
34
|
-
fn.apply(void 0, params);
|
|
35
|
-
}, wait);
|
|
36
|
-
};
|
|
20
|
+
*/ var debounce = function(fn) {
|
|
21
|
+
var ref = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, _wait = ref.wait, wait = _wait === void 0 ? 50 : _wait;
|
|
22
|
+
var finalRunTimer;
|
|
23
|
+
return function() {
|
|
24
|
+
for(var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++){
|
|
25
|
+
params[_key] = arguments[_key];
|
|
26
|
+
}
|
|
27
|
+
// reset timer at every function call
|
|
28
|
+
clearTimeout(finalRunTimer);
|
|
29
|
+
finalRunTimer = setTimeout(function() {
|
|
30
|
+
fn.apply(void 0, swcHelpers.toConsumableArray(params));
|
|
31
|
+
}, wait);
|
|
32
|
+
};
|
|
37
33
|
};
|
|
38
|
-
|
|
39
34
|
export { debounce };
|
|
35
|
+
|
|
40
36
|
//# sourceMappingURL=debounce.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/debounce/debounce.js"],"
|
|
1
|
+
{"version":3,"sources":["../../src/debounce/debounce.js"],"sourcesContent":["/**\n * Create a wrapper functions that is invoked only after some time since the last call.\n *\n * @param {Function} fn\n * @param {Object} [props]\n * @param {number} [props.wait=50] Time in milliseconds to wait until invoke\n *\n * @returns {Function} Wrapper function that calls `fn` after `wait` passed without calling\n *\n * @name debounce\n * @tag Core\n * @signature (fn: Function, { wait: number }): Function\n *\n * @example\n * const debouncedAutocomplete = debounce(autocompleteFromAPI, { wait: 100 })\n *\n * // render\n * <input onChange={debouncedAutocomplete} ... />\n */\nconst debounce = (fn, { wait = 50 } = {}) => {\n let finalRunTimer\n\n return (...params) => {\n // reset timer at every function call\n clearTimeout(finalRunTimer)\n\n finalRunTimer = setTimeout(() => {\n fn(...params)\n }, wait)\n }\n}\n\nexport { debounce }\n"],"names":["debounce","fn","wait","finalRunTimer","params","clearTimeout","setTimeout"],"mappings":";AAAA,EAkBG,AAlBH;;;;;;;;;;;;;;;;;;CAkBG,AAlBH,EAkBG,CACH,GAAK,CAACA,QAAQ,GAAG,QAAQ,CAAPC,EAAE,EAAyB,CAAC;+EAAR,CAAC,CAAC,cAAhBC,IAAI,EAAJA,IAAI,sBAAG,EAAE;IAC/B,GAAG,CAACC,aAAa;IAEjB,MAAM,CAAC,QAAQ,GAAO,CAAC;yCAAZC,MAAM;YAANA,MAAM;;QACf,EAAqC,AAArC,mCAAqC;QACrCC,YAAY,CAACF,aAAa;QAE1BA,aAAa,GAAGG,UAAU,CAAC,QAC/B,GADqC,CAAC;YAChCL,EAAE,CAAFA,KAAa,CAAbA,IAAI,CAAJA,CAAE,+BAAIG,MAAM;QACd,CAAC,EAAEF,IAAI;IACT,CAAC;AACH,CAAC;AAED,MAAM,GAAGF,QAAQ"}
|
|
@@ -1,52 +1,49 @@
|
|
|
1
1
|
import test from "tape";
|
|
2
2
|
import { debounce } from "./debounce.js";
|
|
3
|
-
test("debounce", function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
test("debounce", function(t) {
|
|
4
|
+
{
|
|
5
|
+
var callCount = 0;
|
|
6
|
+
var iteration = 0;
|
|
7
|
+
var defaultSet = debounce(function(input) {
|
|
8
|
+
callCount = callCount + 1;
|
|
9
|
+
iteration = input;
|
|
10
|
+
});
|
|
11
|
+
for(var i = 0; i < 100; i++){
|
|
12
|
+
defaultSet(i);
|
|
13
|
+
}
|
|
14
|
+
setTimeout(function() {
|
|
15
|
+
t.deepEqual({
|
|
16
|
+
callCount: callCount,
|
|
17
|
+
i: iteration
|
|
18
|
+
}, {
|
|
19
|
+
callCount: 1,
|
|
20
|
+
i: 99
|
|
21
|
+
}, "Calling debounce function 100 times should run it once, 50ms after last call");
|
|
22
|
+
}, 100);
|
|
14
23
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
customSet(_i);
|
|
24
|
+
{
|
|
25
|
+
var callCount1 = 0;
|
|
26
|
+
var iteration1 = 0;
|
|
27
|
+
var customSet = debounce(function(input) {
|
|
28
|
+
callCount1 = callCount1 + 1;
|
|
29
|
+
iteration1 = input;
|
|
30
|
+
}, {
|
|
31
|
+
wait: 100
|
|
32
|
+
});
|
|
33
|
+
for(var i1 = 0; i1 < 100; i1++){
|
|
34
|
+
customSet(i1);
|
|
35
|
+
}
|
|
36
|
+
setTimeout(function() {
|
|
37
|
+
t.deepEqual({
|
|
38
|
+
callCount: callCount1,
|
|
39
|
+
i: iteration1
|
|
40
|
+
}, {
|
|
41
|
+
callCount: 1,
|
|
42
|
+
i: 99
|
|
43
|
+
}, "Calling debounced function 100 times with custom timer window");
|
|
44
|
+
t.end();
|
|
45
|
+
}, 150);
|
|
38
46
|
}
|
|
39
|
-
|
|
40
|
-
setTimeout(function () {
|
|
41
|
-
t.deepEqual({
|
|
42
|
-
callCount: _callCount,
|
|
43
|
-
i: _iteration
|
|
44
|
-
}, {
|
|
45
|
-
callCount: 1,
|
|
46
|
-
i: 99
|
|
47
|
-
}, "Calling debounced function 100 times with custom timer window");
|
|
48
|
-
t.end();
|
|
49
|
-
}, 150);
|
|
50
|
-
}
|
|
51
47
|
});
|
|
48
|
+
|
|
52
49
|
//# sourceMappingURL=debounce.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/debounce/debounce.test.js"],"
|
|
1
|
+
{"version":3,"sources":["../../src/debounce/debounce.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { debounce } from \"./debounce.js\"\n\ntest(\"debounce\", t => {\n {\n let callCount = 0\n\n let iteration = 0\n\n const defaultSet = debounce(input => {\n callCount = callCount + 1\n iteration = input\n })\n\n for (let i = 0; i < 100; i++) {\n defaultSet(i)\n }\n\n setTimeout(() => {\n t.deepEqual(\n {\n callCount,\n i: iteration,\n },\n {\n callCount: 1,\n i: 99,\n },\n \"Calling debounce function 100 times should run it once, 50ms after last call\"\n )\n }, 100)\n }\n\n {\n let callCount = 0\n\n let iteration = 0\n\n const customSet = debounce(\n input => {\n callCount = callCount + 1\n iteration = input\n },\n { wait: 100 }\n )\n\n for (let i = 0; i < 100; i++) {\n customSet(i)\n }\n\n setTimeout(() => {\n t.deepEqual(\n {\n callCount,\n i: iteration,\n },\n {\n callCount: 1,\n i: 99,\n },\n \"Calling debounced function 100 times with custom timer window\"\n )\n\n t.end()\n }, 150)\n }\n})\n"],"names":["test","debounce","t","callCount","iteration","defaultSet","input","i","setTimeout","deepEqual","customSet","wait","end"],"mappings":"AAAA,MAAM,CAACA,IAAI,MAAM,CAAM;AAEvB,MAAM,GAAGC,QAAQ,QAAQ,CAAe;AAExCD,IAAI,CAAC,CAAU,WAAEE,QAChB,CADgBA,CAAC,EAAI,CAAC;IACrB,CAAC;QACC,GAAG,CAACC,SAAS,GAAG,CAAC;QAEjB,GAAG,CAACC,SAAS,GAAG,CAAC;QAEjB,GAAK,CAACC,UAAU,GAAGJ,QAAQ,CAACK,QAAQ,CAARA,KAAK,EAAI,CAAC;YACpCH,SAAS,GAAGA,SAAS,GAAG,CAAC;YACzBC,SAAS,GAAGE,KAAK;QACnB,CAAC;QAED,GAAG,CAAE,GAAG,CAACC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAG,GAAG,EAAEA,CAAC,GAAI,CAAC;YAC7BF,UAAU,CAACE,CAAC;QACd,CAAC;QAEDC,UAAU,CAAC,QACf,GADqB,CAAC;YAChBN,CAAC,CAACO,SAAS,CACT,CAAC;gBACCN,SAAS,EAATA,SAAS;gBACTI,CAAC,EAAEH,SAAS;YACd,CAAC,EACD,CAAC;gBACCD,SAAS,EAAE,CAAC;gBACZI,CAAC,EAAE,EAAE;YACP,CAAC,EACD,CAA8E;QAElF,CAAC,EAAE,GAAG;IACR,CAAC;IAED,CAAC;QACC,GAAG,CAACJ,UAAS,GAAG,CAAC;QAEjB,GAAG,CAACC,UAAS,GAAG,CAAC;QAEjB,GAAK,CAACM,SAAS,GAAGT,QAAQ,CACxBK,QAAQ,CAARA,KAAK,EAAI,CAAC;YACRH,UAAS,GAAGA,UAAS,GAAG,CAAC;YACzBC,UAAS,GAAGE,KAAK;QACnB,CAAC,EACD,CAAC;YAACK,IAAI,EAAE,GAAG;QAAC,CAAC;QAGf,GAAG,CAAE,GAAG,CAACJ,EAAC,GAAG,CAAC,EAAEA,EAAC,GAAG,GAAG,EAAEA,EAAC,GAAI,CAAC;YAC7BG,SAAS,CAACH,EAAC;QACb,CAAC;QAEDC,UAAU,CAAC,QACf,GADqB,CAAC;YAChBN,CAAC,CAACO,SAAS,CACT,CAAC;gBACCN,SAAS,EAATA,UAAS;gBACTI,CAAC,EAAEH,UAAS;YACd,CAAC,EACD,CAAC;gBACCD,SAAS,EAAE,CAAC;gBACZI,CAAC,EAAE,EAAE;YACP,CAAC,EACD,CAA+D;YAGjEL,CAAC,CAACU,GAAG;QACP,CAAC,EAAE,GAAG;IACR,CAAC;AACH,CAAC"}
|
package/dist/dec/dec.js
CHANGED
package/dist/dec/dec.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/dec/dec.js"],"
|
|
1
|
+
{"version":3,"sources":["../../src/dec/dec.js"],"sourcesContent":["/**\n * Substract one\n *\n * @param {number} input Input number\n *\n * @returns {number}\n *\n * @tag Number\n * @signature (input: number): number\n *\n * @example\n * dec(2)\n * // => 1\n */\nexport const dec = input => input - 1\n"],"names":["dec","input"],"mappings":"AAAA,EAaG,AAbH;;;;;;;;;;;;;CAaG,AAbH,EAaG,CACH,MAAM,CAAC,GAAK,CAACA,GAAG,GAAGC,QAAQ,CAARA,KAAK;IAAIA,MAAM,CAANA,KAAK,GAAG,CAAC"}
|
package/dist/dec/dec.test.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import test from "tape";
|
|
2
2
|
import { dec } from "./dec.js";
|
|
3
|
-
test("dec", function
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
test("dec", function(t) {
|
|
4
|
+
t.equal(dec(2), 1, "Decrement number");
|
|
5
|
+
t.end();
|
|
6
6
|
});
|
|
7
|
+
|
|
7
8
|
//# sourceMappingURL=dec.test.js.map
|
package/dist/dec/dec.test.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/dec/dec.test.js"],"
|
|
1
|
+
{"version":3,"sources":["../../src/dec/dec.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { dec } from \"./dec.js\"\n\ntest(\"dec\", t => {\n t.equal(dec(2), 1, \"Decrement number\")\n\n t.end()\n})\n"],"names":["test","dec","t","equal","end"],"mappings":"AAAA,MAAM,CAACA,IAAI,MAAM,CAAM;AAEvB,MAAM,GAAGC,GAAG,QAAQ,CAAU;AAE9BD,IAAI,CAAC,CAAK,MAAEE,QACX,CADWA,CAAC,EAAI,CAAC;IAChBA,CAAC,CAACC,KAAK,CAACF,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,CAAkB;IAErCC,CAAC,CAACE,GAAG;AACP,CAAC"}
|