@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/dist/split/split.js
CHANGED
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.split = void 0;
|
|
9
|
-
|
|
10
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
11
|
-
|
|
12
|
-
var _split = function _split(separator, source) {
|
|
3
|
+
var _split = function _split(separator, input) {
|
|
13
4
|
if (!(separator instanceof RegExp) && typeof separator !== "string") {
|
|
14
|
-
throw new TypeError("split - invalid 'separator' parameter type '".concat((
|
|
5
|
+
throw new TypeError("split - invalid 'separator' parameter type '".concat(_typeof(separator), "'. 'separator' type should be a String or RegExp."));
|
|
15
6
|
}
|
|
16
7
|
|
|
17
|
-
if (typeof
|
|
18
|
-
throw new TypeError("split - invalid 'source' parameter type '".concat((
|
|
8
|
+
if (typeof input !== "string") {
|
|
9
|
+
throw new TypeError("split - invalid 'source' parameter type '".concat(_typeof(input), "'. 'source' type should be String."));
|
|
19
10
|
}
|
|
20
11
|
|
|
21
|
-
return
|
|
12
|
+
return input.split(separator);
|
|
22
13
|
};
|
|
23
14
|
/**
|
|
24
15
|
* Splits a String object into an array of strings by separating the string
|
|
@@ -26,12 +17,12 @@ var _split = function _split(separator, source) {
|
|
|
26
17
|
* make each split.
|
|
27
18
|
*
|
|
28
19
|
* @tag String
|
|
29
|
-
* @signature (separator: string|RegExp,
|
|
30
|
-
* @signature (separator: string|RegExp) => (
|
|
20
|
+
* @signature (separator: string|RegExp, input:string): Array
|
|
21
|
+
* @signature (separator: string|RegExp) => (input:string): Array
|
|
31
22
|
*
|
|
32
23
|
* @param {...any} params
|
|
33
24
|
* @param {string|RegExp} params.separator Points where each split should occur
|
|
34
|
-
* @param {string} params.
|
|
25
|
+
* @param {string} params.input Input string
|
|
35
26
|
*
|
|
36
27
|
* @returns {Array}
|
|
37
28
|
*
|
|
@@ -41,20 +32,19 @@ var _split = function _split(separator, source) {
|
|
|
41
32
|
*/
|
|
42
33
|
|
|
43
34
|
|
|
44
|
-
var split = function split() {
|
|
35
|
+
export var split = function split() {
|
|
45
36
|
for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
46
37
|
params[_key] = arguments[_key];
|
|
47
38
|
}
|
|
48
39
|
|
|
49
|
-
// @signature (separator) => (
|
|
40
|
+
// @signature (separator) => (input)
|
|
50
41
|
if (params.length <= 1) {
|
|
51
|
-
return function (
|
|
52
|
-
return _split(params[0],
|
|
42
|
+
return function (input) {
|
|
43
|
+
return _split(params[0], input);
|
|
53
44
|
};
|
|
54
|
-
} // @signature (separator,
|
|
45
|
+
} // @signature (separator, input)
|
|
55
46
|
|
|
56
47
|
|
|
57
48
|
return _split.apply(void 0, params);
|
|
58
49
|
};
|
|
59
|
-
|
|
60
|
-
exports.split = split;
|
|
50
|
+
//# sourceMappingURL=split.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/split/split.js"],"names":["_split","separator","input","RegExp","TypeError","split","params","length"],"mappings":";;AAAA,IAAMA,MAAM,GAAG,SAATA,MAAS,CAACC,SAAD,EAAYC,KAAZ,EAAsB;AACnC,MAAI,EAAED,SAAS,YAAYE,MAAvB,KAAkC,OAAOF,SAAP,KAAqB,QAA3D,EAAqE;AACnE,UAAM,IAAIG,SAAJ,+DACkDH,SADlD,wDAAN;AAGD;;AAED,MAAI,OAAOC,KAAP,KAAiB,QAArB,EAA+B;AAC7B,UAAM,IAAIE,SAAJ,4DAC+CF,KAD/C,yCAAN;AAGD;;AAED,SAAOA,KAAK,CAACG,KAAN,CAAYJ,SAAZ,CAAP;AACD,CAdD;AAgBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,IAAMI,KAAK,GAAG,SAARA,KAAQ,GAAe;AAAA,oCAAXC,MAAW;AAAXA,IAAAA,MAAW;AAAA;;AAClC;AACA,MAAIA,MAAM,CAACC,MAAP,IAAiB,CAArB,EAAwB;AACtB,WAAO,UAAAL,KAAK;AAAA,aAAIF,MAAM,CAACM,MAAM,CAAC,CAAD,CAAP,EAAYJ,KAAZ,CAAV;AAAA,KAAZ;AACD,GAJiC,CAMlC;;;AACA,SAAOF,MAAM,MAAN,SAAUM,MAAV,CAAP;AACD,CARM","sourcesContent":["const _split = (separator, input) => {\n if (!(separator instanceof RegExp) && typeof separator !== \"string\") {\n throw new TypeError(\n `split - invalid 'separator' parameter type '${typeof separator}'. 'separator' type should be a String or RegExp.`\n )\n }\n\n if (typeof input !== \"string\") {\n throw new TypeError(\n `split - invalid 'source' parameter type '${typeof input}'. 'source' type should be String.`\n )\n }\n\n return input.split(separator)\n}\n\n/**\n * Splits a String object into an array of strings by separating the string\n * into substrings, using a specified separator string to determine where to\n * make each split.\n *\n * @tag String\n * @signature (separator: string|RegExp, input:string): Array\n * @signature (separator: string|RegExp) => (input:string): Array\n *\n * @param {...any} params\n * @param {string|RegExp} params.separator Points where each split should occur\n * @param {string} params.input Input string\n *\n * @returns {Array}\n *\n * @example\n * split(\",\", \"lorem,ipsum\")\n * // [\"lorem\", \"ipsum\"]\n */\nexport const split = (...params) => {\n // @signature (separator) => (input)\n if (params.length <= 1) {\n return input => _split(params[0], input)\n }\n\n // @signature (separator, input)\n return _split(...params)\n}\n"],"file":"split.js"}
|
package/dist/split/split.test.js
CHANGED
|
@@ -1,60 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
6
|
-
|
|
7
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
8
|
-
|
|
9
|
-
var _riteway = require("riteway");
|
|
10
|
-
|
|
11
|
-
var _split = require("./split");
|
|
12
|
-
|
|
13
1
|
/* eslint-disable new-cap */
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
should: "return array with 3 strings",
|
|
29
|
-
actual: (0, _split.split)(/[,-]/, "foo,bar-lorem"),
|
|
30
|
-
expected: ["foo", "bar", "lorem"]
|
|
31
|
-
});
|
|
32
|
-
assert({
|
|
33
|
-
given: "non-string source",
|
|
34
|
-
should: "throw",
|
|
35
|
-
actual: (0, _riteway.Try)(function () {
|
|
36
|
-
(0, _split.split)(",", [1, 2, 3, 4]);
|
|
37
|
-
}).toString(),
|
|
38
|
-
expected: "TypeError: split - invalid 'source' parameter type 'object'. 'source' type should be String."
|
|
39
|
-
});
|
|
40
|
-
assert({
|
|
41
|
-
given: "non-string, non-regexp separator",
|
|
42
|
-
should: "throw",
|
|
43
|
-
actual: (0, _riteway.Try)(function () {
|
|
44
|
-
(0, _split.split)(2, [1, 2, 3, 4]);
|
|
45
|
-
}).toString(),
|
|
46
|
-
expected: "TypeError: split - invalid 'separator' parameter type 'number'. 'separator' type should be a String or RegExp."
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
case 4:
|
|
50
|
-
case "end":
|
|
51
|
-
return _context.stop();
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}, _callee);
|
|
55
|
-
}));
|
|
56
|
-
|
|
57
|
-
return function (_x) {
|
|
58
|
-
return _ref.apply(this, arguments);
|
|
59
|
-
};
|
|
60
|
-
}());
|
|
2
|
+
import test from "tape";
|
|
3
|
+
import { split } from "./split.js";
|
|
4
|
+
test("split", function (t) {
|
|
5
|
+
t.deepEqual(split(",")("lorem,ipsum"), ["lorem", "ipsum"], "given [string that contains one ',', splitting by it] should [return array with 2 strings]");
|
|
6
|
+
t.deepEqual(split(/[,-]/, "foo,bar-lorem"), ["foo", "bar", "lorem"], "given [string that contains one ',' and one '-', splitting by a RegExp matching both] should [return array with 3 strings]");
|
|
7
|
+
t.throws(function () {
|
|
8
|
+
return split(",", [1, 2, 3, 4]);
|
|
9
|
+
}, "TypeError: split - invalid 'source' parameter type 'object'. 'source' type should be String.", "given [non-string source] shold [throw]");
|
|
10
|
+
t.throws(function () {
|
|
11
|
+
return split(2, [1, 2, 3, 4]);
|
|
12
|
+
}, "TypeError: split - invalid 'separator' parameter type 'number'. 'separator' type should be a String or RegExp.", "given [non-string, non-regexp separator] shold [throw]");
|
|
13
|
+
t.end();
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=split.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/split/split.test.js"],"names":["test","split","t","deepEqual","throws","end"],"mappings":"AAAA;AAEA,OAAOA,IAAP,MAAiB,MAAjB;AAEA,SAASC,KAAT,QAAsB,YAAtB;AAEAD,IAAI,CAAC,OAAD,EAAU,UAAAE,CAAC,EAAI;AACjBA,EAAAA,CAAC,CAACC,SAAF,CACEF,KAAK,CAAC,GAAD,CAAL,CAAW,aAAX,CADF,EAEE,CAAC,OAAD,EAAU,OAAV,CAFF,EAGE,4FAHF;AAMAC,EAAAA,CAAC,CAACC,SAAF,CACEF,KAAK,CAAC,MAAD,EAAS,eAAT,CADP,EAEE,CAAC,KAAD,EAAQ,KAAR,EAAe,OAAf,CAFF,EAGE,4HAHF;AAMAC,EAAAA,CAAC,CAACE,MAAF,CACE;AAAA,WAAMH,KAAK,CAAC,GAAD,EAAM,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CAAN,CAAX;AAAA,GADF,EAEE,8FAFF,EAGE,yCAHF;AAMAC,EAAAA,CAAC,CAACE,MAAF,CACE;AAAA,WAAMH,KAAK,CAAC,CAAD,EAAI,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CAAJ,CAAX;AAAA,GADF,EAEE,gHAFF,EAGE,wDAHF;AAMAC,EAAAA,CAAC,CAACG,GAAF;AACD,CA1BG,CAAJ","sourcesContent":["/* eslint-disable new-cap */\n\nimport test from \"tape\"\n\nimport { split } from \"./split.js\"\n\ntest(\"split\", t => {\n t.deepEqual(\n split(\",\")(\"lorem,ipsum\"),\n [\"lorem\", \"ipsum\"],\n \"given [string that contains one ',', splitting by it] should [return array with 2 strings]\"\n )\n\n t.deepEqual(\n split(/[,-]/, \"foo,bar-lorem\"),\n [\"foo\", \"bar\", \"lorem\"],\n \"given [string that contains one ',' and one '-', splitting by a RegExp matching both] should [return array with 3 strings]\"\n )\n\n t.throws(\n () => split(\",\", [1, 2, 3, 4]),\n \"TypeError: split - invalid 'source' parameter type 'object'. 'source' type should be String.\",\n \"given [non-string source] shold [throw]\"\n )\n\n t.throws(\n () => split(2, [1, 2, 3, 4]),\n \"TypeError: split - invalid 'separator' parameter type 'number'. 'separator' type should be a String or RegExp.\",\n \"given [non-string, non-regexp separator] shold [throw]\"\n )\n\n t.end()\n})\n"],"file":"split.test.js"}
|
|
@@ -1,30 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.splitInGroupsOf = void 0;
|
|
9
|
-
|
|
10
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
11
|
-
|
|
12
|
-
var _splitInGroupsOf = function _splitInGroupsOf(size, source) {
|
|
3
|
+
var _splitInGroupsOf = function _splitInGroupsOf(size, input) {
|
|
13
4
|
if (size <= 0) {
|
|
14
5
|
throw new Error("splitInGroupsOf - invalid 'size' parameter value '".concat(size, "'. 'size' value should be a positive, non-zero, integer."));
|
|
15
6
|
}
|
|
16
7
|
|
|
17
|
-
if (!Array.isArray(
|
|
18
|
-
throw new TypeError("splitInGroupsOf - invalid 'source' parameter type '".concat((
|
|
8
|
+
if (!Array.isArray(input)) {
|
|
9
|
+
throw new TypeError("splitInGroupsOf - invalid 'source' parameter type '".concat(_typeof(input), "'. 'source' type should be Array."));
|
|
19
10
|
}
|
|
20
11
|
|
|
21
12
|
var result = [];
|
|
22
|
-
var groupCount = Math.ceil(
|
|
13
|
+
var groupCount = Math.ceil(input.length / size);
|
|
23
14
|
|
|
24
15
|
for (var i = 0; i < groupCount; ++i) {
|
|
25
16
|
var startIndex = i * size;
|
|
26
17
|
var endIndex = (i + 1) * size;
|
|
27
|
-
result.push(
|
|
18
|
+
result.push(input.slice(startIndex, endIndex));
|
|
28
19
|
}
|
|
29
20
|
|
|
30
21
|
return result;
|
|
@@ -48,20 +39,19 @@ var _splitInGroupsOf = function _splitInGroupsOf(size, source) {
|
|
|
48
39
|
*/
|
|
49
40
|
|
|
50
41
|
|
|
51
|
-
var splitInGroupsOf = function splitInGroupsOf() {
|
|
42
|
+
export var splitInGroupsOf = function splitInGroupsOf() {
|
|
52
43
|
for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
53
44
|
params[_key] = arguments[_key];
|
|
54
45
|
}
|
|
55
46
|
|
|
56
47
|
// @signature (size) => (source)
|
|
57
48
|
if (params.length <= 1) {
|
|
58
|
-
return function (
|
|
59
|
-
return _splitInGroupsOf(params[0],
|
|
49
|
+
return function (input) {
|
|
50
|
+
return _splitInGroupsOf(params[0], input);
|
|
60
51
|
};
|
|
61
52
|
} // @signature (size, source)
|
|
62
53
|
|
|
63
54
|
|
|
64
55
|
return _splitInGroupsOf.apply(void 0, params);
|
|
65
56
|
};
|
|
66
|
-
|
|
67
|
-
exports.splitInGroupsOf = splitInGroupsOf;
|
|
57
|
+
//# sourceMappingURL=split-in-groups-of.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/split-in-groups-of/split-in-groups-of.js"],"names":["_splitInGroupsOf","size","input","Error","Array","isArray","TypeError","result","groupCount","Math","ceil","length","i","startIndex","endIndex","push","slice","splitInGroupsOf","params"],"mappings":";;AAAA,IAAMA,gBAAgB,GAAG,SAAnBA,gBAAmB,CAACC,IAAD,EAAOC,KAAP,EAAiB;AACxC,MAAID,IAAI,IAAI,CAAZ,EAAe;AACb,UAAM,IAAIE,KAAJ,6DACiDF,IADjD,8DAAN;AAGD;;AAED,MAAI,CAACG,KAAK,CAACC,OAAN,CAAcH,KAAd,CAAL,EAA2B;AACzB,UAAM,IAAII,SAAJ,sEACyDJ,KADzD,wCAAN;AAGD;;AAED,MAAMK,MAAM,GAAG,EAAf;AACA,MAAMC,UAAU,GAAGC,IAAI,CAACC,IAAL,CAAUR,KAAK,CAACS,MAAN,GAAeV,IAAzB,CAAnB;;AAEA,OAAK,IAAIW,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGJ,UAApB,EAAgC,EAAEI,CAAlC,EAAqC;AACnC,QAAMC,UAAU,GAAGD,CAAC,GAAGX,IAAvB;AACA,QAAMa,QAAQ,GAAG,CAACF,CAAC,GAAG,CAAL,IAAUX,IAA3B;AAEAM,IAAAA,MAAM,CAACQ,IAAP,CAAYb,KAAK,CAACc,KAAN,CAAYH,UAAZ,EAAwBC,QAAxB,CAAZ;AACD;;AAED,SAAOP,MAAP;AACD,CAxBD;AA0BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,IAAMU,eAAe,GAAG,SAAlBA,eAAkB,GAAe;AAAA,oCAAXC,MAAW;AAAXA,IAAAA,MAAW;AAAA;;AAC5C;AACA,MAAIA,MAAM,CAACP,MAAP,IAAiB,CAArB,EAAwB;AACtB,WAAO,UAAAT,KAAK;AAAA,aAAIF,gBAAgB,CAACkB,MAAM,CAAC,CAAD,CAAP,EAAYhB,KAAZ,CAApB;AAAA,KAAZ;AACD,GAJ2C,CAM5C;;;AACA,SAAOF,gBAAgB,MAAhB,SAAoBkB,MAApB,CAAP;AACD,CARM","sourcesContent":["const _splitInGroupsOf = (size, input) => {\n if (size <= 0) {\n throw new Error(\n `splitInGroupsOf - invalid 'size' parameter value '${size}'. 'size' value should be a positive, non-zero, integer.`\n )\n }\n\n if (!Array.isArray(input)) {\n throw new TypeError(\n `splitInGroupsOf - invalid 'source' parameter type '${typeof input}'. 'source' type should be Array.`\n )\n }\n\n const result = []\n const groupCount = Math.ceil(input.length / size)\n\n for (let i = 0; i < groupCount; ++i) {\n const startIndex = i * size\n const endIndex = (i + 1) * size\n\n result.push(input.slice(startIndex, endIndex))\n }\n\n return result\n}\n\n/**\n * Split an array into multiple arrays of set size\n *\n * @tag Array\n * @signature (size: number, source: Array): Array\n * @signature (size: number) => (source: Array): Array\n *\n * @param {...any} params\n * @param {number} params.size\n * @param {Array} params.source\n *\n * @returns {Array[]}\n *\n * @example\n * split(2, [1, 2, 3, 4])\n * // [[1, 2], [3, 4]]\n */\nexport const splitInGroupsOf = (...params) => {\n // @signature (size) => (source)\n if (params.length <= 1) {\n return input => _splitInGroupsOf(params[0], input)\n }\n\n // @signature (size, source)\n return _splitInGroupsOf(...params)\n}\n"],"file":"split-in-groups-of.js"}
|
|
@@ -1,78 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
6
|
-
|
|
7
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
8
|
-
|
|
9
|
-
var _riteway = require("riteway");
|
|
10
|
-
|
|
11
|
-
var _splitInGroupsOf = require("./split-in-groups-of");
|
|
12
|
-
|
|
13
1
|
/* eslint-disable new-cap */
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
});
|
|
32
|
-
assert({
|
|
33
|
-
given: "array of size 4, split by size 4",
|
|
34
|
-
should: "return array with 1 sub-array, one of size 4",
|
|
35
|
-
actual: (0, _splitInGroupsOf.splitInGroupsOf)(4, [1, 2, 3, 4]),
|
|
36
|
-
expected: [[1, 2, 3, 4]]
|
|
37
|
-
});
|
|
38
|
-
assert({
|
|
39
|
-
given: "array of size 4, split by size 10",
|
|
40
|
-
should: "return array with 1 sub-array, one of size 4",
|
|
41
|
-
actual: (0, _splitInGroupsOf.splitInGroupsOf)(4, [1, 2, 3, 4]),
|
|
42
|
-
expected: [[1, 2, 3, 4]]
|
|
43
|
-
});
|
|
44
|
-
assert({
|
|
45
|
-
given: "array of size 4, split by size 10",
|
|
46
|
-
should: "return array with 1 sub-array, one of size 4",
|
|
47
|
-
actual: (0, _splitInGroupsOf.splitInGroupsOf)(4, [1, 2, 3, 4]),
|
|
48
|
-
expected: [[1, 2, 3, 4]]
|
|
49
|
-
});
|
|
50
|
-
assert({
|
|
51
|
-
given: "array of size 4, split by size 0",
|
|
52
|
-
should: "throw",
|
|
53
|
-
actual: (0, _riteway.Try)(function () {
|
|
54
|
-
(0, _splitInGroupsOf.splitInGroupsOf)(0, [1, 2, 3, 4]);
|
|
55
|
-
}).toString(),
|
|
56
|
-
expected: "Error: splitInGroupsOf - invalid 'size' parameter value '0'. 'size' value should be a positive, non-zero, integer."
|
|
57
|
-
});
|
|
58
|
-
assert({
|
|
59
|
-
given: "non-array source",
|
|
60
|
-
should: "throw",
|
|
61
|
-
actual: (0, _riteway.Try)(function () {
|
|
62
|
-
(0, _splitInGroupsOf.splitInGroupsOf)(2, 2);
|
|
63
|
-
}).toString(),
|
|
64
|
-
expected: "TypeError: splitInGroupsOf - invalid 'source' parameter type 'number'. 'source' type should be Array."
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
case 7:
|
|
68
|
-
case "end":
|
|
69
|
-
return _context.stop();
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}, _callee);
|
|
73
|
-
}));
|
|
74
|
-
|
|
75
|
-
return function (_x) {
|
|
76
|
-
return _ref.apply(this, arguments);
|
|
77
|
-
};
|
|
78
|
-
}());
|
|
2
|
+
import test from "tape";
|
|
3
|
+
import { splitInGroupsOf } from "./split-in-groups-of.js";
|
|
4
|
+
test("splitInGroupsOf", function (t) {
|
|
5
|
+
t.deepEqual(splitInGroupsOf(2)([1, 2, 3, 4]), [[1, 2], [3, 4]], "given [array of size 4, split by size 2] should [return array with 2 sub-arrays, both of size 2]");
|
|
6
|
+
t.deepEqual(splitInGroupsOf(3, [1, 2, 3, 4]), [[1, 2, 3], [4]], "given [array of size 4, split by size 3] should [return array with 2 sub-arrays, one of size 3, other of size 1]");
|
|
7
|
+
t.deepEqual(splitInGroupsOf(4, [1, 2, 3, 4]), [[1, 2, 3, 4]], "given [array of size 4, split by size 4] should [return array with 1 sub-array, one of size 4]");
|
|
8
|
+
t.deepEqual(splitInGroupsOf(4, [1, 2, 3, 4]), [[1, 2, 3, 4]], "given [array of size 4, split by size 10] should [return array with 1 sub-array, one of size 4]");
|
|
9
|
+
t.deepEqual(splitInGroupsOf(4, [1, 2, 3, 4]), [[1, 2, 3, 4]], "given [array of size 4, split by size 10] should [return array with 1 sub-array, one of size 4]");
|
|
10
|
+
t.throws(function () {
|
|
11
|
+
return splitInGroupsOf(0, [1, 2, 3, 4]);
|
|
12
|
+
}, "Error: splitInGroupsOf - invalid 'size' parameter value '0'. 'size' value should be a positive, non-zero, integer.", "given [array of size 4, split by size 0] shold [throw]");
|
|
13
|
+
t.throws(function () {
|
|
14
|
+
return splitInGroupsOf(2, 2);
|
|
15
|
+
}, "TypeError: splitInGroupsOf - invalid 'source' parameter type 'number'. 'source' type should be Array.", "given [non-array source] shold [throw]");
|
|
16
|
+
t.end();
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=split-in-groups-of.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/split-in-groups-of/split-in-groups-of.test.js"],"names":["test","splitInGroupsOf","t","deepEqual","throws","end"],"mappings":"AAAA;AAEA,OAAOA,IAAP,MAAiB,MAAjB;AAEA,SAASC,eAAT,QAAgC,yBAAhC;AAEAD,IAAI,CAAC,iBAAD,EAAoB,UAAAE,CAAC,EAAI;AAC3BA,EAAAA,CAAC,CAACC,SAAF,CACEF,eAAe,CAAC,CAAD,CAAf,CAAmB,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CAAnB,CADF,EAEE,CACE,CAAC,CAAD,EAAI,CAAJ,CADF,EAEE,CAAC,CAAD,EAAI,CAAJ,CAFF,CAFF,EAME,kGANF;AASAC,EAAAA,CAAC,CAACC,SAAF,CACEF,eAAe,CAAC,CAAD,EAAI,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CAAJ,CADjB,EAEE,CAAC,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAAD,EAAY,CAAC,CAAD,CAAZ,CAFF,EAGE,kHAHF;AAMAC,EAAAA,CAAC,CAACC,SAAF,CACEF,eAAe,CAAC,CAAD,EAAI,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CAAJ,CADjB,EAEE,CAAC,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CAAD,CAFF,EAGE,gGAHF;AAMAC,EAAAA,CAAC,CAACC,SAAF,CACEF,eAAe,CAAC,CAAD,EAAI,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CAAJ,CADjB,EAEE,CAAC,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CAAD,CAFF,EAGE,iGAHF;AAMAC,EAAAA,CAAC,CAACC,SAAF,CACEF,eAAe,CAAC,CAAD,EAAI,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CAAJ,CADjB,EAEE,CAAC,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CAAD,CAFF,EAGE,iGAHF;AAMAC,EAAAA,CAAC,CAACE,MAAF,CACE;AAAA,WAAMH,eAAe,CAAC,CAAD,EAAI,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CAAJ,CAArB;AAAA,GADF,EAEE,oHAFF,EAGE,wDAHF;AAMAC,EAAAA,CAAC,CAACE,MAAF,CACE;AAAA,WAAMH,eAAe,CAAC,CAAD,EAAI,CAAJ,CAArB;AAAA,GADF,EAEE,uGAFF,EAGE,wCAHF;AAMAC,EAAAA,CAAC,CAACG,GAAF;AACD,CA/CG,CAAJ","sourcesContent":["/* eslint-disable new-cap */\n\nimport test from \"tape\"\n\nimport { splitInGroupsOf } from \"./split-in-groups-of.js\"\n\ntest(\"splitInGroupsOf\", t => {\n t.deepEqual(\n splitInGroupsOf(2)([1, 2, 3, 4]),\n [\n [1, 2],\n [3, 4],\n ],\n \"given [array of size 4, split by size 2] should [return array with 2 sub-arrays, both of size 2]\"\n )\n\n t.deepEqual(\n splitInGroupsOf(3, [1, 2, 3, 4]),\n [[1, 2, 3], [4]],\n \"given [array of size 4, split by size 3] should [return array with 2 sub-arrays, one of size 3, other of size 1]\"\n )\n\n t.deepEqual(\n splitInGroupsOf(4, [1, 2, 3, 4]),\n [[1, 2, 3, 4]],\n \"given [array of size 4, split by size 4] should [return array with 1 sub-array, one of size 4]\"\n )\n\n t.deepEqual(\n splitInGroupsOf(4, [1, 2, 3, 4]),\n [[1, 2, 3, 4]],\n \"given [array of size 4, split by size 10] should [return array with 1 sub-array, one of size 4]\"\n )\n\n t.deepEqual(\n splitInGroupsOf(4, [1, 2, 3, 4]),\n [[1, 2, 3, 4]],\n \"given [array of size 4, split by size 10] should [return array with 1 sub-array, one of size 4]\"\n )\n\n t.throws(\n () => splitInGroupsOf(0, [1, 2, 3, 4]),\n \"Error: splitInGroupsOf - invalid 'size' parameter value '0'. 'size' value should be a positive, non-zero, integer.\",\n \"given [array of size 4, split by size 0] shold [throw]\"\n )\n\n t.throws(\n () => splitInGroupsOf(2, 2),\n \"TypeError: splitInGroupsOf - invalid 'source' parameter type 'number'. 'source' type should be Array.\",\n \"given [non-array source] shold [throw]\"\n )\n\n t.end()\n})\n"],"file":"split-in-groups-of.test.js"}
|
package/dist/spy/spy.js
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.spy = void 0;
|
|
7
|
-
|
|
8
|
-
var _is = require("../is/is");
|
|
9
|
-
|
|
1
|
+
import { is } from "../is/is.js";
|
|
10
2
|
/**
|
|
11
3
|
* Proxy input and print to console.log. Useful for debugging pipe chains.
|
|
12
4
|
*
|
|
@@ -21,7 +13,8 @@ var _is = require("../is/is");
|
|
|
21
13
|
*
|
|
22
14
|
* @example
|
|
23
15
|
*/
|
|
24
|
-
|
|
16
|
+
|
|
17
|
+
export var spy = function spy() {
|
|
25
18
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
26
19
|
return function () {
|
|
27
20
|
if (arguments.length > 1) {
|
|
@@ -31,7 +24,7 @@ var spy = function spy() {
|
|
|
31
24
|
var _props$description = props.description,
|
|
32
25
|
description = _props$description === void 0 ? "@asd14/m/spy" : _props$description,
|
|
33
26
|
transform = props.transform;
|
|
34
|
-
var spyValue =
|
|
27
|
+
var spyValue = is(transform) ? transform(arguments.length <= 0 ? undefined : arguments[0]) : arguments.length <= 0 ? undefined : arguments[0];
|
|
35
28
|
console.log();
|
|
36
29
|
console.log("// ".concat(description));
|
|
37
30
|
console.log();
|
|
@@ -42,5 +35,4 @@ var spy = function spy() {
|
|
|
42
35
|
return arguments.length <= 0 ? undefined : arguments[0];
|
|
43
36
|
};
|
|
44
37
|
};
|
|
45
|
-
|
|
46
|
-
exports.spy = spy;
|
|
38
|
+
//# sourceMappingURL=spy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/spy/spy.js"],"names":["is","spy","props","length","Error","description","transform","spyValue","console","log","JSON","stringify"],"mappings":"AAAA,SAASA,EAAT,QAAmB,aAAnB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,IAAMC,GAAG,GACd,SADWA,GACX;AAAA,MAACC,KAAD,uEAAS,EAAT;AAAA,SACA,YAAc;AACZ,QAAI,UAAMC,MAAN,GAAe,CAAnB,EAAsB;AACpB,YAAM,IAAIC,KAAJ,wEAC4D,UAAMD,MADlE,EAAN;AAGD;;AAED,6BAAoDD,KAApD,CAAQG,WAAR;AAAA,QAAQA,WAAR,mCAAsB,cAAtB;AAAA,QAAsCC,SAAtC,GAAoDJ,KAApD,CAAsCI,SAAtC;AAEA,QAAMC,QAAQ,GAAGP,EAAE,CAACM,SAAD,CAAF,GAAgBA,SAAS,kDAAzB,mDAAjB;AAEAE,IAAAA,OAAO,CAACC,GAAR;AACAD,IAAAA,OAAO,CAACC,GAAR,cAAkBJ,WAAlB;AACAG,IAAAA,OAAO,CAACC,GAAR;AAEA;;AACAD,IAAAA,OAAO,CAACC,GAAR,CAAYC,IAAI,CAACC,SAAL,CAAeJ,QAAf,EAAyB,IAAzB,EAA+B,CAA/B,CAAZ,EAhBY,CAkBZ;;AACA;AACD,GArBD;AAAA,CADK","sourcesContent":["import { is } from \"../is/is.js\"\n\n/**\n * Proxy input and print to console.log. Useful for debugging pipe chains.\n *\n * @param {Object} props\n * @param {any} source\n *\n * @returns {any}\n *\n * @name spy\n * @tag Other\n * @signature (...props: any) => (source: any): any\n *\n * @example\n */\nexport const spy =\n (props = {}) =>\n (...input) => {\n if (input.length > 1) {\n throw new Error(\n `@asd14/m/spy - Can only be called with 1 parameter, received ${input.length}`\n )\n }\n\n const { description = \"@asd14/m/spy\", transform } = props\n\n const spyValue = is(transform) ? transform(input[0]) : input[0]\n\n console.log()\n console.log(`// ${description}`)\n console.log()\n\n /* eslint-disable unicorn/no-null */\n console.log(JSON.stringify(spyValue, null, 2))\n\n // Make sure we're just proxying input\n return input[0]\n }\n"],"file":"spy.js"}
|
package/dist/spy/spy.test.js
CHANGED
|
@@ -1,20 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
6
|
-
|
|
7
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
8
|
-
|
|
9
|
-
var _riteway = require("riteway");
|
|
10
|
-
|
|
11
|
-
var _pipe = require("../pipe/pipe");
|
|
12
|
-
|
|
13
|
-
var _top = require("../top/top");
|
|
14
|
-
|
|
15
|
-
var _spy = require("./spy");
|
|
16
|
-
|
|
17
1
|
/* eslint-disable new-cap */
|
|
2
|
+
import test from "tape";
|
|
3
|
+
import { pipe } from "../pipe/pipe.js";
|
|
4
|
+
import { top } from "../top/top.js";
|
|
5
|
+
import { spy } from "./spy.js";
|
|
18
6
|
var example = [{
|
|
19
7
|
id: 1
|
|
20
8
|
}, {
|
|
@@ -22,57 +10,24 @@ var example = [{
|
|
|
22
10
|
}, {
|
|
23
11
|
id: "uuid"
|
|
24
12
|
}];
|
|
25
|
-
(
|
|
26
|
-
|
|
27
|
-
return
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
});
|
|
47
|
-
assert({
|
|
48
|
-
given: "slicing and transformations",
|
|
49
|
-
should: "return initial source value",
|
|
50
|
-
actual: (0, _pipe.pipe)((0, _spy.spy)({
|
|
51
|
-
description: "First 2 items",
|
|
52
|
-
transform: (0, _top.top)(2)
|
|
53
|
-
}), function (source) {
|
|
54
|
-
return source;
|
|
55
|
-
})(example),
|
|
56
|
-
expected: example
|
|
57
|
-
});
|
|
58
|
-
assert({
|
|
59
|
-
given: "multiple parameters when calling pipe",
|
|
60
|
-
should: "throw since we cant proxy multiple values",
|
|
61
|
-
actual: (0, _riteway.Try)((0, _pipe.pipe)((0, _spy.spy)("test"), function (source) {
|
|
62
|
-
return source;
|
|
63
|
-
}), 2, 3).toString(),
|
|
64
|
-
expected: "Error: @asd14/m/spy - Can only be called with 1 parameter, received 2"
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
case 4:
|
|
68
|
-
case "end":
|
|
69
|
-
return _context.stop();
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}, _callee);
|
|
73
|
-
}));
|
|
74
|
-
|
|
75
|
-
return function (_x) {
|
|
76
|
-
return _ref.apply(this, arguments);
|
|
77
|
-
};
|
|
78
|
-
}());
|
|
13
|
+
test("spy", function (t) {
|
|
14
|
+
t.deepEqual(pipe(spy(), function (input) {
|
|
15
|
+
return input;
|
|
16
|
+
})(2), 2, "given [no arguments pipe] should [return initial source value]");
|
|
17
|
+
t.deepEqual(pipe(spy("test"), function (input) {
|
|
18
|
+
return input;
|
|
19
|
+
})(2), 2, "given [unary pipe] should [return initial source value]");
|
|
20
|
+
t.deepEqual(pipe(spy({
|
|
21
|
+
description: "First 2 items",
|
|
22
|
+
transform: top(2)
|
|
23
|
+
}), function (input) {
|
|
24
|
+
return input;
|
|
25
|
+
})(example), example, "given [slicing and transformations] should [return initial source value]");
|
|
26
|
+
t.throws(function () {
|
|
27
|
+
return pipe(spy("test"), function (input) {
|
|
28
|
+
return input;
|
|
29
|
+
})(2, 3);
|
|
30
|
+
}, "Error: @asd14/m/spy - Can only be called with 1 parameter, received 2", "given [multiple parameters when calling pipe] shold [throw since we cant proxy multiple values]");
|
|
31
|
+
t.end();
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=spy.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/spy/spy.test.js"],"names":["test","pipe","top","spy","example","id","t","deepEqual","input","description","transform","throws","end"],"mappings":"AAAA;AAEA,OAAOA,IAAP,MAAiB,MAAjB;AAEA,SAASC,IAAT,QAAqB,iBAArB;AACA,SAASC,GAAT,QAAoB,eAApB;AACA,SAASC,GAAT,QAAoB,UAApB;AAEA,IAAMC,OAAO,GAAG,CAAC;AAAEC,EAAAA,EAAE,EAAE;AAAN,CAAD,EAAY;AAAEA,EAAAA,EAAE,EAAE;AAAN,CAAZ,EAAuB;AAAEA,EAAAA,EAAE,EAAE;AAAN,CAAvB,CAAhB;AAEAL,IAAI,CAAC,KAAD,EAAQ,UAAAM,CAAC,EAAI;AACfA,EAAAA,CAAC,CAACC,SAAF,CACEN,IAAI,CAACE,GAAG,EAAJ,EAAQ,UAAAK,KAAK;AAAA,WAAIA,KAAJ;AAAA,GAAb,CAAJ,CAA4B,CAA5B,CADF,EAEE,CAFF,EAGE,gEAHF;AAMAF,EAAAA,CAAC,CAACC,SAAF,CACEN,IAAI,CAACE,GAAG,CAAC,MAAD,CAAJ,EAAc,UAAAK,KAAK;AAAA,WAAIA,KAAJ;AAAA,GAAnB,CAAJ,CAAkC,CAAlC,CADF,EAEE,CAFF,EAGE,yDAHF;AAMAF,EAAAA,CAAC,CAACC,SAAF,CACEN,IAAI,CACFE,GAAG,CAAC;AACFM,IAAAA,WAAW,EAAE,eADX;AAEFC,IAAAA,SAAS,EAAER,GAAG,CAAC,CAAD;AAFZ,GAAD,CADD,EAKF,UAAAM,KAAK;AAAA,WAAIA,KAAJ;AAAA,GALH,CAAJ,CAMEJ,OANF,CADF,EAQEA,OARF,EASE,0EATF;AAYAE,EAAAA,CAAC,CAACK,MAAF,CACE;AAAA,WAAMV,IAAI,CAACE,GAAG,CAAC,MAAD,CAAJ,EAAc,UAAAK,KAAK;AAAA,aAAIA,KAAJ;AAAA,KAAnB,CAAJ,CAAkC,CAAlC,EAAqC,CAArC,CAAN;AAAA,GADF,EAEE,uEAFF,EAGE,iGAHF;AAMAF,EAAAA,CAAC,CAACM,GAAF;AACD,CAhCG,CAAJ","sourcesContent":["/* eslint-disable new-cap */\n\nimport test from \"tape\"\n\nimport { pipe } from \"../pipe/pipe.js\"\nimport { top } from \"../top/top.js\"\nimport { spy } from \"./spy.js\"\n\nconst example = [{ id: 1 }, { id: 2 }, { id: \"uuid\" }]\n\ntest(\"spy\", t => {\n t.deepEqual(\n pipe(spy(), input => input)(2),\n 2,\n \"given [no arguments pipe] should [return initial source value]\"\n )\n\n t.deepEqual(\n pipe(spy(\"test\"), input => input)(2),\n 2,\n \"given [unary pipe] should [return initial source value]\"\n )\n\n t.deepEqual(\n pipe(\n spy({\n description: \"First 2 items\",\n transform: top(2),\n }),\n input => input\n )(example),\n example,\n \"given [slicing and transformations] should [return initial source value]\"\n )\n\n t.throws(\n () => pipe(spy(\"test\"), input => input)(2, 3),\n \"Error: @asd14/m/spy - Can only be called with 1 parameter, received 2\",\n \"given [multiple parameters when calling pipe] shold [throw since we cant proxy multiple values]\"\n )\n\n t.end()\n})\n"],"file":"spy.test.js"}
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { curry } from "../curry/curry.js";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.startsWith = void 0;
|
|
7
|
-
|
|
8
|
-
var _curry = require("../curry/curry");
|
|
9
|
-
|
|
10
|
-
var _startsWith = function _startsWith(search, source) {
|
|
11
|
-
var searchPosition = source.indexOf(search);
|
|
3
|
+
var _startsWith = function _startsWith(search, input) {
|
|
4
|
+
var searchPosition = input.indexOf(search);
|
|
12
5
|
|
|
13
6
|
if (searchPosition === -1) {
|
|
14
7
|
return false;
|
|
@@ -40,5 +33,5 @@ var _startsWith = function _startsWith(search, source) {
|
|
|
40
33
|
*/
|
|
41
34
|
|
|
42
35
|
|
|
43
|
-
var startsWith =
|
|
44
|
-
|
|
36
|
+
export var startsWith = curry(_startsWith);
|
|
37
|
+
//# sourceMappingURL=starts-with.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/starts-with/starts-with.js"],"names":["curry","_startsWith","search","input","searchPosition","indexOf","startsWith"],"mappings":"AAAA,SAASA,KAAT,QAAsB,mBAAtB;;AAEA,IAAMC,WAAW,GAAG,SAAdA,WAAc,CAACC,MAAD,EAASC,KAAT,EAAmB;AACrC,MAAMC,cAAc,GAAGD,KAAK,CAACE,OAAN,CAAcH,MAAd,CAAvB;;AAEA,MAAIE,cAAc,KAAK,CAAC,CAAxB,EAA2B;AACzB,WAAO,KAAP;AACD;;AAED,SAAOA,cAAc,KAAK,CAA1B;AACD,CARD;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,IAAME,UAAU,GAAGN,KAAK,CAACC,WAAD,CAAxB","sourcesContent":["import { curry } from \"../curry/curry.js\"\n\nconst _startsWith = (search, input) => {\n const searchPosition = input.indexOf(search)\n\n if (searchPosition === -1) {\n return false\n }\n\n return searchPosition === 0\n}\n\n/**\n * Test if string starts with substring\n *\n * @param {string|any} search\n * @param {string|array} source\n *\n * @returns {boolean}\n *\n * @name startsWith\n * @tag String\n * @signature (search: string|any) => (source: string|Array): boolean\n *\n * @example\n * startsWith(\"lorem\", \"lorem ipsum\")\n * // => true\n *\n * startsWith(\"lorem\", [\"lorem\", \"ipsum\"])\n * // => true\n *\n * startsWith(\"dolor\")(\"lorem ipsum\")\n * // false\n */\nexport const startsWith = curry(_startsWith)\n"],"file":"starts-with.js"}
|
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
(
|
|
10
|
-
t.equals((0, _startsWith.startsWith)("lorem", "lorem ipsum"), true, "Source string starts with search string (uncurried)");
|
|
11
|
-
t.equals((0, _startsWith.startsWith)("lorem")("lorem ipsum"), true, "Source string starts with search string (curried)");
|
|
12
|
-
t.equals((0, _startsWith.startsWith)("ipsum")("lorem ipsum"), false, "Search string exists but not at starting");
|
|
13
|
-
t.equals((0, _startsWith.startsWith)("lorem ipsum dolor")("lorem ipsum"), false, "Search string is longer than source string");
|
|
14
|
-
t.equals((0, _startsWith.startsWith)("asd")("lorem ipsum"), false, "Search string does not exist in source");
|
|
15
|
-
t.equals((0, _startsWith.startsWith)("lorem")(["lorem", "ipsum"]), true, "Search item inside array");
|
|
1
|
+
import test from "tape";
|
|
2
|
+
import { startsWith } from "./starts-with.js";
|
|
3
|
+
test("startsWith", function (t) {
|
|
4
|
+
t.equals(startsWith("lorem", "lorem ipsum"), true, "Source string starts with search string (uncurried)");
|
|
5
|
+
t.equals(startsWith("lorem")("lorem ipsum"), true, "Source string starts with search string (curried)");
|
|
6
|
+
t.equals(startsWith("ipsum")("lorem ipsum"), false, "Search string exists but not at starting");
|
|
7
|
+
t.equals(startsWith("lorem ipsum dolor")("lorem ipsum"), false, "Search string is longer than source string");
|
|
8
|
+
t.equals(startsWith("asd")("lorem ipsum"), false, "Search string does not exist in source");
|
|
9
|
+
t.equals(startsWith("lorem")(["lorem", "ipsum"]), true, "Search item inside array");
|
|
16
10
|
t.end();
|
|
17
|
-
});
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=starts-with.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/starts-with/starts-with.test.js"],"names":["test","startsWith","t","equals","end"],"mappings":"AAAA,OAAOA,IAAP,MAAiB,MAAjB;AAEA,SAASC,UAAT,QAA2B,kBAA3B;AAEAD,IAAI,CAAC,YAAD,EAAe,UAAAE,CAAC,EAAI;AACtBA,EAAAA,CAAC,CAACC,MAAF,CACEF,UAAU,CAAC,OAAD,EAAU,aAAV,CADZ,EAEE,IAFF,EAGE,qDAHF;AAMAC,EAAAA,CAAC,CAACC,MAAF,CACEF,UAAU,CAAC,OAAD,CAAV,CAAoB,aAApB,CADF,EAEE,IAFF,EAGE,mDAHF;AAMAC,EAAAA,CAAC,CAACC,MAAF,CACEF,UAAU,CAAC,OAAD,CAAV,CAAoB,aAApB,CADF,EAEE,KAFF,EAGE,0CAHF;AAMAC,EAAAA,CAAC,CAACC,MAAF,CACEF,UAAU,CAAC,mBAAD,CAAV,CAAgC,aAAhC,CADF,EAEE,KAFF,EAGE,4CAHF;AAMAC,EAAAA,CAAC,CAACC,MAAF,CACEF,UAAU,CAAC,KAAD,CAAV,CAAkB,aAAlB,CADF,EAEE,KAFF,EAGE,wCAHF;AAMAC,EAAAA,CAAC,CAACC,MAAF,CACEF,UAAU,CAAC,OAAD,CAAV,CAAoB,CAAC,OAAD,EAAU,OAAV,CAApB,CADF,EAEE,IAFF,EAGE,0BAHF;AAMAC,EAAAA,CAAC,CAACE,GAAF;AACD,CAtCG,CAAJ","sourcesContent":["import test from \"tape\"\n\nimport { startsWith } from \"./starts-with.js\"\n\ntest(\"startsWith\", t => {\n t.equals(\n startsWith(\"lorem\", \"lorem ipsum\"),\n true,\n \"Source string starts with search string (uncurried)\"\n )\n\n t.equals(\n startsWith(\"lorem\")(\"lorem ipsum\"),\n true,\n \"Source string starts with search string (curried)\"\n )\n\n t.equals(\n startsWith(\"ipsum\")(\"lorem ipsum\"),\n false,\n \"Search string exists but not at starting\"\n )\n\n t.equals(\n startsWith(\"lorem ipsum dolor\")(\"lorem ipsum\"),\n false,\n \"Search string is longer than source string\"\n )\n\n t.equals(\n startsWith(\"asd\")(\"lorem ipsum\"),\n false,\n \"Search string does not exist in source\"\n )\n\n t.equals(\n startsWith(\"lorem\")([\"lorem\", \"ipsum\"]),\n true,\n \"Search item inside array\"\n )\n\n t.end()\n})\n"],"file":"starts-with.test.js"}
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.throttle = void 0;
|
|
7
|
-
|
|
8
1
|
/**
|
|
9
2
|
* Create a wrapper function that is invoked once every time interval, regardless
|
|
10
3
|
* of how many times is called.
|
|
@@ -57,4 +50,5 @@ var throttle = function throttle(fn) {
|
|
|
57
50
|
};
|
|
58
51
|
};
|
|
59
52
|
|
|
60
|
-
|
|
53
|
+
export { throttle };
|
|
54
|
+
//# sourceMappingURL=throttle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/throttle/throttle.js"],"names":["throttle","fn","wait","hasLastCall","lastExecution","Date","now","finalRunTimer","params","hasTimeWindowPassed","getTime","clearTimeout","setTimeout"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMA,QAAQ,GAAG,SAAXA,QAAW,CAACC,EAAD,EAAiD;AAAA,iFAAP,EAAO;AAAA,uBAA1CC,IAA0C;AAAA,MAA1CA,IAA0C,0BAAnC,EAAmC;AAAA,8BAA/BC,WAA+B;AAAA,MAA/BA,WAA+B,iCAAjB,KAAiB;;AAChE,MAAIC,aAAa,GAAG,IAAIC,IAAJ,CAASA,IAAI,CAACC,GAAL,KAAaJ,IAAtB,CAApB;AAEA,MAAIK,aAAJ;AAEA,SAAO,YAAe;AAAA,sCAAXC,MAAW;AAAXA,MAAAA,MAAW;AAAA;;AACpB,QAAMC,mBAAmB,GAAGL,aAAa,CAACM,OAAd,KAA0BR,IAA1B,IAAkCG,IAAI,CAACC,GAAL,EAA9D,CADoB,CAGpB;;AACA,QAAIG,mBAAJ,EAAyB;AACvBL,MAAAA,aAAa,GAAG,IAAIC,IAAJ,EAAhB;AAEAJ,MAAAA,EAAE,MAAF,SAAMO,MAAN;AACD;;AAED,QAAIL,WAAJ,EAAiB;AACfQ,MAAAA,YAAY,CAACJ,aAAD,CAAZ;AAEAA,MAAAA,aAAa,GAAGK,UAAU,CAAC,YAAM;AAC/BR,QAAAA,aAAa,GAAG,IAAIC,IAAJ,EAAhB;AAEAJ,QAAAA,EAAE,MAAF,SAAMO,MAAN;AACD,OAJyB,EAIvBN,IAJuB,CAA1B;AAKD;AACF,GAnBD;AAoBD,CAzBD;;AA2BA,SAASF,QAAT","sourcesContent":["/**\n * Create a wrapper function that is invoked once every time interval, regardless\n * of how many times is called.\n *\n * @param {Function} fn\n * @param {Object} [props]\n * @param {number} [props.wait=50] Time in milliseconds between \"fn\" invokations\n * @param {boolean} [props.hasLastCall=false] If should call \"fn\" after wrapper is no longer called\n *\n * @returns {Function}\n *\n * @name throttle\n * @tag Core\n * @signature (fn: Function, { wait: number }): Function\n *\n * @example\n * const thottledMouseMove = throttle(mouseMove, { wait: 100 })\n *\n * // render\n * <input onMouseMove={thottledMouseMove} ... />\n */\nconst throttle = (fn, { wait = 50, hasLastCall = false } = {}) => {\n let lastExecution = new Date(Date.now() - wait)\n\n let finalRunTimer\n\n return (...params) => {\n const hasTimeWindowPassed = lastExecution.getTime() + wait <= Date.now()\n\n // once every\n if (hasTimeWindowPassed) {\n lastExecution = new Date()\n\n fn(...params)\n }\n\n if (hasLastCall) {\n clearTimeout(finalRunTimer)\n\n finalRunTimer = setTimeout(() => {\n lastExecution = new Date()\n\n fn(...params)\n }, wait)\n }\n }\n}\n\nexport { throttle }\n"],"file":"throttle.js"}
|