@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/trim/trim.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/trim/trim.js"],"
|
|
1
|
+
{"version":3,"sources":["../../src/trim/trim.js"],"sourcesContent":["/* eslint-disable jsdoc/check-param-names,jsdoc/require-param */\n\nimport { escapeRegExp } from \"../escape-reg-exp/escape-reg-exp.js\"\n\nconst _trim = (char = \" \", input) => {\n const safeChar = escapeRegExp(char)\n\n return input.replace(new RegExp(`^[${safeChar}]+|[${safeChar}]+$`, \"g\"), \"\")\n}\n\n/**\n * Remove char from beginning and end of string\n *\n * @param {string} char Character to be removed\n * @param {string} source Source string\n *\n * @returns {string}\n *\n * @tag String\n * @signature (char: string) => (source: string): string\n * @signature (char: string, source: string): string\n *\n * @example\n * trim()(\" lorem \")\n * // => \"lorem\"\n *\n * trim(\"-\", \"-- lorem -\")\n * // => \" lorem \"\n */\nconst trim = (...params) => {\n // @signature (char) => (source)\n if (params.length <= 1) {\n return input => _trim(params[0], input)\n }\n\n // @signature (char, source)\n return _trim(...params)\n}\n\nexport { trim }\n"],"names":["escapeRegExp","_trim","char","input","safeChar","replace","RegExp","trim","params","length"],"mappings":";AAAA,EAAgE,AAAhE,4DAAgE,AAAhE,EAAgE,CAEhE,MAAM,GAAGA,YAAY,QAAQ,CAAqC;AAElE,GAAK,CAACC,KAAK,GAAG,QAAQ,GAAe,CAAC;QAAvBC,IAAI,oEAAG,CAAG,IAAEC,KAAK;IAC9B,GAAK,CAACC,QAAQ,GAAGJ,YAAY,CAACE,IAAI;IAElC,MAAM,CAACC,KAAK,CAACE,OAAO,CAAC,GAAG,CAACC,MAAM,CAAE,CAAE,IAAiBF,MAAQ,CAAvBA,QAAQ,EAAC,CAAI,OAAW,MAAG,CAAZA,QAAQ,EAAC,CAAG,OAAG,CAAG,KAAG,CAAE;AAC7E,CAAC;AAED,EAkBG,AAlBH;;;;;;;;;;;;;;;;;;CAkBG,AAlBH,EAkBG,CACH,GAAK,CAACG,IAAI,GAAG,QAAQ,GAAO,CAAC;qCAAZC,MAAM;QAANA,MAAM;;IACrB,EAAgC,AAAhC,8BAAgC;IAChC,EAAE,EAAEA,MAAM,CAACC,MAAM,IAAI,CAAC,EAAE,CAAC;QACvB,MAAM,CAACN,QAAQ,CAARA,KAAK;YAAIF,MAAMO,CAANP,KAAK,CAACO,MAAM,CAAC,CAAC,GAAGL,KAAK;;IACxC,CAAC;IAED,EAA4B,AAA5B,0BAA4B;IAC5B,MAAM,CAACF,KAAK,CAALA,KAAgB,CAAhBA,IAAI,CAAJA,CAAK,+BAAIO,MAAM;AACxB,CAAC;AAED,MAAM,GAAGD,IAAI"}
|
package/dist/trim/trim.test.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import test from "tape";
|
|
2
2
|
import { trim } from "./trim.js";
|
|
3
|
-
test("trim", function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
test("trim", function(t) {
|
|
4
|
+
t.equals(trim()(" lorem "), "lorem", "Remove white space - curried");
|
|
5
|
+
t.equals(trim(" ", " lorem "), "lorem", "Remove white space - uncurried");
|
|
6
|
+
t.equals(trim("-")("-- lorem -"), " lorem ", "Remove custom char");
|
|
7
|
+
t.end();
|
|
8
8
|
});
|
|
9
|
+
|
|
9
10
|
//# sourceMappingURL=trim.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/trim/trim.test.js"],"
|
|
1
|
+
{"version":3,"sources":["../../src/trim/trim.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { trim } from \"./trim.js\"\n\ntest(\"trim\", t => {\n t.equals(trim()(\" lorem \"), \"lorem\", \"Remove white space - curried\")\n\n t.equals(trim(\" \", \" lorem \"), \"lorem\", \"Remove white space - uncurried\")\n\n t.equals(trim(\"-\")(\"-- lorem -\"), \" lorem \", \"Remove custom char\")\n\n t.end()\n})\n"],"names":["test","trim","t","equals","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,MAAM,CAACF,IAAI,GAAG,CAAU,YAAG,CAAO,QAAE,CAA8B;IAEpEC,CAAC,CAACC,MAAM,CAACF,IAAI,CAAC,CAAG,IAAE,CAAU,YAAG,CAAO,QAAE,CAAgC;IAEzEC,CAAC,CAACC,MAAM,CAACF,IAAI,CAAC,CAAG,IAAE,CAAa,eAAG,CAAU,WAAE,CAAoB;IAEnEC,CAAC,CAACE,GAAG;AACP,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as swcHelpers from "@swc/helpers";
|
|
1
2
|
/**
|
|
2
3
|
* Replicate try/catch using a tryer and catcher function
|
|
3
4
|
*
|
|
@@ -17,20 +18,20 @@
|
|
|
17
18
|
* (error, source) => inc(source)
|
|
18
19
|
* )(10)
|
|
19
20
|
* // => 11
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
21
|
+
*/ var tryCatch = function(tryer, catcher) {
|
|
22
|
+
return function() {
|
|
23
|
+
for(var _len = arguments.length, input = new Array(_len), _key = 0; _key < _len; _key++){
|
|
24
|
+
input[_key] = arguments[_key];
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
return tryer.apply(void 0, swcHelpers.toConsumableArray(input));
|
|
28
|
+
} catch (error) {
|
|
29
|
+
return catcher.apply(void 0, [
|
|
30
|
+
error
|
|
31
|
+
].concat(swcHelpers.toConsumableArray(input)));
|
|
32
|
+
}
|
|
33
|
+
};
|
|
33
34
|
};
|
|
34
|
-
|
|
35
35
|
export { tryCatch };
|
|
36
|
+
|
|
36
37
|
//# sourceMappingURL=try-catch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/try-catch/try-catch.js"],"
|
|
1
|
+
{"version":3,"sources":["../../src/try-catch/try-catch.js"],"sourcesContent":["/**\n * Replicate try/catch using a tryer and catcher function\n *\n * @param {Function} tryer Try to do something with source input\n * @param {Function} catcher Run if tryer throws exception\n *\n * @returns {any}\n *\n * @tag Core\n *\n * @example\n * tryCatch(inc)(10)\n * // => 11\n *\n * tryCatch(\n * () => { throw new Error(\"Tryer error\") },\n * (error, source) => inc(source)\n * )(10)\n * // => 11\n */\nconst tryCatch =\n (tryer, catcher) =>\n (...input) => {\n try {\n return tryer(...input)\n } catch (error) {\n return catcher(error, ...input)\n }\n }\n\nexport { tryCatch }\n"],"names":["tryCatch","catcher","tryer","input","error"],"mappings":";AAAA,EAmBG,AAnBH;;;;;;;;;;;;;;;;;;;CAmBG,AAnBH,EAmBG,CACH,GAAK,CAACA,QAAQ,GACZ,QAAQC,CAAPC,KAAK,EAAED,OAAO;IACf,MAAM,CAAN,QAAQ,GAAM,CAAC;yCAAXE,KAAK;YAALA,KAAK;;QACP,GAAG,CAAC,CAAC;YACH,MAAM,CAACD,KAAK,CAALA,KAAe,CAAfA,IAAI,CAAJA,CAAK,+BAAIC,KAAK;QACvB,CAAC,CAAC,KAAK,EAAEC,KAAK,EAAE,CAAC;YACf,MAAM,CAACH,OAAO,CAAPA,KAAwB,CAAxBA,IAAI,CAAJA,CAAO,EAAPA,CAAC;gBAAOG,KAAK;YAAU,CAAC,CAAxBH,MAAwB,8BAANE,KAAK;QAChC,CAAC;IACH,CAAC;;AAEH,MAAM,GAAGH,QAAQ"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import test from "tape";
|
|
2
2
|
import { inc } from "../inc/inc.js";
|
|
3
3
|
import { tryCatch } from "./try-catch.js";
|
|
4
|
-
test("tryCatch", function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
test("tryCatch", function(t) {
|
|
5
|
+
t.equals(tryCatch(inc)(10), 11, "Given tryer function not throwing, apply tryer function on input");
|
|
6
|
+
t.equals(tryCatch(function() {
|
|
7
|
+
throw new Error("Tryer error");
|
|
8
|
+
}, function(error, input) {
|
|
9
|
+
return inc(input);
|
|
10
|
+
})(10), 11, "Given tryer function throwing, apply catcher function on input");
|
|
11
|
+
t.end();
|
|
12
12
|
});
|
|
13
|
+
|
|
13
14
|
//# sourceMappingURL=try-catch.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/try-catch/try-catch.test.js"],"
|
|
1
|
+
{"version":3,"sources":["../../src/try-catch/try-catch.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { inc } from \"../inc/inc.js\"\nimport { tryCatch } from \"./try-catch.js\"\n\ntest(\"tryCatch\", t => {\n t.equals(\n tryCatch(inc)(10),\n 11,\n \"Given tryer function not throwing, apply tryer function on input\"\n )\n\n t.equals(\n tryCatch(\n () => {\n throw new Error(\"Tryer error\")\n },\n (error, input) => inc(input)\n )(10),\n 11,\n \"Given tryer function throwing, apply catcher function on input\"\n )\n\n t.end()\n})\n"],"names":["test","inc","tryCatch","t","equals","Error","input","error","end"],"mappings":"AAAA,MAAM,CAACA,IAAI,MAAM,CAAM;AAEvB,MAAM,GAAGC,GAAG,QAAQ,CAAe;AACnC,MAAM,GAAGC,QAAQ,QAAQ,CAAgB;AAEzCF,IAAI,CAAC,CAAU,WAAEG,QAChB,CADgBA,CAAC,EAAI,CAAC;IACrBA,CAAC,CAACC,MAAM,CACNF,QAAQ,CAACD,GAAG,EAAE,EAAE,GAChB,EAAE,EACF,CAAkE;IAGpEE,CAAC,CAACC,MAAM,CACNF,QAAQ,CACN,QACN,GADY,CAAC;QACL,KAAK,CAAC,GAAG,CAACG,KAAK,CAAC,CAAa;IAC/B,CAAC,EACD,QAAQC,CAAPC,KAAK,EAAED,KAAK;QAAKL,MAAM,CAANA,GAAG,CAACK,KAAK;OAC3B,EAAE,GACJ,EAAE,EACF,CAAgE;IAGlEH,CAAC,CAACK,GAAG;AACP,CAAC"}
|
package/dist/type/type.js
CHANGED
|
@@ -21,10 +21,9 @@
|
|
|
21
21
|
* type(new Date()) // "Date"
|
|
22
22
|
* type(() => {}) // "Function"
|
|
23
23
|
* type(Promise.resolve()) // "Promise"
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
return input === null ? "Null" : input === undefined ? "Undefined" : Object.prototype.toString.call(input).slice(8, -1);
|
|
24
|
+
*/ var type = function(input) {
|
|
25
|
+
return input === null ? "Null" : input === undefined ? "Undefined" : Object.prototype.toString.call(input).slice(8, -1);
|
|
27
26
|
};
|
|
28
|
-
|
|
29
27
|
export { type };
|
|
28
|
+
|
|
30
29
|
//# sourceMappingURL=type.js.map
|
package/dist/type/type.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/type/type.js"],"
|
|
1
|
+
{"version":3,"sources":["../../src/type/type.js"],"sourcesContent":["/**\n * From ramda: Gives a single-word string description of the (native) type of\n * a value, returning such answers as \"Object\", \"Number\", \"Array\", or \"Null\".\n *\n * Does not attempt to distinguish user Object types any further, reporting\n * them all as \"Object\".\n *\n * @param {any} input Something to check type on\n *\n * @returns {string}\n *\n * @example\n * type({}) // \"Object\"\n * type(1) // \"Number\"\n * type(false) // \"Boolean\"\n * type(\"s\") // \"String\"\n * type(null) // \"Null\"\n * type(undefined) // \"Undefined\"\n * type([]) // \"Array\"\n * type(/[A-z]/) // \"RegExp\"\n * type(new Date()) // \"Date\"\n * type(() => {}) // \"Function\"\n * type(Promise.resolve()) // \"Promise\"\n */\nconst type = input =>\n input === null\n ? \"Null\"\n : input === undefined\n ? \"Undefined\"\n : Object.prototype.toString.call(input).slice(8, -1)\n\nexport { type }\n"],"names":["type","input","undefined","Object","prototype","toString","call","slice"],"mappings":"AAAA,EAuBG,AAvBH;;;;;;;;;;;;;;;;;;;;;;;CAuBG,AAvBH,EAuBG,CACH,GAAK,CAACA,IAAI,GAAGC,QAAQ,CAARA,KAAK;IAChBA,MAAM,CAANA,KAAK,KAAK,IAAI,GACV,CAAM,QACNA,KAAK,KAAKC,SAAS,GACnB,CAAW,aACXC,MAAM,CAACC,SAAS,CAACC,QAAQ,CAACC,IAAI,CAACL,KAAK,EAAEM,KAAK,CAAC,CAAC,GAAG,CAAC;;AAEvD,MAAM,GAAGP,IAAI"}
|
package/dist/type/type.test.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
/* eslint-disable unicorn/no-null */
|
|
2
|
-
import test from "tape";
|
|
1
|
+
/* eslint-disable unicorn/no-null */ import test from "tape";
|
|
3
2
|
import { type } from "./type.js";
|
|
4
|
-
test("type", function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
3
|
+
test("type", function(t) {
|
|
4
|
+
t.equal(type(null), "Null", "null should equal Null");
|
|
5
|
+
t.equal(type(), "Undefined", "undefined should equal Undefined");
|
|
6
|
+
t.equal(type(Number.NaN), "Number", "NaN should equal Number");
|
|
7
|
+
t.equal(type(false), "Boolean", "false should equal Boolean");
|
|
8
|
+
t.equal(type(2), "Number", "2 should equal Number");
|
|
9
|
+
t.equal(type(""), "String", '"" should equal String');
|
|
10
|
+
t.equal(type([]), "Array", "[] should equal Array");
|
|
11
|
+
t.equal(type({}), "Object", "{} should equal Object");
|
|
12
|
+
t.equal(type(new Date()), "Date", "new Date() should equal Date");
|
|
13
|
+
t.equal(type(function() {}), "Function", "() => {} should equal Function");
|
|
14
|
+
t.equal(type(/[A-z]/), "RegExp", "/[A-z]/ should equal RegExp");
|
|
15
|
+
t.equal(type(Promise.resolve(2)), "Promise", "Promise.resolve(2) should equal Promise");
|
|
16
|
+
t.end();
|
|
18
17
|
});
|
|
18
|
+
|
|
19
19
|
//# sourceMappingURL=type.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/type/type.test.js"],"
|
|
1
|
+
{"version":3,"sources":["../../src/type/type.test.js"],"sourcesContent":["/* eslint-disable unicorn/no-null */\n\nimport test from \"tape\"\n\nimport { type } from \"./type.js\"\n\ntest(\"type\", t => {\n t.equal(type(null), \"Null\", \"null should equal Null\")\n t.equal(type(), \"Undefined\", \"undefined should equal Undefined\")\n t.equal(type(Number.NaN), \"Number\", \"NaN should equal Number\")\n t.equal(type(false), \"Boolean\", \"false should equal Boolean\")\n t.equal(type(2), \"Number\", \"2 should equal Number\")\n t.equal(type(\"\"), \"String\", '\"\" should equal String')\n t.equal(type([]), \"Array\", \"[] should equal Array\")\n t.equal(type({}), \"Object\", \"{} should equal Object\")\n t.equal(type(new Date()), \"Date\", \"new Date() should equal Date\")\n t.equal(\n type(() => {}),\n \"Function\",\n \"() => {} should equal Function\"\n )\n t.equal(type(/[A-z]/), \"RegExp\", \"/[A-z]/ should equal RegExp\")\n t.equal(\n type(Promise.resolve(2)),\n \"Promise\",\n \"Promise.resolve(2) should equal Promise\"\n )\n t.end()\n})\n"],"names":["test","type","t","equal","Number","NaN","Date","Promise","resolve","end"],"mappings":"AAAA,EAAoC,AAApC,gCAAoC,AAApC,EAAoC,CAEpC,MAAM,CAACA,IAAI,MAAM,C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ype.join.call(input, separator);
|
|
2
|
+
var _unite = function(separator, input) {
|
|
3
|
+
return Array.prototype.join.call(input, separator);
|
|
5
4
|
};
|
|
6
5
|
/**
|
|
7
6
|
* Unite all elements of an array into a string
|
|
@@ -18,8 +17,6 @@ var _unite = function _unite(separator, input) {
|
|
|
18
17
|
* @example
|
|
19
18
|
* unite(",", ["lorem", "ipsum"])
|
|
20
19
|
* // => "lorem,ipsum"
|
|
21
|
-
*/
|
|
22
|
-
|
|
20
|
+
*/ export var unite = curry(_unite);
|
|
23
21
|
|
|
24
|
-
export var unite = curry(_unite);
|
|
25
22
|
//# sourceMappingURL=unite.js.map
|
package/dist/unite/unite.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/unite/unite.js"],"
|
|
1
|
+
{"version":3,"sources":["../../src/unite/unite.js"],"sourcesContent":["import { curry } from \"../curry/curry.js\"\n\nconst _unite = (separator, input) => Array.prototype.join.call(input, separator)\n\n/**\n * Unite all elements of an array into a string\n *\n * @param {string} separator Separator between each adjacent elements\n * @param {Array} source Source array\n *\n * @returns {string}\n *\n * @name unite\n * @tag Array\n * @signature (separator: String, source: Array) => String\n *\n * @example\n * unite(\",\", [\"lorem\", \"ipsum\"])\n * // => \"lorem,ipsum\"\n */\nexport const unite = curry(_unite)\n"],"names":["curry","_unite","separator","input","Array","prototype","join","call","unite"],"mappings":"AAAA,MAAM,GAAGA,KAAK,QAAQ,CAAmB;AAEzC,GAAK,CAACC,MAAM,GAAG,QAAQ,CAAPC,SAAS,EAAEC,KAAK;IAAKC,MAAMC,CAAND,KAAK,CAACC,SAAS,CAACC,IAAI,CAACC,IAAI,CAACJ,KAAK,EAAED,SAAS;;AAE/E,EAeG,AAfH;;;;;;;;;;;;;;;CAeG,AAfH,EAeG,CACH,MAAM,CAAC,GAAK,CAACM,KAAK,GAAGR,KAAK,CAACC,MAAM"}
|
package/dist/unite/unite.test.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import test from "tape";
|
|
2
2
|
import { unite } from "./unite.js";
|
|
3
|
-
test("unite", function
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
test("unite", function(t) {
|
|
4
|
+
t.deepEqual(unite(",", [
|
|
5
|
+
1,
|
|
6
|
+
2,
|
|
7
|
+
3
|
|
8
|
+
]), "1,2,3", "given [a comma and and array] should [return a string with items separated by comma]");
|
|
9
|
+
t.end();
|
|
6
10
|
});
|
|
11
|
+
|
|
7
12
|
//# sourceMappingURL=unite.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/unite/unite.test.js"],"
|
|
1
|
+
{"version":3,"sources":["../../src/unite/unite.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { unite } from \"./unite.js\"\n\ntest(\"unite\", t => {\n t.deepEqual(\n unite(\",\", [1, 2, 3]),\n \"1,2,3\",\n \"given [a comma and and array] should [return a string with items separated by comma]\"\n )\n\n t.end()\n})\n"],"names":["test","unite","t","deepEqual","end"],"mappings":"AAAA,MAAM,CAACA,IAAI,MAAM,CAAM;AAEvB,MAAM,GAAGC,KAAK,QAAQ,CAAY;AAElCD,IAAI,CAAC,CAAO,QAAEE,QACb,CADaA,CAAC,EAAI,CAAC;IAClBA,CAAC,CAACC,SAAS,CACTF,KAAK,CAAC,CAAG,IAAE,CAAC;AAAA,SAAC;AAAE,SAAC;AAAE,SAAC;IAAA,CAAC,GACpB,CAAO,QACP,CAAsF;IAGxFC,CAAC,CAACE,GAAG;AACP,CAAC"}
|
package/dist/update/update.js
CHANGED
|
@@ -1,90 +1,83 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
|
|
4
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
5
|
-
|
|
6
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
7
|
-
|
|
1
|
+
import * as swcHelpers from "@swc/helpers";
|
|
8
2
|
import { map } from "../map/map.js";
|
|
9
3
|
import { isMatch } from "../is-match/is-match.js";
|
|
10
|
-
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
4
|
+
var _update = function(transformations, input) {
|
|
5
|
+
var entries = Object.entries(transformations);
|
|
6
|
+
var result = swcHelpers.objectSpread({}, input);
|
|
7
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
8
|
+
try {
|
|
9
|
+
for(var _iterator = entries[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
10
|
+
var _value = swcHelpers.slicedToArray(_step.value, 2), key = _value[0], value = _value[1];
|
|
11
|
+
result[key] = typeof value === "function" ? value(input[key], input) : value;
|
|
12
|
+
}
|
|
13
|
+
} catch (err) {
|
|
14
|
+
_didIteratorError = true;
|
|
15
|
+
_iteratorError = err;
|
|
16
|
+
} finally{
|
|
17
|
+
try {
|
|
18
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
19
|
+
_iterator.return();
|
|
20
|
+
}
|
|
21
|
+
} finally{
|
|
22
|
+
if (_didIteratorError) {
|
|
23
|
+
throw _iteratorError;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
25
28
|
};
|
|
26
|
-
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
result
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return result;
|
|
29
|
+
var _updateWith = function(filter, transformations, input) {
|
|
30
|
+
var result = [];
|
|
31
|
+
for(var i = 0, length = input.length; i < length; ++i){
|
|
32
|
+
var item = input[i];
|
|
33
|
+
var shouldMutate = isMatch(filter, item);
|
|
34
|
+
result.push(shouldMutate ? _update(transformations, item) : item);
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
37
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}, input);
|
|
38
|
+
var _updateMany = function(transformations, input) {
|
|
39
|
+
return map(function(item) {
|
|
40
|
+
return _update(transformations, item);
|
|
41
|
+
}, input);
|
|
43
42
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return _update.apply(void 0, params);
|
|
43
|
+
export var update = function() {
|
|
44
|
+
for(var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++){
|
|
45
|
+
params[_key] = arguments[_key];
|
|
46
|
+
}
|
|
47
|
+
// @signature (transformations) => (source)
|
|
48
|
+
if (params.length <= 1) {
|
|
49
|
+
return function(input) {
|
|
50
|
+
return _update(params[0], input);
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
// @signature (transformations, source)
|
|
54
|
+
return _update.apply(void 0, swcHelpers.toConsumableArray(params));
|
|
59
55
|
};
|
|
60
|
-
export var updateMany = function
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return _updateMany.apply(void 0, params);
|
|
56
|
+
export var updateMany = function() {
|
|
57
|
+
for(var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++){
|
|
58
|
+
params[_key] = arguments[_key];
|
|
59
|
+
}
|
|
60
|
+
// @signature (transformations) => (source)
|
|
61
|
+
if (params.length <= 1) {
|
|
62
|
+
return function(input) {
|
|
63
|
+
return _updateMany(params[0], input);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
// @signature (transformations, source)
|
|
67
|
+
return _updateMany.apply(void 0, swcHelpers.toConsumableArray(params));
|
|
74
68
|
};
|
|
75
|
-
export var updateWith = function
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return _updateWith.apply(void 0, params);
|
|
69
|
+
export var updateWith = function() {
|
|
70
|
+
for(var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++){
|
|
71
|
+
params[_key] = arguments[_key];
|
|
72
|
+
}
|
|
73
|
+
// @signature (filter, transformations) => (source)
|
|
74
|
+
if (params.length <= 2) {
|
|
75
|
+
return function(input) {
|
|
76
|
+
return _updateWith(params[0], params[1], input);
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
// @signature (filter, transformations, source)
|
|
80
|
+
return _updateWith.apply(void 0, swcHelpers.toConsumableArray(params));
|
|
89
81
|
};
|
|
82
|
+
|
|
90
83
|
//# sourceMappingURL=update.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/update/update.js"],"
|
|
1
|
+
{"version":3,"sources":["../../src/update/update.js"],"sourcesContent":["import { map } from \"../map/map.js\"\nimport { isMatch } from \"../is-match/is-match.js\"\n\nconst _update = (transformations, input) => {\n const entries = Object.entries(transformations)\n const result = { ...input }\n\n for (const [key, value] of entries) {\n result[key] = typeof value === \"function\" ? value(input[key], input) : value\n }\n\n return result\n}\n\nconst _updateWith = (filter, transformations, input) => {\n const result = []\n\n for (let i = 0, length = input.length; i < length; ++i) {\n const item = input[i]\n const shouldMutate = isMatch(filter, item)\n\n result.push(shouldMutate ? _update(transformations, item) : item)\n }\n\n return result\n}\n\nconst _updateMany = (transformations, input) =>\n map(item => _update(transformations, item), input)\n\nexport const update = (...params) => {\n // @signature (transformations) => (source)\n if (params.length <= 1) {\n return input => _update(params[0], input)\n }\n\n // @signature (transformations, source)\n return _update(...params)\n}\n\nexport const updateMany = (...params) => {\n // @signature (transformations) => (source)\n if (params.length <= 1) {\n return input => _updateMany(params[0], input)\n }\n\n // @signature (transformations, source)\n return _updateMany(...params)\n}\n\nexport const updateWith = (...params) => {\n // @signature (filter, transformations) => (source)\n if (params.length <= 2) {\n return input => _updateWith(params[0], params[1], input)\n }\n\n // @signature (filter, transformations, source)\n return _updateWith(...params)\n}\n"],"names":["map","isMatch","_update","transformations","input","entries","Object","result","key","value","_updateWith","filter","i","length","item","shouldMutate","push","_updateMany","update","params","updateMany","updateWith"],"mappings":";AAAA,MAAM,GAAGA,GAAG,QAAQ,CAAe;AACnC,MAAM,GAAGC,OAAO,QAAQ,CAAyB;AAEjD,GAAK,CAACC,OAAO,GAAG,QAAQ,CAAPC,eAAe,EAAEC,KAAK,EAAK,CAAC;IAC3C,GAAK,CAACC,OAAO,GAAGC,MAAM,CAACD,OAAO,CAACF,eAAe;IAC9C,GAAK,CAACI,MAAM,+BAAQH,KAAK;QAEpB,yBAAkB,SAAlB,iBAAkB,UAAlB,cAAkB;;QAAvB,GAAG,KAAE,SAAkB,GAAIC,OAAO,qBAA7B,KAAkB,IAAlB,yBAAkB,IAAlB,KAAkB,GAAlB,SAAkB,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|
5
|
-
return x + 1;
|
|
3
|
+
var inc = function(x) {
|
|
4
|
+
return x + 1;
|
|
6
5
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
t.end();
|
|
6
|
+
test("update", function(t) {
|
|
7
|
+
t.deepEqual(update({
|
|
8
|
+
test: "changed"
|
|
9
|
+
}, {
|
|
10
|
+
test: "Lorem Ipsum"
|
|
11
|
+
}), {
|
|
12
|
+
test: "changed"
|
|
13
|
+
}, "Updating existing property should return changed object");
|
|
14
|
+
t.deepEqual(update({
|
|
15
|
+
test: inc
|
|
16
|
+
})({
|
|
17
|
+
test: 2
|
|
18
|
+
}), {
|
|
19
|
+
test: 3
|
|
20
|
+
}, "Updating existing property with function should return changed object");
|
|
21
|
+
t.deepEqual(update({
|
|
22
|
+
notExist: 2
|
|
23
|
+
}, {
|
|
24
|
+
test: "Lorem Ipsum"
|
|
25
|
+
}), {
|
|
26
|
+
test: "Lorem Ipsum",
|
|
27
|
+
notExist: 2
|
|
28
|
+
}, "Updating non-existing property should return changed object");
|
|
29
|
+
t.deepEqual(update({
|
|
30
|
+
test: function(input, item) {
|
|
31
|
+
return "".concat(input, " ").concat(item.foo);
|
|
32
|
+
}
|
|
33
|
+
}, {
|
|
34
|
+
foo: "bar",
|
|
35
|
+
test: "Lorem Ipsum"
|
|
36
|
+
}), {
|
|
37
|
+
foo: "bar",
|
|
38
|
+
test: "Lorem Ipsum bar"
|
|
39
|
+
}, "Updating existing property based on other field should return changed object");
|
|
40
|
+
t.end();
|
|
43
41
|
});
|
|
44
|
-
test("updateMany", function
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
42
|
+
test("updateMany", function(t) {
|
|
43
|
+
t.deepEqual(updateMany({
|
|
44
|
+
id: function() {
|
|
45
|
+
var input = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
|
|
46
|
+
return input + 1;
|
|
47
|
+
}
|
|
48
|
+
}, [
|
|
49
|
+
{
|
|
50
|
+
id: 1
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
id: 2
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
test: "dolor"
|
|
57
|
+
}
|
|
58
|
+
]), [
|
|
59
|
+
{
|
|
60
|
+
id: 2
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
id: 3
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: 1,
|
|
67
|
+
test: "dolor"
|
|
68
|
+
}
|
|
69
|
+
], "Updating existing and unexisting properties should return changed object");
|
|
70
|
+
t.end();
|
|
65
71
|
});
|
|
66
|
-
test("updateWith", function
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
72
|
+
test("updateWith", function(t) {
|
|
73
|
+
t.deepEqual(updateWith({
|
|
74
|
+
id: 2
|
|
75
|
+
}, {
|
|
76
|
+
count: inc,
|
|
77
|
+
other: 2
|
|
78
|
+
}, [
|
|
79
|
+
{
|
|
80
|
+
id: 1
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
id: 2,
|
|
84
|
+
count: 1
|
|
85
|
+
}
|
|
86
|
+
]), [
|
|
87
|
+
{
|
|
88
|
+
id: 1
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
id: 2,
|
|
92
|
+
count: 2,
|
|
93
|
+
other: 2
|
|
94
|
+
}
|
|
95
|
+
], "Mutating item inside array should return new array with changed object");
|
|
96
|
+
t.end();
|
|
85
97
|
});
|
|
98
|
+
|
|
86
99
|
//# sourceMappingURL=update.test.js.map
|