@asd14/m 7.5.0 → 7.7.0-next.2
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 +46 -37
package/dist/page/page.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import * as swcHelpers from "@swc/helpers";
|
|
3
2
|
/**
|
|
4
3
|
* Get a subset array using offset and limit
|
|
5
4
|
*
|
|
@@ -16,18 +15,12 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
|
16
15
|
* limit: 5
|
|
17
16
|
* })([1, 2, 3, 4, 5, 6, 7, 8])
|
|
18
17
|
* // => [2, 3, 4, 5, 6]
|
|
19
|
-
*/
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
_ref$limit = _ref.limit,
|
|
25
|
-
limit = _ref$limit === void 0 ? 10 : _ref$limit;
|
|
26
|
-
|
|
27
|
-
return function (input) {
|
|
28
|
-
return _toConsumableArray(input.splice(offset, limit));
|
|
29
|
-
};
|
|
18
|
+
*/ var page = function() {
|
|
19
|
+
var ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _offset = ref.offset, offset = _offset === void 0 ? 0 : _offset, _limit = ref.limit, limit = _limit === void 0 ? 10 : _limit;
|
|
20
|
+
return function(input) {
|
|
21
|
+
return swcHelpers.toConsumableArray(input.splice(offset, limit));
|
|
22
|
+
};
|
|
30
23
|
};
|
|
31
|
-
|
|
32
24
|
export { page };
|
|
25
|
+
|
|
33
26
|
//# sourceMappingURL=page.js.map
|
package/dist/page/page.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/page/page.js"],"
|
|
1
|
+
{"version":3,"sources":["../../src/page/page.js"],"sourcesContent":["/**\n * Get a subset array using offset and limit\n *\n * @param {Object} props\n * @param {number} props.offset\n * @param {number} props.limit\n * @param {Array} input\n *\n * @returns {Array}\n *\n * @example\n * page({\n * offset: 1,\n * limit: 5\n * })([1, 2, 3, 4, 5, 6, 7, 8])\n * // => [2, 3, 4, 5, 6]\n */\nconst page =\n ({ offset = 0, limit = 10 } = {}) =>\n input =>\n [...input.splice(offset, limit)]\n\nexport { page }\n"],"names":["page","offset","limit","input","splice"],"mappings":";AAAA,EAgBG,AAhBH;;;;;;;;;;;;;;;;CAgBG,AAhBH,EAgBG,CACH,GAAK,CAACA,IAAI,GACR,QAAQ;+EAAsB,CAAC,CAAC,gBAA7BC,MAAM,EAANA,MAAM,wBAAG,CAAC,yBAAEC,KAAK,EAALA,KAAK,uBAAG,EAAE;IACzBC,MAAM,CAANA,QAAQ,CAARA,KAAK;QACF,MAAM,8BAAHA,KAAK,CAACC,MAAM,CAACH,MAAM,EAAEC,KAAK;;;AAElC,MAAM,GAAGF,IAAI"}
|
package/dist/page/page.test.js
CHANGED
|
@@ -1,19 +1,70 @@
|
|
|
1
1
|
import test from "tape";
|
|
2
2
|
import { page } from "./page.js";
|
|
3
|
-
test("page", function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
3
|
+
test("page", function(t) {
|
|
4
|
+
t.deepEqual(page()([
|
|
5
|
+
1,
|
|
6
|
+
2,
|
|
7
|
+
3,
|
|
8
|
+
4,
|
|
9
|
+
5,
|
|
10
|
+
6,
|
|
11
|
+
7,
|
|
12
|
+
8,
|
|
13
|
+
9,
|
|
14
|
+
10,
|
|
15
|
+
11
|
|
16
|
+
]), [
|
|
17
|
+
1,
|
|
18
|
+
2,
|
|
19
|
+
3,
|
|
20
|
+
4,
|
|
21
|
+
5,
|
|
22
|
+
6,
|
|
23
|
+
7,
|
|
24
|
+
8,
|
|
25
|
+
9,
|
|
26
|
+
10
|
|
27
|
+
], "Page with default");
|
|
28
|
+
t.deepEqual(page({
|
|
29
|
+
offset: 1,
|
|
30
|
+
limit: 5
|
|
31
|
+
})([
|
|
32
|
+
1,
|
|
33
|
+
2,
|
|
34
|
+
3,
|
|
35
|
+
4,
|
|
36
|
+
5,
|
|
37
|
+
6,
|
|
38
|
+
7,
|
|
39
|
+
8
|
|
40
|
+
]), [
|
|
41
|
+
2,
|
|
42
|
+
3,
|
|
43
|
+
4,
|
|
44
|
+
5,
|
|
45
|
+
6
|
|
46
|
+
], "5 length page starting from position 1");
|
|
47
|
+
t.deepEqual(page({
|
|
48
|
+
offset: 0,
|
|
49
|
+
limit: 5
|
|
50
|
+
})([
|
|
51
|
+
1,
|
|
52
|
+
2,
|
|
53
|
+
3
|
|
54
|
+
]), [
|
|
55
|
+
1,
|
|
56
|
+
2,
|
|
57
|
+
3
|
|
58
|
+
], "limit over source lenght");
|
|
59
|
+
t.deepEqual(page({
|
|
60
|
+
offset: 11,
|
|
61
|
+
limit: 5
|
|
62
|
+
})([
|
|
63
|
+
1,
|
|
64
|
+
2,
|
|
65
|
+
3
|
|
66
|
+
]), [], "offset over source lenght");
|
|
67
|
+
t.end();
|
|
18
68
|
});
|
|
69
|
+
|
|
19
70
|
//# sourceMappingURL=page.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/page/page.test.js"],"
|
|
1
|
+
{"version":3,"sources":["../../src/page/page.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { page } from \"./page.js\"\n\ntest(\"page\", t => {\n t.deepEqual(\n page()([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),\n [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],\n \"Page with default\"\n )\n\n t.deepEqual(\n page({ offset: 1, limit: 5 })([1, 2, 3, 4, 5, 6, 7, 8]),\n [2, 3, 4, 5, 6],\n \"5 length page starting from position 1\"\n )\n\n t.deepEqual(\n page({ offset: 0, limit: 5 })([1, 2, 3]),\n [1, 2, 3],\n \"limit over source lenght\"\n )\n\n t.deepEqual(\n page({ offset: 11, limit: 5 })([1, 2, 3]),\n [],\n \"offset over source lenght\"\n )\n\n t.end()\n})\n"],"names":["test","page","t","deepEqual","offset","limit","end"],"mappings":"AAAA,MAAM,CAACA,IAAI,MAAM,CAAM;AAEvB,MAAM,GAAGC,IAAI,QAAQ,CAAW;AAEhCD,IAAI,CAAC,CAAM,OAAEE,QACZ,CADYA,CAAC,EAAI,CAAC;IACjBA,CAAC,CAACC,SAAS,CACTF,IAAI,GAAG,CAAC;AAAA,SAAC;AAAE,SAAC;AAAE,SAAC;AAAE,SAAC;AAAE,SAAC;AAAE,SAAC;AAAE,SAAC;AAAE,SAAC;AAAE,SAAC;AAAE,UAAE;AAAE,UAAE;IAAA,CAAC,GAC1C,CAAC;AAAA,SAAC;AAAE,SAAC;AAAE,SAAC;AAAE,SAAC;AAAE,SAAC;AAAE,SAAC;AAAE,SAAC;AAAE,SAAC;AAAE,SAAC;AAAE,UAAE;IAAA,CAAC,EAC/B,CAAmB;IAGrBC,CAAC,CAACC,SAAS,CACTF,IAAI,CAAC,CAAC;QAACG,MAAM,EAAE,CAAC;QAAEC,KAAK,EAAE,CAAC;IAAC,CAAC,EAAE,CAAC;AAAA,SAAC;AAAE,SAAC;AAAE,SAAC;AAAE,SAAC;AAAE,SAAC;AAAE,SAAC;AAAE,SAAC;AAAE,SAAC;IAAA,CAAC,GACtD,CAAC;AAAA,SAAC;AAAE,SAAC;AAAE,SAAC;AAAE,SAAC;AAAE,SAAC;IAAA,CAAC,EACf,CAAwC;IAG1CH,CAAC,CAACC,SAAS,CACTF,IAAI,CAAC,CAAC;QAACG,MAAM,EAAE,CAAC;QAAEC,KAAK,EAAE,CAAC;IAAC,CAAC,EAAE,CAAC;AAAA,SAAC;AAAE,SAAC;AAAE,SAAC;IAAA,CAAC,GACvC,CAAC;AAAA,SAAC;AAAE,SAAC;AAAE,SAAC;IAAA,CAAC,EACT,CAA0B;IAG5BH,CAAC,CAACC,SAAS,CACTF,IAAI,CAAC,CAAC;QAACG,MAAM,EAAE,EAAE;QAAEC,KAAK,EAAE,CAAC;IAAC,CAAC,EAAE,CAAC;AAAA,SAAC;AAAE,SAAC;AAAE,SAAC;IAAA,CAAC,GACxC,CAAC,CAAC,EACF,CAA2B;IAG7BH,CAAC,CAACI,GAAG;AACP,CAAC"}
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
/* eslint-disable no-unused-vars*/
|
|
4
|
-
import { pipe } from "../pipe/pipe.js";
|
|
1
|
+
import * as swcHelpers from "@swc/helpers";
|
|
2
|
+
/* eslint-disable no-unused-vars*/ import { pipe } from "../pipe/pipe.js";
|
|
5
3
|
import { curry } from "../curry/curry.js";
|
|
6
4
|
import { isMatch } from "../is-match/is-match.js";
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
fail.push(input[i]);
|
|
5
|
+
var _partition = function(_fn, input) {
|
|
6
|
+
var fn = Array.isArray(_fn) ? pipe.apply(void 0, swcHelpers.toConsumableArray(_fn)) : _fn;
|
|
7
|
+
var pass = [];
|
|
8
|
+
var fail = [];
|
|
9
|
+
for(var i = 0; i < input.length; ++i){
|
|
10
|
+
if (fn(input[i], i, input)) {
|
|
11
|
+
pass.push(input[i]);
|
|
12
|
+
} else {
|
|
13
|
+
fail.push(input[i]);
|
|
14
|
+
}
|
|
18
15
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
return [
|
|
17
|
+
pass,
|
|
18
|
+
fail
|
|
19
|
+
];
|
|
22
20
|
};
|
|
23
21
|
/**
|
|
24
22
|
* Split an array based on a predicate function.
|
|
@@ -37,10 +35,7 @@ var _partition = function _partition(_fn, input) {
|
|
|
37
35
|
* @example
|
|
38
36
|
* partition(x => x % 2 === 0)([1, 2, 3, 4, 5])
|
|
39
37
|
* // => [[2, 4], [1, 3, 5]]
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
export var partition = curry(_partition);
|
|
38
|
+
*/ export var partition = curry(_partition);
|
|
44
39
|
/**
|
|
45
40
|
* Split an array based on object matching
|
|
46
41
|
* Take `A[]` and return a two-tuple of `A[]`s. The first element of the tuple
|
|
@@ -58,9 +53,8 @@ export var partition = curry(_partition);
|
|
|
58
53
|
* @example
|
|
59
54
|
* partitionWith({comments: is}, [{id: 1}, {id: 2, comments: []}])
|
|
60
55
|
* // => [[{id: 1}], [{id: 2, comments: []}]]
|
|
61
|
-
*/
|
|
62
|
-
|
|
63
|
-
export var partitionWith = curry(function (subset, input) {
|
|
64
|
-
return _partition(isMatch(subset), input);
|
|
56
|
+
*/ export var partitionWith = curry(function(subset, input) {
|
|
57
|
+
return _partition(isMatch(subset), input);
|
|
65
58
|
});
|
|
59
|
+
|
|
66
60
|
//# sourceMappingURL=partition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/partition/partition.js"],"
|
|
1
|
+
{"version":3,"sources":["../../src/partition/partition.js"],"sourcesContent":["/* eslint-disable no-unused-vars*/\n\nimport { pipe } from \"../pipe/pipe.js\"\nimport { curry } from \"../curry/curry.js\"\nimport { isMatch } from \"../is-match/is-match.js\"\n\nconst _partition = (_fn, input) => {\n const fn = Array.isArray(_fn) ? pipe(..._fn) : _fn\n const pass = []\n const fail = []\n\n for (let i = 0; i < input.length; ++i) {\n if (fn(input[i], i, input)) {\n pass.push(input[i])\n } else {\n fail.push(input[i])\n }\n }\n\n return [pass, fail]\n}\n\n/**\n * Split an array based on a predicate function.\n * Take `A[]` and return a two-tuple of `A[]`s. The first element of the tuple\n * consists of elements for which the predicate returned `true`, the second of\n * elements for which it returned `false`.\n *\n * @param {Function} fn A predicate function.\n *\n * @returns {Array<Array, Array>}\n *\n * @name partition\n * @tag Array\n * @signature (fn: Function|Function[], input: Array) => Array<Array, Array>\n *\n * @example\n * partition(x => x % 2 === 0)([1, 2, 3, 4, 5])\n * // => [[2, 4], [1, 3, 5]]\n */\nexport const partition = curry(_partition)\n\n/**\n * Split an array based on object matching\n * Take `A[]` and return a two-tuple of `A[]`s. The first element of the tuple\n * consists of elements for which the predicate returned `true`, the second of\n * elements for which it returned `false`.\n *\n * @param {object} subset A predicate function.\n *\n * @returns {Array<Array, Array>}\n *\n * @name partitionWith\n * @tag Array\n * @signature (subset: Object, input: Array) => Array<Array, Array>\n *\n * @example\n * partitionWith({comments: is}, [{id: 1}, {id: 2, comments: []}])\n * // => [[{id: 1}], [{id: 2, comments: []}]]\n */\nexport const partitionWith = curry((subset, input) =>\n _partition(isMatch(subset), input)\n)\n"],"names":["pipe","curry","isMatch","_partition","_fn","input","fn","Array","isArray","pass","fail","i","length","push","partition","partitionWith","subset"],"mappings":";AAAA,EAAkC,AAAlC,8BAAkC,AAAlC,EAAkC,CAElC,MAAM,GAAGA,IAAI,QAAQ,CAAiB;AACtC,MAAM,GAAGC,KAAK,QAAQ,CAAmB;AACzC,MAAM,GAAGC,OAAO,QAAQ,CAAyB;AAEjD,GAAK,CAACC,UAAU,GAAG,QAAQ,CAAPC,GAAG,EAAEC,KAAK,EAAK,CAAC;IAClC,GAAK,CAACC,EAAE,GAAGC,KAAK,CAACC,OAAO,CAACJ,GAAG,IAAIJ,IAAI,CAAJA,KAAY,CAAZA,IAAI,CAAJA,CAAI,+BAAII,GAAG,KAAIA,GAAG;IAClD,GAAK,CAACK,IAAI,GAAG,CAAC,CAAC;IACf,GAAK,CAACC,IAAI,GAAG,CAAC,CAAC;IAEf,GAAG,CAAE,GAAG,CAACC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGN,KAAK,CAACO,MAAM,IAAID,CAAC,CAAE,CAAC;QACtC,EAAE,EAAEL,EAAE,CAACD,KAAK,CAACM,CAAC,GAAGA,CAAC,EAAEN,KAAK,GAAG,CAAC;YAC3BI,IAAI,CAACI,IAAI,CAACR,KAAK,CAACM,CAAC;QACnB,CAAC,MAAM,CAAC;YACND,IAAI,CAACG,IAAI,CAACR,KAAK,CAACM,CAAC;QACnB,CAAC;IACH,CAAC;IAED,MAAM,CAAC,CAACF;QAAAA,IAAI;QAAEC,IAAI;IAAA,CAAC;AACrB,CAAC;AAED,EAiBG,AAjBH;;;;;;;;;;;;;;;;;CAiBG,AAjBH,EAiBG,CACH,MAAM,CAAC,GAAK,CAACI,SAAS,GAAGb,KAAK,CAACE,UAAU;AAEzC,EAiBG,AAjBH;;;;;;;;;;;;;;;;;CAiBG,AAjBH,EAiBG,CACH,MAAM,CAAC,GAAK,CAACY,aAAa,GAAGd,KAAK,CAAC,QAAQ,CAAPe,MAAM,EAAEX,KAAK;IAC/CF,MAAM,CAANA,UAAU,CAACD,OAAO,CAACc,MAAM,GAAGX,KAAK"}
|
|
@@ -2,42 +2,103 @@ import test from "tape";
|
|
|
2
2
|
import { is } from "../is/is.js";
|
|
3
3
|
import { read } from "../read/read.js";
|
|
4
4
|
import { partition, partitionWith } from "./partition.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return x === 2;
|
|
5
|
+
var equalsTwo = function(x) {
|
|
6
|
+
return x === 2;
|
|
8
7
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
8
|
+
test("partition", function(t) {
|
|
9
|
+
t.deepEqual(partition(equalsTwo)([
|
|
10
|
+
2,
|
|
11
|
+
2,
|
|
12
|
+
1,
|
|
13
|
+
1,
|
|
14
|
+
2
|
|
15
|
+
]), [
|
|
16
|
+
[
|
|
17
|
+
2,
|
|
18
|
+
2,
|
|
19
|
+
2
|
|
20
|
+
],
|
|
21
|
+
[
|
|
22
|
+
1,
|
|
23
|
+
1
|
|
24
|
+
],
|
|
25
|
+
], "(equalsTwo)([2,2,1,1,2]) // => [[2,2,2],[1,1]]");
|
|
26
|
+
t.deepEqual(partition(equalsTwo, [
|
|
27
|
+
2,
|
|
28
|
+
2,
|
|
29
|
+
1,
|
|
30
|
+
1,
|
|
31
|
+
2
|
|
32
|
+
]), [
|
|
33
|
+
[
|
|
34
|
+
2,
|
|
35
|
+
2,
|
|
36
|
+
2
|
|
37
|
+
],
|
|
38
|
+
[
|
|
39
|
+
1,
|
|
40
|
+
1
|
|
41
|
+
],
|
|
42
|
+
], "(equalsTwo, [2,2,1,1,2]) // => [[2,2,2],[1,1]]");
|
|
43
|
+
t.deepEqual(partition([
|
|
44
|
+
read("comments"),
|
|
45
|
+
is
|
|
46
|
+
], [
|
|
47
|
+
{
|
|
48
|
+
id: 1,
|
|
49
|
+
comments: []
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: 2
|
|
53
|
+
}
|
|
54
|
+
]), [
|
|
55
|
+
[
|
|
56
|
+
{
|
|
57
|
+
id: 1,
|
|
58
|
+
comments: []
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
[
|
|
62
|
+
{
|
|
63
|
+
id: 2
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
], "(equalsTwo, [2,2,1,1,2]) // => [[2,2,2],[1,1]]");
|
|
67
|
+
t.deepEqual(partition(equalsTwo)([
|
|
68
|
+
1
|
|
69
|
+
]), [
|
|
70
|
+
[],
|
|
71
|
+
[
|
|
72
|
+
1
|
|
73
|
+
]
|
|
74
|
+
], "(equalsTwo)([1]) // => [[], [1]]");
|
|
75
|
+
t.end();
|
|
26
76
|
});
|
|
27
|
-
test("partitionWith", function
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
77
|
+
test("partitionWith", function(t) {
|
|
78
|
+
t.deepEqual(partitionWith({
|
|
79
|
+
parentId: is
|
|
80
|
+
})([
|
|
81
|
+
{
|
|
82
|
+
id: 1
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: 2,
|
|
86
|
+
parentId: 1
|
|
87
|
+
}
|
|
88
|
+
]), [
|
|
89
|
+
[
|
|
90
|
+
{
|
|
91
|
+
id: 2,
|
|
92
|
+
parentId: 1
|
|
93
|
+
}
|
|
94
|
+
],
|
|
95
|
+
[
|
|
96
|
+
{
|
|
97
|
+
id: 1
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
], "partitionWith({parentId: is}) // => [[{parentId: 1}], [{id: 1}]]");
|
|
101
|
+
t.end();
|
|
42
102
|
});
|
|
103
|
+
|
|
43
104
|
//# sourceMappingURL=partition.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/partition/partition.test.js"],"
|
|
1
|
+
{"version":3,"sources":["../../src/partition/partition.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { is } from \"../is/is.js\"\nimport { read } from \"../read/read.js\"\nimport { partition, partitionWith } from \"./partition.js\"\n\nconst equalsTwo = x => x === 2\n\ntest(\"partition\", t => {\n t.deepEqual(\n partition(equalsTwo)([2, 2, 1, 1, 2]),\n [\n [2, 2, 2],\n [1, 1],\n ],\n \"(equalsTwo)([2,2,1,1,2]) // => [[2,2,2],[1,1]]\"\n )\n\n t.deepEqual(\n partition(equalsTwo, [2, 2, 1, 1, 2]),\n [\n [2, 2, 2],\n [1, 1],\n ],\n \"(equalsTwo, [2,2,1,1,2]) // => [[2,2,2],[1,1]]\"\n )\n\n t.deepEqual(\n partition([read(\"comments\"), is], [{ id: 1, comments: [] }, { id: 2 }]),\n [[{ id: 1, comments: [] }], [{ id: 2 }]],\n \"(equalsTwo, [2,2,1,1,2]) // => [[2,2,2],[1,1]]\"\n )\n\n t.deepEqual(\n partition(equalsTwo)([1]),\n [[], [1]],\n \"(equalsTwo)([1]) // => [[], [1]]\"\n )\n\n t.end()\n})\n\ntest(\"partitionWith\", t => {\n t.deepEqual(\n partitionWith({\n parentId: is,\n })([{ id: 1 }, { id: 2, parentId: 1 }]),\n [[{ id: 2, parentId: 1 }], [{ id: 1 }]],\n \"partitionWith({parentId: is}) // => [[{parentId: 1}], [{id: 1}]]\"\n )\n\n t.end()\n})\n"],"names":["test","is","read","partition","partitionWith","equalsTwo","x","t","deepEqual","id","comments","end","parentId"],"mappings":"AAAA,MAAM,CAACA,IAAI,MAAM,CAAM;AAEvB,MAAM,GAAGC,EAAE,QAAQ,CAAa;AAChC,MAAM,GAAGC,IAAI,QAAQ,CAAiB;AACtC,MAAM,GAAGC,SAAS,EAAEC,aAAa,QAAQ,CAAgB;AAEzD,GAAK,CAACC,SAAS,GAAGC,QAAQ,CAARA,CAAC;IAAIA,MAAM,CAANA,CAAC,KAAK,CAAC;;AAE9BN,IAAI,CAAC,CAAW,YAAEO,QACjB,CADiBA,CAAC,EAAI,CAAC;IACtBA,CAAC,CAACC,SAAS,CACTL,SAAS,CAACE,SAAS,EAAE,CAAC;AAAA,SAAC;AAAE,SAAC;AAAE,SAAC;AAAE,SAAC;AAAE,SAAC;IAAA,CAAC,GACpC,CAAC;QACC,CAAC;AAAA,aAAC;AAAE,aAAC;AAAE,aAAC;QAAA,CAAC;QACT,CAAC;AAAA,aAAC;AAAE,aAAC;QAAA,CAAC;IACR,CAAC,EACD,CAAgD;IAGlDE,CAAC,CAACC,SAAS,CACTL,SAAS,CAACE,SAAS,EAAE,CAAC;AAAA,SAAC;AAAE,SAAC;AAAE,SAAC;AAAE,SAAC;AAAE,SAAC;IAAA,CAAC,GACpC,CAAC;QACC,CAAC;AAAA,aAAC;AAAE,aAAC;AAAE,aAAC;QAAA,CAAC;QACT,CAAC;AAAA,aAAC;AAAE,aAAC;QAAA,CAAC;IACR,CAAC,EACD,CAAgD;IAGlDE,CAAC,CAACC,SAAS,CACTL,SAAS,CAAC,CAACD;QAAAA,IAAI,CAAC,CAAU;QAAGD,EAAE;IAAA,CAAC,EAAE,CAAC;QAAA,CAAC;YAACQ,EAAE,EAAE,CAAC;YAAEC,QAAQ,EAAE,CAAC,CAAC;QAAC,CAAC;QAAE,CAAC;YAACD,EAAE,EAAE,CAAC;QAAC,CAAC;IAAA,CAAC,GACtE,CAAC;QAAA,CAAC;YAAA,CAAC;gBAACA,EAAE,EAAE,CAAC;gBAAEC,QAAQ,EAAE,CAAC,CAAC;YAAC,CAAC;QAAA,CAAC;QAAE,CAAC;YAAA,CAAC;gBAACD,EAAE,EAAE,CAAC;YAAC,CAAC;QAAA,CAAC;IAAA,CAAC,EACxC,CAAgD;IAGlDF,CAAC,CAACC,SAAS,CACTL,SAAS,CAACE,SAAS,EAAE,CAAC;AAAA,SAAC;IAAA,CAAC,GACxB,CAAC;QAAA,CAAC,CAAC;QAAE,CAAC;AAAA,aAAC;QAAA,CAAC;IAAA,CAAC,EACT,CAAkC;IAGpCE,CAAC,CAACI,GAAG;AACP,CAAC;AAEDX,IAAI,CAAC,CAAe,gBAAEO,QACrB,CADqBA,CAAC,EAAI,CAAC;IAC1BA,CAAC,CAACC,SAAS,CACTJ,aAAa,CAAC,CAAC;QACbQ,QAAQ,EAAEX,EAAE;IACd,CAAC,EAAE,CAAC;QAAA,CAAC;YAACQ,EAAE,EAAE,CAAC;QAAC,CAAC;QAAE,CAAC;YAACA,EAAE,EAAE,CAAC;YAAEG,QAAQ,EAAE,CAAC;QAAC,CAAC;IAAA,CAAC,GACtC,CAAC;QAAA,CAAC;YAAA,CAAC;gBAACH,EAAE,EAAE,CAAC;gBAAEG,QAAQ,EAAE,CAAC;YAAC,CAAC;QAAA,CAAC;QAAE,CAAC;YAAA,CAAC;gBAACH,EAAE,EAAE,CAAC;YAAC,CAAC;QAAA,CAAC;IAAA,CAAC,EACvC,CAAkE;IAGpEF,CAAC,CAACI,GAAG;AACP,CAAC"}
|
package/dist/pick/pick.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
+
import * as swcHelpers from "@swc/helpers";
|
|
1
2
|
/**
|
|
2
3
|
* @param {string} key Field name to extract values from
|
|
3
4
|
* @param {Object[]} input Array of objects
|
|
4
5
|
*
|
|
5
6
|
* @returns {Array}
|
|
6
|
-
*/
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
result
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return result;
|
|
7
|
+
*/ var _pick = function(key, input) {
|
|
8
|
+
var result = [];
|
|
9
|
+
for(var i = 0, length = input.length; i < length; i++){
|
|
10
|
+
result.push(input[i][key]);
|
|
11
|
+
}
|
|
12
|
+
return result;
|
|
15
13
|
};
|
|
16
14
|
/**
|
|
17
15
|
* Returns a new list by extracting the same named property off all objects in
|
|
@@ -27,22 +25,18 @@ var _pick = function _pick(key, input) {
|
|
|
27
25
|
* @example
|
|
28
26
|
* pick("position")([{id: 1, position: 3}, {id:2, position: -1}])
|
|
29
27
|
* // => [3, -1]
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
params
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
};
|
|
43
|
-
} // @signature (key, input)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return _pick.apply(void 0, params);
|
|
28
|
+
*/ export var pick = function() {
|
|
29
|
+
for(var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++){
|
|
30
|
+
params[_key] = arguments[_key];
|
|
31
|
+
}
|
|
32
|
+
// @signature (key) => (input)
|
|
33
|
+
if (params.length <= 1) {
|
|
34
|
+
return function(input) {
|
|
35
|
+
return _pick(params[0], input);
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
// @signature (key, input)
|
|
39
|
+
return _pick.apply(void 0, swcHelpers.toConsumableArray(params));
|
|
47
40
|
};
|
|
41
|
+
|
|
48
42
|
//# sourceMappingURL=pick.js.map
|
package/dist/pick/pick.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/pick/pick.js"],"
|
|
1
|
+
{"version":3,"sources":["../../src/pick/pick.js"],"sourcesContent":["/**\n * @param {string} key Field name to extract values from\n * @param {Object[]} input Array of objects\n *\n * @returns {Array}\n */\nconst _pick = (key, input) => {\n const result = []\n\n for (let i = 0, length = input.length; i < length; i++) {\n result.push(input[i][key])\n }\n\n return result\n}\n\n/**\n * Returns a new list by extracting the same named property off all objects in\n * the source list\n *\n * @param {...any} params\n *\n * @returns {Array}\n *\n * @tag Array\n * @signature (key: string) => (input: object[]): mixed[]\n *\n * @example\n * pick(\"position\")([{id: 1, position: 3}, {id:2, position: -1}])\n * // => [3, -1]\n */\nexport const pick = (...params) => {\n // @signature (key) => (input)\n if (params.length <= 1) {\n return input => _pick(params[0], input)\n }\n\n // @signature (key, input)\n return _pick(...params)\n}\n"],"names":["_pick","key","input","result","i","length","push","pick","params"],"mappings":";AAAA,EAKG,AALH;;;;;CAKG,AALH,EAKG,CACH,GAAK,CAACA,KAAK,GAAG,QAAQ,CAAPC,GAAG,EAAEC,KAAK,EAAK,CAAC;IAC7B,GAAK,CAACC,MAAM,GAAG,CAAC,CAAC;IAEjB,GAAG,CAAE,GAAG,CAACC,CAAC,GAAG,CAAC,EAAEC,MAAM,GAAGH,KAAK,CAACG,MAAM,EAAED,CAAC,GAAGC,MAAM,EAAED,CAAC,GAAI,CAAC;QACvDD,MAAM,CAACG,IAAI,CAACJ,KAAK,CAACE,CAAC,EAAEH,GAAG;IAC1B,CAAC;IAED,MAAM,CAACE,MAAM;AACf,CAAC;AAED,EAcG,AAdH;;;;;;;;;;;;;;CAcG,AAdH,EAcG,CACH,MAAM,CAAC,GAAK,CAACI,IAAI,GAAG,QAAQ,GAAO,CAAC;qCAAZC,MAAM;QAANA,MAAM;;IAC5B,EAA8B,AAA9B,4BAA8B;IAC9B,EAAE,EAAEA,MAAM,CAACH,MAAM,IAAI,CAAC,EAAE,CAAC;QACvB,MAAM,CAACH,QAAQ,CAARA,KAAK;YAAIF,MAAMQ,CAANR,KAAK,CAACQ,MAAM,CAAC,CAAC,GAAGN,KAAK;;IACxC,CAAC;IAED,EAA0B,AAA1B,wBAA0B;IAC1B,MAAM,CAACF,KAAK,CAALA,KAAgB,CAAhBA,IAAI,CAAJA,CAAK,+BAAIQ,MAAM;AACxB,CAAC"}
|
package/dist/pick/pick.test.js
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
import test from "tape";
|
|
2
2
|
import { pick } from "./pick.js";
|
|
3
|
-
test("pick", function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
3
|
+
test("pick", function(t) {
|
|
4
|
+
var input = [
|
|
5
|
+
{
|
|
6
|
+
id: 1,
|
|
7
|
+
position: 3,
|
|
8
|
+
onlyHere: 1
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
id: 2,
|
|
12
|
+
position: -1
|
|
13
|
+
},
|
|
14
|
+
];
|
|
15
|
+
t.deepEqual(pick("position")(input), [
|
|
16
|
+
3,
|
|
17
|
+
-1
|
|
18
|
+
], "Array with extracted field");
|
|
19
|
+
t.deepEqual(pick("onlyHere", input), [
|
|
20
|
+
1,
|
|
21
|
+
undefined
|
|
22
|
+
], "Array with extracted field not available in all source elements");
|
|
23
|
+
t.end();
|
|
15
24
|
});
|
|
25
|
+
|
|
16
26
|
//# sourceMappingURL=pick.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/pick/pick.test.js"],"
|
|
1
|
+
{"version":3,"sources":["../../src/pick/pick.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { pick } from \"./pick.js\"\n\ntest(\"pick\", t => {\n const input = [\n {\n id: 1,\n position: 3,\n onlyHere: 1,\n },\n {\n id: 2,\n position: -1,\n },\n ]\n\n t.deepEqual(pick(\"position\")(input), [3, -1], \"Array with extracted field\")\n\n t.deepEqual(\n pick(\"onlyHere\", input),\n [1, undefined],\n \"Array with extracted field not available in all source elements\"\n )\n\n t.end()\n})\n"],"names":["test","pick","t","input","id","position","onlyHere","deepEqual","undefined","end"],"mappings":"AAAA,MAAM,CAACA,IAAI,MAAM,CAAM;AAEvB,MAAM,GAAGC,IAAI,QAAQ,CAAW;AAEhCD,IAAI,CAAC,CAAM,OAAEE,QACZ,CADYA,CAAC,EAAI,CAAC;IACjB,GAAK,CAACC,KAAK,GAAG,CAAC;QACb,CAAC;YACCC,EAAE,EAAE,CAAC;YACLC,QAAQ,EAAE,CAAC;YACXC,QAAQ,EAAE,CAAC;QACb,CAAC;QACD,CAAC;YACCF,EAAE,EAAE,CAAC;YACLC,QAAQ,GAAG,CAAC;QACd,CAAC;IACH,CAAC;IAEDH,CAAC,CAACK,SAAS,CAACN,IAAI,CAAC,CAAU,WAAEE,KAAK,GAAG,CAAC;AAAA,SAAC;SAAG,CAAC;IAAA,CAAC,EAAE,CAA4B;IAE1ED,CAAC,CAACK,SAAS,CACTN,IAAI,CAAC,CAAU,WAAEE,KAAK,GACtB,CAAC;AAAA,SAAC;QAAEK,SAAS;IAAA,CAAC,EACd,CAAiE;IAGnEN,CAAC,CAACO,GAAG;AACP,CAAC"}
|
package/dist/pipe/pipe.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as swcHelpers from "@swc/helpers";
|
|
1
2
|
/**
|
|
2
3
|
* Performs left-to-right function composition. The leftmost function may have
|
|
3
4
|
* any arity, the remaining functions must be unary.
|
|
@@ -17,20 +18,20 @@
|
|
|
17
18
|
* @example
|
|
18
19
|
* pipe(inc, inc)(2)
|
|
19
20
|
* // => 4
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
restFn[_key - 1] = arguments[_key];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return function () {
|
|
27
|
-
var acc = firstFn.apply(void 0, arguments);
|
|
28
|
-
|
|
29
|
-
for (var index = 0, length = restFn.length; index < length; index++) {
|
|
30
|
-
acc = restFn[index](acc);
|
|
21
|
+
*/ export var pipe = function(firstFn) {
|
|
22
|
+
for(var _len1 = arguments.length, restFn = new Array(_len1 > 1 ? _len1 - 1 : 0), _key1 = 1; _key1 < _len1; _key1++){
|
|
23
|
+
restFn[_key1 - 1] = arguments[_key1];
|
|
31
24
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
return function() {
|
|
26
|
+
for(var _len = arguments.length, input = new Array(_len), _key = 0; _key < _len; _key++){
|
|
27
|
+
input[_key] = arguments[_key];
|
|
28
|
+
}
|
|
29
|
+
var acc = firstFn.apply(void 0, swcHelpers.toConsumableArray(input));
|
|
30
|
+
for(var index = 0, length = restFn.length; index < length; index++){
|
|
31
|
+
acc = restFn[index](acc);
|
|
32
|
+
}
|
|
33
|
+
return acc;
|
|
34
|
+
};
|
|
35
35
|
};
|
|
36
|
+
|
|
36
37
|
//# sourceMappingURL=pipe.js.map
|
package/dist/pipe/pipe.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/pipe/pipe.js"],"
|
|
1
|
+
{"version":3,"sources":["../../src/pipe/pipe.js"],"sourcesContent":["/**\n * Performs left-to-right function composition. The leftmost function may have\n * any arity, the remaining functions must be unary.\n *\n * @param {Function} firstFn First function in transform chain\n * @param {Function[]} restFn Remaining functions\n * @param {Array} input First function arguments\n *\n * @returns {any}\n *\n * @name pipe\n * @tag Core\n * @signature (...fn: Function[]) => (...input: Array): any\n *\n * @see {@link pipeP}\n *\n * @example\n * pipe(inc, inc)(2)\n * // => 4\n */\nexport const pipe =\n (firstFn, ...restFn) =>\n (...input) => {\n let acc = firstFn(...input)\n\n for (let index = 0, length = restFn.length; index < length; index++) {\n acc = restFn[index](acc)\n }\n\n return acc\n }\n"],"names":["pipe","firstFn","restFn","input","acc","index","length"],"mappings":";AAAA,EAmBG,AAnBH;;;;;;;;;;;;;;;;;;;CAmBG,AAnBH,EAmBG,CACH,MAAM,CAAC,GAAK,CAACA,IAAI,GACf,QAAQ,CAAPC,OAAO;sCAAKC,MAAM;QAANA,MAAM;;IACnB,MAAM,CAAN,QAAQ,GAAM,CAAC;yCAAXC,KAAK;YAALA,KAAK;;QACP,GAAG,CAACC,GAAG,GAAGH,OAAO,CAAPA,KAAiB,CAAjBA,IAAI,CAAJA,CAAO,+BAAIE,KAAK;QAE1B,GAAG,CAAE,GAAG,CAACE,KAAK,GAAG,CAAC,EAAEC,MAAM,GAAGJ,MAAM,CAACI,MAAM,EAAED,KAAK,GAAGC,MAAM,EAAED,KAAK,GAAI,CAAC;YACpED,GAAG,GAAGF,MAAM,CAACG,KAAK,EAAED,GAAG;QACzB,CAAC;QAED,MAAM,CAACA,GAAG;IACZ,CAAC"}
|
package/dist/pipe/pipe.test.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import test from "tape";
|
|
2
2
|
import { pipe } from "./pipe.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return input + 1;
|
|
3
|
+
var inc = function(input) {
|
|
4
|
+
return input + 1;
|
|
6
5
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return a + b;
|
|
6
|
+
var sum = function(a, b) {
|
|
7
|
+
return a + b;
|
|
10
8
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
t.end();
|
|
9
|
+
test("pipe", function(t) {
|
|
10
|
+
t.deepEqual(pipe(inc, inc)(2), 4, "first input arity 1");
|
|
11
|
+
t.deepEqual(pipe(sum, inc)(2, 2), 5, "first input arity 2");
|
|
12
|
+
t.end();
|
|
16
13
|
});
|
|
14
|
+
|
|
17
15
|
//# sourceMappingURL=pipe.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/pipe/pipe.test.js"],"
|
|
1
|
+
{"version":3,"sources":["../../src/pipe/pipe.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { pipe } from \"./pipe.js\"\n\nconst inc = input => input + 1\nconst sum = (a, b) => a + b\n\ntest(\"pipe\", t => {\n t.deepEqual(pipe(inc, inc)(2), 4, \"first input arity 1\")\n\n t.deepEqual(pipe(sum, inc)(2, 2), 5, \"first input arity 2\")\n\n t.end()\n})\n"],"names":["test","pipe","inc","input","sum","a","b","t","deepEqual","end"],"mappings":"AAAA,MAAM,CAACA,IAAI,MAAM,CAAM;AAEvB,MAAM,GAAGC,IAAI,QAAQ,CAAW;AAEhC,GAAK,CAACC,GAAG,GAAGC,QAAQ,CAARA,KAAK;IAAIA,MAAM,CAANA,KAAK,GAAG,CAAC;;AAC9B,GAAK,CAACC,GAAG,GAAG,QAAQ,CAAPC,CAAC,EAAEC,CAAC;IAAKD,MACtB,CADsBA,CAAC,GAAGC,CAAC;;AAE3BN,IAAI,CAAC,CAAM,OAAEO,QACZ,CADYA,CAAC,EAAI,CAAC;IACjBA,CAAC,CAACC,SAAS,CAACP,IAAI,CAACC,GAAG,EAAEA,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,CAAqB;IAEvDK,CAAC,CAACC,SAAS,CAACP,IAAI,CAACG,GAAG,EAAEF,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAqB;IAE1DK,CAAC,CAACE,GAAG;AACP,CAAC"}
|
package/dist/pipe-p/pipe-p.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as swcHelpers from "@swc/helpers";
|
|
1
2
|
/**
|
|
2
3
|
* Performs left-to-right function composition. The leftmost function may have
|
|
3
4
|
* any arity, the remaining functions must be unary.
|
|
@@ -23,28 +24,24 @@
|
|
|
23
24
|
* pipeP(incP, inc)(2).then(result => {
|
|
24
25
|
* // => result = 4
|
|
25
26
|
* })
|
|
26
|
-
*/
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
restFn[_key - 1] = arguments[_key];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return function () {
|
|
33
|
-
var acc = Promise.resolve(firstFn.apply(void 0, arguments));
|
|
34
|
-
|
|
35
|
-
var _loop = function _loop(index, length) {
|
|
36
|
-
acc = acc.then(function (result) {
|
|
37
|
-
return restFn[index](result);
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
for (var index = 0, length = restFn.length; index < length; index++) {
|
|
42
|
-
_loop(index, length);
|
|
27
|
+
*/ var pipeP = function(firstFn) {
|
|
28
|
+
for(var _len1 = arguments.length, restFn = new Array(_len1 > 1 ? _len1 - 1 : 0), _key1 = 1; _key1 < _len1; _key1++){
|
|
29
|
+
restFn[_key1 - 1] = arguments[_key1];
|
|
43
30
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
31
|
+
return function() {
|
|
32
|
+
var _loop = function(index, length) {
|
|
33
|
+
acc = acc.then(function(result) {
|
|
34
|
+
return restFn[index](result);
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
for(var _len = arguments.length, input = new Array(_len), _key = 0; _key < _len; _key++){
|
|
38
|
+
input[_key] = arguments[_key];
|
|
39
|
+
}
|
|
40
|
+
var acc = Promise.resolve(firstFn.apply(void 0, swcHelpers.toConsumableArray(input)));
|
|
41
|
+
for(var index = 0, length = restFn.length; index < length; index++)_loop(index, length);
|
|
42
|
+
return acc;
|
|
43
|
+
};
|
|
47
44
|
};
|
|
48
|
-
|
|
49
45
|
export { pipeP };
|
|
46
|
+
|
|
50
47
|
//# sourceMappingURL=pipe-p.js.map
|