@asd14/m 7.8.2 → 8.1.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/dist/all/all.js +2 -2
- package/dist/all/all.js.map +1 -1
- package/dist/all/all.test.js.map +1 -1
- package/dist/any/any.js +2 -2
- package/dist/any/any.js.map +1 -1
- package/dist/any/any.test.js +1 -1
- package/dist/any/any.test.js.map +1 -1
- package/dist/append/append.js +2 -2
- package/dist/append/append.js.map +1 -1
- package/dist/append/append.test.js.map +1 -1
- package/dist/bottom/bottom.js +2 -2
- package/dist/bottom/bottom.js.map +1 -1
- package/dist/bottom/bottom.test.js.map +1 -1
- package/dist/cases/cases.js +3 -2
- package/dist/cases/cases.js.map +1 -1
- package/dist/cases/cases.test.js +3 -3
- package/dist/cases/cases.test.js.map +1 -1
- package/dist/clone/clone.js +2 -2
- package/dist/clone/clone.js.map +1 -1
- package/dist/clone/clone.test.js +2 -2
- package/dist/clone/clone.test.js.map +1 -1
- package/dist/compact/compact.js +2 -2
- package/dist/compact/compact.js.map +1 -1
- package/dist/compact/compact.test.js +2 -2
- package/dist/compact/compact.test.js.map +1 -1
- package/dist/contains/contains.js.map +1 -1
- package/dist/contains/contains.test.js.map +1 -1
- package/dist/converge/converge.js +8 -8
- package/dist/converge/converge.js.map +1 -1
- package/dist/converge/converge.test.js +1 -1
- package/dist/converge/converge.test.js.map +1 -1
- package/dist/count/count.js +4 -3
- package/dist/count/count.js.map +1 -1
- package/dist/count/count.test.js +3 -3
- package/dist/count/count.test.js.map +1 -1
- package/dist/curry/curry.js +7 -8
- package/dist/curry/curry.js.map +1 -1
- package/dist/curry/curry.test.js.map +1 -1
- package/dist/debounce/debounce.js +3 -3
- package/dist/debounce/debounce.js.map +1 -1
- package/dist/debounce/debounce.test.js.map +1 -1
- package/dist/dec/dec.js.map +1 -1
- package/dist/dec/dec.test.js.map +1 -1
- package/dist/deep-equal/deep-equal.bench.js.map +1 -1
- package/dist/deep-equal/deep-equal.js +2 -2
- package/dist/deep-equal/deep-equal.js.map +1 -1
- package/dist/deep-equal/deep-equal.own.js +4 -3
- package/dist/deep-equal/deep-equal.own.js.map +1 -1
- package/dist/deep-equal/deep-equal.test.js.map +1 -1
- package/dist/distinct/distinct.bench.js.map +1 -1
- package/dist/distinct/distinct.js.map +1 -1
- package/dist/distinct/distinct.test.js.map +1 -1
- package/dist/drop-last/drop-last.js.map +1 -1
- package/dist/drop-last/drop-last.test.js.map +1 -1
- package/dist/elapsed-time/elapsed-time.js.map +1 -1
- package/dist/elapsed-time/elapsed-time.test.js.map +1 -1
- package/dist/ends-with/ends-with.js.map +1 -1
- package/dist/ends-with/ends-with.test.js.map +1 -1
- package/dist/escape/escape.js.map +1 -1
- package/dist/escape-html/escape-html.js.map +1 -1
- package/dist/escape-html/escape-html.test.js.map +1 -1
- package/dist/escape-reg-exp/escape-reg-exp.js.map +1 -1
- package/dist/escape-reg-exp/escape-reg-exp.test.js.map +1 -1
- package/dist/filter/filter.js +2 -2
- package/dist/filter/filter.js.map +1 -1
- package/dist/filter/filter.test.js +3 -3
- package/dist/filter/filter.test.js.map +1 -1
- package/dist/find/find.js +4 -4
- package/dist/find/find.js.map +1 -1
- package/dist/find/find.test.js +2 -2
- package/dist/find/find.test.js.map +1 -1
- package/dist/find-index/find-index.js +2 -2
- package/dist/find-index/find-index.js.map +1 -1
- package/dist/find-index/find-index.test.js +2 -2
- package/dist/find-index/find-index.test.js.map +1 -1
- package/dist/first/first.js.map +1 -1
- package/dist/first/first.test.js.map +1 -1
- package/dist/flatten/flatten.js +8 -4
- package/dist/flatten/flatten.js.map +1 -1
- package/dist/flatten/flatten.test.js.map +1 -1
- package/dist/for-each/for-each.js +2 -2
- package/dist/for-each/for-each.js.map +1 -1
- package/dist/for-each/for-each.test.js.map +1 -1
- package/dist/group-by/group-by.js.map +1 -1
- package/dist/group-by/group-by.test.js +3 -3
- package/dist/group-by/group-by.test.js.map +1 -1
- package/dist/gt/gt.js.map +1 -1
- package/dist/gt/gt.test.js.map +1 -1
- package/dist/has-key/has-key.js.map +1 -1
- package/dist/has-key/has-key.test.js.map +1 -1
- package/dist/hist/hist.js.map +1 -1
- package/dist/hist/hist.test.js +1 -1
- package/dist/hist/hist.test.js.map +1 -1
- package/dist/i/i.js.map +1 -1
- package/dist/i/i.test.js.map +1 -1
- package/dist/inc/inc.js.map +1 -1
- package/dist/inc/inc.test.js.map +1 -1
- package/dist/index-by/index-by.js.map +1 -1
- package/dist/index-by/index-by.test.js +2 -2
- package/dist/index-by/index-by.test.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.test.js.map +1 -1
- package/dist/intersect/intersect.js +2 -2
- package/dist/intersect/intersect.js.map +1 -1
- package/dist/intersect/intersect.test.js +4 -4
- package/dist/intersect/intersect.test.js.map +1 -1
- package/dist/is/is.js.map +1 -1
- package/dist/is/is.test.js.map +1 -1
- package/dist/is-between/is-between.js.map +1 -1
- package/dist/is-between/is-between.test.js.map +1 -1
- package/dist/is-empty/is-empty.js.map +1 -1
- package/dist/is-empty/is-empty.test.js.map +1 -1
- package/dist/is-equal/is-equal.js.map +1 -1
- package/dist/is-equal/is-equal.test.js.map +1 -1
- package/dist/is-match/is-match.js +4 -3
- package/dist/is-match/is-match.js.map +1 -1
- package/dist/is-match/is-match.test.js.map +1 -1
- package/dist/is-uri/is-uri.js.map +1 -1
- package/dist/is-uri/is-uri.test.js.map +1 -1
- package/dist/join/join.js +2 -2
- package/dist/join/join.js.map +1 -1
- package/dist/join/join.test.js +2 -2
- package/dist/join/join.test.js.map +1 -1
- package/dist/keys/keys.js.map +1 -1
- package/dist/keys/keys.test.js.map +1 -1
- package/dist/last/last.js.map +1 -1
- package/dist/last/last.test.js.map +1 -1
- package/dist/lt/lt.js.map +1 -1
- package/dist/lt/lt.test.js.map +1 -1
- package/dist/map/map.js +2 -2
- package/dist/map/map.js.map +1 -1
- package/dist/map/map.test.js +1 -1
- package/dist/map/map.test.js.map +1 -1
- package/dist/map-matrix/map-matrix.js +2 -2
- package/dist/map-matrix/map-matrix.js.map +1 -1
- package/dist/map-matrix/map-matrix.test.js +6 -6
- package/dist/map-matrix/map-matrix.test.js.map +1 -1
- package/dist/max/max.js +4 -3
- package/dist/max/max.js.map +1 -1
- package/dist/max/max.test.js +1 -1
- package/dist/max/max.test.js.map +1 -1
- package/dist/merge/merge.js +4 -3
- package/dist/merge/merge.js.map +1 -1
- package/dist/merge/merge.test.js +3 -3
- package/dist/merge/merge.test.js.map +1 -1
- package/dist/min/min.js +4 -3
- package/dist/min/min.js.map +1 -1
- package/dist/min/min.test.js +1 -1
- package/dist/min/min.test.js.map +1 -1
- package/dist/move/move.js +6 -5
- package/dist/move/move.js.map +1 -1
- package/dist/move/move.test.js.map +1 -1
- package/dist/mutate/mutate.js +9 -7
- package/dist/mutate/mutate.js.map +1 -1
- package/dist/mutate/mutate.test.js +2 -2
- package/dist/mutate/mutate.test.js.map +1 -1
- package/dist/page/page.js +3 -3
- package/dist/page/page.js.map +1 -1
- package/dist/page/page.test.js.map +1 -1
- package/dist/partition/partition.js +3 -3
- package/dist/partition/partition.js.map +1 -1
- package/dist/partition/partition.test.js +2 -2
- package/dist/partition/partition.test.js.map +1 -1
- package/dist/pick/pick.js +3 -3
- package/dist/pick/pick.js.map +1 -1
- package/dist/pick/pick.test.js +1 -1
- package/dist/pick/pick.test.js.map +1 -1
- package/dist/pipe/pipe.js +5 -5
- package/dist/pipe/pipe.js.map +1 -1
- package/dist/pipe/pipe.test.js.map +1 -1
- package/dist/pipe-p/pipe-p.js +5 -5
- package/dist/pipe-p/pipe-p.js.map +1 -1
- package/dist/pipe-p/pipe-p.test.js +2 -2
- package/dist/pipe-p/pipe-p.test.js.map +1 -1
- package/dist/pluck/pluck.js +2 -2
- package/dist/pluck/pluck.js.map +1 -1
- package/dist/pluck/pluck.test.js +1 -1
- package/dist/pluck/pluck.test.js.map +1 -1
- package/dist/prepend/prepend.js +3 -3
- package/dist/prepend/prepend.js.map +1 -1
- package/dist/prepend/prepend.test.js.map +1 -1
- package/dist/proto-chain/proto-chain.js +3 -3
- package/dist/proto-chain/proto-chain.js.map +1 -1
- package/dist/proto-chain/proto-chain.test.js.map +1 -1
- package/dist/push/push.js +3 -3
- package/dist/push/push.js.map +1 -1
- package/dist/push/push.test.js.map +1 -1
- package/dist/raise/raise.js.map +1 -1
- package/dist/raise/raise.test.js.map +1 -1
- package/dist/random/random.js.map +1 -1
- package/dist/random/random.test.js.map +1 -1
- package/dist/read/read.js +3 -3
- package/dist/read/read.js.map +1 -1
- package/dist/read/read.test.js +1 -1
- package/dist/read/read.test.js.map +1 -1
- package/dist/reduce/reduce.js +3 -3
- package/dist/reduce/reduce.js.map +1 -1
- package/dist/reduce/reduce.test.js +4 -2
- package/dist/reduce/reduce.test.js.map +1 -1
- package/dist/remove/remove.js +6 -5
- package/dist/remove/remove.js.map +1 -1
- package/dist/remove/remove.test.js +2 -2
- package/dist/remove/remove.test.js.map +1 -1
- package/dist/rename/rename.js +7 -5
- package/dist/rename/rename.js.map +1 -1
- package/dist/rename/rename.test.js +1 -1
- package/dist/rename/rename.test.js.map +1 -1
- package/dist/rename-file/rename-file.js.map +1 -1
- package/dist/rename-file/rename-file.test.js.map +1 -1
- package/dist/repeat/repeat.js +3 -3
- package/dist/repeat/repeat.js.map +1 -1
- package/dist/repeat/repeat.test.js.map +1 -1
- package/dist/replace/replace.js.map +1 -1
- package/dist/replace/replace.test.js +9 -8
- package/dist/replace/replace.test.js.map +1 -1
- package/dist/same/same.js.map +1 -1
- package/dist/same/same.test.js.map +1 -1
- package/dist/sequence/sequence.js.map +1 -1
- package/dist/sequence/sequence.test.js +2 -2
- package/dist/sequence/sequence.test.js.map +1 -1
- package/dist/sort/sort-with.js +8 -7
- package/dist/sort/sort-with.js.map +1 -1
- package/dist/sort/sort.js +4 -4
- package/dist/sort/sort.js.map +1 -1
- package/dist/sort/sort.test.js +14 -14
- package/dist/sort/sort.test.js.map +1 -1
- package/dist/split/split.js +5 -4
- package/dist/split/split.js.map +1 -1
- package/dist/split/split.test.js.map +1 -1
- package/dist/split-in-groups-of/split-in-groups-of.js +4 -3
- 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 +1 -1
- package/dist/split-in-groups-of/split-in-groups-of.test.js.map +1 -1
- package/dist/spy/spy.js.map +1 -1
- package/dist/spy/spy.test.js.map +1 -1
- package/dist/starts-with/starts-with.js.map +1 -1
- package/dist/starts-with/starts-with.test.js.map +1 -1
- package/dist/throttle/throttle.js +4 -4
- package/dist/throttle/throttle.js.map +1 -1
- package/dist/throttle/throttle.test.js.map +1 -1
- package/dist/to-lower/to-lower.js.map +1 -1
- package/dist/to-lower/to-lower.test.js.map +1 -1
- package/dist/to-upper/to-upper.js.map +1 -1
- package/dist/to-upper/to-upper.test.js.map +1 -1
- package/dist/toggle/toggle.js.map +1 -1
- package/dist/toggle/toggle.test.js.map +1 -1
- package/dist/top/top.js +5 -5
- package/dist/top/top.js.map +1 -1
- package/dist/top/top.test.js.map +1 -1
- package/dist/trim/trim.js +3 -3
- package/dist/trim/trim.js.map +1 -1
- package/dist/trim/trim.test.js.map +1 -1
- package/dist/try-catch/try-catch.js +4 -4
- package/dist/try-catch/try-catch.js.map +1 -1
- package/dist/try-catch/try-catch.test.js.map +1 -1
- package/dist/type/type.js.map +1 -1
- package/dist/type/type.test.js.map +1 -1
- package/dist/unite/unite.js.map +1 -1
- package/dist/unite/unite.test.js.map +1 -1
- package/dist/update/update.js +8 -6
- package/dist/update/update.js.map +1 -1
- package/dist/update/update.test.js.map +1 -1
- package/dist/upsert/upsert.js +2 -2
- package/dist/upsert/upsert.js.map +1 -1
- package/dist/upsert/upsert.test.js.map +1 -1
- package/dist/values/values.js +3 -3
- package/dist/values/values.js.map +1 -1
- package/dist/values/values.test.js.map +1 -1
- package/dist/when/when.js +6 -6
- package/dist/when/when.js.map +1 -1
- package/dist/when/when.test.js.map +1 -1
- package/dist/write/write.js +5 -3
- package/dist/write/write.js.map +1 -1
- package/dist/write/write.test.js.map +1 -1
- package/dist/zip-to-object/zip-to-object.js.map +1 -1
- package/dist/zip-to-object/zip-to-object.test.js.map +1 -1
- package/package.json +19 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/escape-reg-exp/escape-reg-exp.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { escapeRegExp } from \"./escape-reg-exp.js\"\n\ntest(\"escapeRegExp\", t => {\n const actualT1 = escapeRegExp(\"lorem. ipsum [dolor] (sit amet)?\")\n const expectedT1 = \"lorem\\\\. ipsum \\\\[dolor\\\\] \\\\(sit amet\\\\)\\\\?\"\n\n t.equal(actualT1, expectedT1, \"Chars: (, ), [, ], ?, . should be escaped\")\n\n const actualT2 = escapeRegExp(\"Alice + Bob = $orry | A < B | f* => {}\")\n const expectedT2 = \"Alice \\\\+ Bob = \\\\$orry \\\\| A \\\\< B \\\\| f\\\\* =\\\\> \\\\{\\\\}\"\n\n t.equal(\n actualT2,\n expectedT2,\n \"Chars: +, $, |, <, >, *, {, } should be escaped\"\n )\n\n t.end()\n})\n"],"names":["test","escapeRegExp","t","actualT1","expectedT1","equal","actualT2","expectedT2","end"],"mappings":"AAAA,OAAOA,
|
|
1
|
+
{"version":3,"sources":["../../src/escape-reg-exp/escape-reg-exp.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { escapeRegExp } from \"./escape-reg-exp.js\"\n\ntest(\"escapeRegExp\", t => {\n const actualT1 = escapeRegExp(\"lorem. ipsum [dolor] (sit amet)?\")\n const expectedT1 = \"lorem\\\\. ipsum \\\\[dolor\\\\] \\\\(sit amet\\\\)\\\\?\"\n\n t.equal(actualT1, expectedT1, \"Chars: (, ), [, ], ?, . should be escaped\")\n\n const actualT2 = escapeRegExp(\"Alice + Bob = $orry | A < B | f* => {}\")\n const expectedT2 = \"Alice \\\\+ Bob = \\\\$orry \\\\| A \\\\< B \\\\| f\\\\* =\\\\> \\\\{\\\\}\"\n\n t.equal(\n actualT2,\n expectedT2,\n \"Chars: +, $, |, <, >, *, {, } should be escaped\"\n )\n\n t.end()\n})\n"],"names":["test","escapeRegExp","t","actualT1","expectedT1","equal","actualT2","expectedT2","end"],"mappings":"AAAA,OAAOA,UAAU,OAAM;AAEvB,SAASC,YAAY,QAAQ,sBAAqB;AAElDD,KAAK,gBAAgBE,SAAAA,GAAK;IACxB,IAAMC,WAAWF,aAAa;IAC9B,IAAMG,aAAa;IAEnBF,EAAEG,KAAK,CAACF,UAAUC,YAAY;IAE9B,IAAME,WAAWL,aAAa;IAC9B,IAAMM,aAAa;IAEnBL,EAAEG,KAAK,CACLC,UACAC,YACA;IAGFL,EAAEM,GAAG;AACP"}
|
package/dist/filter/filter.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _to_consumable_array from "@swc/helpers/src/_to_consumable_array.mjs";
|
|
2
2
|
import { pipe } from "../pipe/pipe.js";
|
|
3
3
|
import { curry } from "../curry/curry.js";
|
|
4
4
|
import { isMatch } from "../is-match/is-match.js";
|
|
5
5
|
var _filter = function(_fn, _input) {
|
|
6
|
-
var fn = Array.isArray(_fn) ? pipe.apply(void 0,
|
|
6
|
+
var fn = Array.isArray(_fn) ? pipe.apply(void 0, _to_consumable_array(_fn)) : _fn;
|
|
7
7
|
var input = Array.isArray(_input) ? _input : [
|
|
8
8
|
_input
|
|
9
9
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/filter/filter.js"],"sourcesContent":["import { pipe } from \"../pipe/pipe.js\"\nimport { curry } from \"../curry/curry.js\"\nimport { isMatch } from \"../is-match/is-match.js\"\n\nconst _filter = (_fn, _input) => {\n const fn = Array.isArray(_fn) ? pipe(..._fn) : _fn\n const input = Array.isArray(_input) ? _input : [_input]\n const result = []\n\n for (let i = 0, length = input.length; i < length; i++) {\n if (fn(input[i]) === true) {\n result.push(input[i])\n }\n }\n\n return result\n}\n\n/**\n * Filter elements matching a predicate\n *\n * @param {Function} fn Predicate functions\n *\n * @returns {Array}\n *\n * @name filter\n * @tag Array\n * @signature (fn: Function) => (source: Array): Array\n * @signature (fn: Function, source: Array): Array\n */\nexport const filter = curry(_filter)\n\n/**\n * Filter elements matching an object\n *\n * @param {Object} subset The function\n *\n * @returns {Array}\n *\n * @name filterWith\n * @tag Array\n * @signature (subset: Object) => (source: Array): Array\n * @signature (subset: Object, source: Array): Array\n */\nexport const filterWith = curry((subset, input) =>\n _filter(isMatch(subset), input)\n)\n"],"names":["pipe","curry","isMatch","_filter","_fn","_input","fn","Array","isArray","input","result","i","length","push","filter","filterWith","subset"],"mappings":"AAAA;AAAA,SAASA,IAAI,QAAQ,
|
|
1
|
+
{"version":3,"sources":["../../src/filter/filter.js"],"sourcesContent":["import { pipe } from \"../pipe/pipe.js\"\nimport { curry } from \"../curry/curry.js\"\nimport { isMatch } from \"../is-match/is-match.js\"\n\nconst _filter = (_fn, _input) => {\n const fn = Array.isArray(_fn) ? pipe(..._fn) : _fn\n const input = Array.isArray(_input) ? _input : [_input]\n const result = []\n\n for (let i = 0, length = input.length; i < length; i++) {\n if (fn(input[i]) === true) {\n result.push(input[i])\n }\n }\n\n return result\n}\n\n/**\n * Filter elements matching a predicate\n *\n * @param {Function} fn Predicate functions\n *\n * @returns {Array}\n *\n * @name filter\n * @tag Array\n * @signature (fn: Function) => (source: Array): Array\n * @signature (fn: Function, source: Array): Array\n */\nexport const filter = curry(_filter)\n\n/**\n * Filter elements matching an object\n *\n * @param {Object} subset The function\n *\n * @returns {Array}\n *\n * @name filterWith\n * @tag Array\n * @signature (subset: Object) => (source: Array): Array\n * @signature (subset: Object, source: Array): Array\n */\nexport const filterWith = curry((subset, input) =>\n _filter(isMatch(subset), input)\n)\n"],"names":["pipe","curry","isMatch","_filter","_fn","_input","fn","Array","isArray","input","result","i","length","push","filter","filterWith","subset"],"mappings":"AAAA;AAAA,SAASA,IAAI,QAAQ,kBAAiB;AACtC,SAASC,KAAK,QAAQ,oBAAmB;AACzC,SAASC,OAAO,QAAQ,0BAAyB;AAEjD,IAAMC,UAAU,SAACC,KAAKC,QAAW;IAC/B,IAAMC,KAAKC,MAAMC,OAAO,CAACJ,OAAOJ,KAAAA,MAAAA,KAAAA,GAAK,qBAAGI,QAAOA,GAAG;IAClD,IAAMK,QAAQF,MAAMC,OAAO,CAACH,UAAUA,SAAS;QAACA;KAAO;IACvD,IAAMK,SAAS,EAAE;IAEjB,IAAK,IAAIC,IAAI,GAAGC,SAASH,MAAMG,MAAM,EAAED,IAAIC,QAAQD,IAAK;QACtD,IAAIL,GAAGG,KAAK,CAACE,EAAE,MAAM,IAAI,EAAE;YACzBD,OAAOG,IAAI,CAACJ,KAAK,CAACE,EAAE;QACtB,CAAC;IACH;IAEA,OAAOD;AACT;AAEA;;;;;;;;;;;CAWC,GACD,OAAO,IAAMI,SAASb,MAAME,SAAQ;AAEpC;;;;;;;;;;;CAWC,GACD,OAAO,IAAMY,aAAad,MAAM,SAACe,QAAQP;WACvCN,QAAQD,QAAQc,SAASP;GAC1B"}
|
|
@@ -40,7 +40,7 @@ test("filter", function(t) {
|
|
|
40
40
|
{
|
|
41
41
|
id: 4,
|
|
42
42
|
items: 2
|
|
43
|
-
}
|
|
43
|
+
}
|
|
44
44
|
]), [
|
|
45
45
|
{
|
|
46
46
|
id: 3,
|
|
@@ -64,7 +64,7 @@ test("filterWith", function(t) {
|
|
|
64
64
|
{
|
|
65
65
|
id: 4,
|
|
66
66
|
items: 2
|
|
67
|
-
}
|
|
67
|
+
}
|
|
68
68
|
]), [
|
|
69
69
|
{
|
|
70
70
|
id: 2,
|
|
@@ -73,7 +73,7 @@ test("filterWith", function(t) {
|
|
|
73
73
|
{
|
|
74
74
|
id: 4,
|
|
75
75
|
items: 2
|
|
76
|
-
}
|
|
76
|
+
}
|
|
77
77
|
], "Keep items in array that have properties that equal - curried");
|
|
78
78
|
t.deepEqual(filterWith({
|
|
79
79
|
"!id": 2
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/filter/filter.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { isEqual } from \"../is-equal/is-equal.js\"\nimport { read } from \"../read/read.js\"\nimport { filter, filterWith } from \"./filter.js\"\n\ntest(\"filter\", t => {\n t.deepEqual(\n filter(filterElm => filterElm <= 3)([1, 2, 3, 4, 5, 6]),\n [1, 2, 3],\n \"Keep items lower or equal than 3 - curried\"\n )\n\n t.deepEqual(\n filter(filterElm => filterElm <= 3, \"asd\"),\n [],\n \"Run filter for non-array input, treat as array of one (input does not match function) - uncurried\"\n )\n\n t.deepEqual(\n filter(filterElm => filterElm <= 3)(3),\n [3],\n \"Run filter for non-array input, treat as array of one (input matches function)\"\n )\n\n t.deepEqual(\n filter([read(\"items\"), isEqual(1)])([\n { id: 2, items: 2 },\n { id: 3, items: 1 },\n { id: 4, items: 2 },\n ]),\n [{ id: 3, items: 1 }],\n \"Keep items in array that have properties that equal - curried\"\n )\n\n t.end()\n})\n\ntest(\"filterWith\", t => {\n t.deepEqual(\n filterWith({\n items: 2,\n })([\n { id: 2, items: 2 },\n { id: 3, items: 1 },\n { id: 4, items: 2 },\n ]),\n [\n { id: 2, items: 2 },\n { id: 4, items: 2 },\n ],\n \"Keep items in array that have properties that equal - curried\"\n )\n\n t.deepEqual(\n filterWith(\n {\n \"!id\": 2,\n },\n [{ lorem: 2 }, { lorem: 3 }, { id: 2 }]\n ),\n [{ lorem: 2 }, { lorem: 3 }],\n \"Keep items in array that have properties that dont equal - uncurried\"\n )\n\n t.end()\n})\n"],"names":["test","isEqual","read","filter","filterWith","t","deepEqual","filterElm","id","items","end","lorem"],"mappings":"AAAA,OAAOA,
|
|
1
|
+
{"version":3,"sources":["../../src/filter/filter.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { isEqual } from \"../is-equal/is-equal.js\"\nimport { read } from \"../read/read.js\"\nimport { filter, filterWith } from \"./filter.js\"\n\ntest(\"filter\", t => {\n t.deepEqual(\n filter(filterElm => filterElm <= 3)([1, 2, 3, 4, 5, 6]),\n [1, 2, 3],\n \"Keep items lower or equal than 3 - curried\"\n )\n\n t.deepEqual(\n filter(filterElm => filterElm <= 3, \"asd\"),\n [],\n \"Run filter for non-array input, treat as array of one (input does not match function) - uncurried\"\n )\n\n t.deepEqual(\n filter(filterElm => filterElm <= 3)(3),\n [3],\n \"Run filter for non-array input, treat as array of one (input matches function)\"\n )\n\n t.deepEqual(\n filter([read(\"items\"), isEqual(1)])([\n { id: 2, items: 2 },\n { id: 3, items: 1 },\n { id: 4, items: 2 },\n ]),\n [{ id: 3, items: 1 }],\n \"Keep items in array that have properties that equal - curried\"\n )\n\n t.end()\n})\n\ntest(\"filterWith\", t => {\n t.deepEqual(\n filterWith({\n items: 2,\n })([\n { id: 2, items: 2 },\n { id: 3, items: 1 },\n { id: 4, items: 2 },\n ]),\n [\n { id: 2, items: 2 },\n { id: 4, items: 2 },\n ],\n \"Keep items in array that have properties that equal - curried\"\n )\n\n t.deepEqual(\n filterWith(\n {\n \"!id\": 2,\n },\n [{ lorem: 2 }, { lorem: 3 }, { id: 2 }]\n ),\n [{ lorem: 2 }, { lorem: 3 }],\n \"Keep items in array that have properties that dont equal - uncurried\"\n )\n\n t.end()\n})\n"],"names":["test","isEqual","read","filter","filterWith","t","deepEqual","filterElm","id","items","end","lorem"],"mappings":"AAAA,OAAOA,UAAU,OAAM;AAEvB,SAASC,OAAO,QAAQ,0BAAyB;AACjD,SAASC,IAAI,QAAQ,kBAAiB;AACtC,SAASC,MAAM,EAAEC,UAAU,QAAQ,cAAa;AAEhDJ,KAAK,UAAUK,SAAAA,GAAK;IAClBA,EAAEC,SAAS,CACTH,OAAOI,SAAAA;eAAaA,aAAa;OAAG;QAAC;QAAG;QAAG;QAAG;QAAG;QAAG;KAAE,GACtD;QAAC;QAAG;QAAG;KAAE,EACT;IAGFF,EAAEC,SAAS,CACTH,OAAOI,SAAAA;eAAaA,aAAa;OAAG,QACpC,EAAE,EACF;IAGFF,EAAEC,SAAS,CACTH,OAAOI,SAAAA;eAAaA,aAAa;OAAG,IACpC;QAAC;KAAE,EACH;IAGFF,EAAEC,SAAS,CACTH,OAAO;QAACD,KAAK;QAAUD,QAAQ;KAAG,EAAE;QAClC;YAAEO,IAAI;YAAGC,OAAO;QAAE;QAClB;YAAED,IAAI;YAAGC,OAAO;QAAE;QAClB;YAAED,IAAI;YAAGC,OAAO;QAAE;KACnB,GACD;QAAC;YAAED,IAAI;YAAGC,OAAO;QAAE;KAAE,EACrB;IAGFJ,EAAEK,GAAG;AACP;AAEAV,KAAK,cAAcK,SAAAA,GAAK;IACtBA,EAAEC,SAAS,CACTF,WAAW;QACTK,OAAO;IACT,GAAG;QACD;YAAED,IAAI;YAAGC,OAAO;QAAE;QAClB;YAAED,IAAI;YAAGC,OAAO;QAAE;QAClB;YAAED,IAAI;YAAGC,OAAO;QAAE;KACnB,GACD;QACE;YAAED,IAAI;YAAGC,OAAO;QAAE;QAClB;YAAED,IAAI;YAAGC,OAAO;QAAE;KACnB,EACD;IAGFJ,EAAEC,SAAS,CACTF,WACE;QACE,OAAO;IACT,GACA;QAAC;YAAEO,OAAO;QAAE;QAAG;YAAEA,OAAO;QAAE;QAAG;YAAEH,IAAI;QAAE;KAAE,GAEzC;QAAC;YAAEG,OAAO;QAAE;QAAG;YAAEA,OAAO;QAAE;KAAE,EAC5B;IAGFN,EAAEK,GAAG;AACP"}
|
package/dist/find/find.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/* eslint-disable jsdoc/check-param-names,jsdoc/require-param */ import _to_consumable_array from "@swc/helpers/src/_to_consumable_array.mjs";
|
|
2
|
+
import { pipe } from "../pipe/pipe.js";
|
|
3
3
|
import { isMatch } from "../is-match/is-match.js";
|
|
4
4
|
var _find = function(_fn, notFoundDefault, _input) {
|
|
5
|
-
var fn = Array.isArray(_fn) ? pipe.apply(void 0,
|
|
5
|
+
var fn = Array.isArray(_fn) ? pipe.apply(void 0, _to_consumable_array(_fn)) : _fn;
|
|
6
6
|
var input = Array.isArray(_input) ? _input : [
|
|
7
7
|
_input
|
|
8
8
|
];
|
|
@@ -49,7 +49,7 @@ var _find = function(_fn, notFoundDefault, _input) {
|
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
// @signature (fn, notFoundDefault, source)
|
|
52
|
-
return _find.apply(void 0,
|
|
52
|
+
return _find.apply(void 0, _to_consumable_array(params));
|
|
53
53
|
};
|
|
54
54
|
/**
|
|
55
55
|
* Find the first element that matches an object
|
package/dist/find/find.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/find/find.js"],"sourcesContent":["/* eslint-disable jsdoc/check-param-names,jsdoc/require-param */\n\nimport { pipe } from \"../pipe/pipe.js\"\nimport { isMatch } from \"../is-match/is-match.js\"\n\nconst _find = (_fn, notFoundDefault, _input) => {\n const fn = Array.isArray(_fn) ? pipe(..._fn) : _fn\n const input = Array.isArray(_input) ? _input : [_input]\n\n for (let i = 0, length = input.length; i < length; i++) {\n const isFound = fn(input[i], i, input)\n\n if (isFound === true) {\n return input[i]\n }\n }\n\n return notFoundDefault\n}\n\n/**\n * Find the first element that matches a predicate\n *\n * @param {Function|Function[]} fn Match function applied to each element\n * @param {any} notFoundDefault Return if no item found\n * @param {Array} source Source array to iterate over\n *\n * @returns {any}\n *\n * @name find\n * @tag Array\n * @signature (fn: Fn|Fn[], notFoundDefault: Any) => (source: Array): Any\n * @signature (fn: Fn|Fn[], notFoundDefault: Any, source: Array) => Any\n *\n * @see {@link findWith}\n *\n * @example\n * const comments = [{id: 1, body: \"\"}, {id: 2, body: \"dolor\"}]\n *\n * find(item => item.body === \"dolor\")(comments)\n * // => {id: 2, body: \"dolor\"}\n *\n * find([get(\"body\"), equals(\"dolor\")], null, comments)\n * // => {id: 2, boby: \"dolor\" }\n */\nexport const find = (...params) => {\n // @signature (fn, notFoundDefault) => (source)\n if (params.length <= 2) {\n return input => _find(params[0], params[1], input)\n }\n\n // @signature (fn, notFoundDefault, source)\n return _find(...params)\n}\n\n/**\n * Find the first element that matches an object\n *\n * @param {Object} subset Match object\n * @param {any} notFoundDefault Return if no item found\n * @param {Array} source Source array to iterate over\n *\n * @returns {any} First element found or undefined\n *\n * @name findWith\n * @tag Array\n * @signature (subset: Object, notFoundDefault: Any) => (source: Array): Any\n * @signature (subset: Object, notFoundDefault: Any, source: Array) => Any\n *\n * @see {@link find}\n * @see {@link isMatch}\n *\n * @example\n * const comments = [{id: 1, body: \"\"}, {id: 2, body: \"dolor\"}]\n *\n * findWith({id: 2})(comments)\n * // => {id: 2, body: \"dolor\"}\n *\n * find({id: \"404\"}, {default: \"value\"}, comments)\n * // => {default: \"value\"}\n */\nexport const findWith = (...params) => {\n // @signature (subset, notFoundDefault) => (source)\n if (params.length <= 2) {\n return input => _find(isMatch(params[0]), params[1], input)\n }\n\n // @signature (subset, notFoundDefault, source)\n return _find(isMatch(params[0]), params[1], params[2])\n}\n"],"names":["pipe","isMatch","_find","_fn","notFoundDefault","_input","fn","Array","isArray","input","i","length","isFound","find","params","findWith"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/find/find.js"],"sourcesContent":["/* eslint-disable jsdoc/check-param-names,jsdoc/require-param */\n\nimport { pipe } from \"../pipe/pipe.js\"\nimport { isMatch } from \"../is-match/is-match.js\"\n\nconst _find = (_fn, notFoundDefault, _input) => {\n const fn = Array.isArray(_fn) ? pipe(..._fn) : _fn\n const input = Array.isArray(_input) ? _input : [_input]\n\n for (let i = 0, length = input.length; i < length; i++) {\n const isFound = fn(input[i], i, input)\n\n if (isFound === true) {\n return input[i]\n }\n }\n\n return notFoundDefault\n}\n\n/**\n * Find the first element that matches a predicate\n *\n * @param {Function|Function[]} fn Match function applied to each element\n * @param {any} notFoundDefault Return if no item found\n * @param {Array} source Source array to iterate over\n *\n * @returns {any}\n *\n * @name find\n * @tag Array\n * @signature (fn: Fn|Fn[], notFoundDefault: Any) => (source: Array): Any\n * @signature (fn: Fn|Fn[], notFoundDefault: Any, source: Array) => Any\n *\n * @see {@link findWith}\n *\n * @example\n * const comments = [{id: 1, body: \"\"}, {id: 2, body: \"dolor\"}]\n *\n * find(item => item.body === \"dolor\")(comments)\n * // => {id: 2, body: \"dolor\"}\n *\n * find([get(\"body\"), equals(\"dolor\")], null, comments)\n * // => {id: 2, boby: \"dolor\" }\n */\nexport const find = (...params) => {\n // @signature (fn, notFoundDefault) => (source)\n if (params.length <= 2) {\n return input => _find(params[0], params[1], input)\n }\n\n // @signature (fn, notFoundDefault, source)\n return _find(...params)\n}\n\n/**\n * Find the first element that matches an object\n *\n * @param {Object} subset Match object\n * @param {any} notFoundDefault Return if no item found\n * @param {Array} source Source array to iterate over\n *\n * @returns {any} First element found or undefined\n *\n * @name findWith\n * @tag Array\n * @signature (subset: Object, notFoundDefault: Any) => (source: Array): Any\n * @signature (subset: Object, notFoundDefault: Any, source: Array) => Any\n *\n * @see {@link find}\n * @see {@link isMatch}\n *\n * @example\n * const comments = [{id: 1, body: \"\"}, {id: 2, body: \"dolor\"}]\n *\n * findWith({id: 2})(comments)\n * // => {id: 2, body: \"dolor\"}\n *\n * find({id: \"404\"}, {default: \"value\"}, comments)\n * // => {default: \"value\"}\n */\nexport const findWith = (...params) => {\n // @signature (subset, notFoundDefault) => (source)\n if (params.length <= 2) {\n return input => _find(isMatch(params[0]), params[1], input)\n }\n\n // @signature (subset, notFoundDefault, source)\n return _find(isMatch(params[0]), params[1], params[2])\n}\n"],"names":["pipe","isMatch","_find","_fn","notFoundDefault","_input","fn","Array","isArray","input","i","length","isFound","find","params","findWith"],"mappings":"AAAA,8DAA8D,GAE9D;AAAA,SAASA,IAAI,QAAQ,kBAAiB;AACtC,SAASC,OAAO,QAAQ,0BAAyB;AAEjD,IAAMC,QAAQ,SAACC,KAAKC,iBAAiBC,QAAW;IAC9C,IAAMC,KAAKC,MAAMC,OAAO,CAACL,OAAOH,KAAAA,MAAAA,KAAAA,GAAK,qBAAGG,QAAOA,GAAG;IAClD,IAAMM,QAAQF,MAAMC,OAAO,CAACH,UAAUA,SAAS;QAACA;KAAO;IAEvD,IAAK,IAAIK,IAAI,GAAGC,SAASF,MAAME,MAAM,EAAED,IAAIC,QAAQD,IAAK;QACtD,IAAME,UAAUN,GAAGG,KAAK,CAACC,EAAE,EAAEA,GAAGD;QAEhC,IAAIG,YAAY,IAAI,EAAE;YACpB,OAAOH,KAAK,CAACC,EAAE;QACjB,CAAC;IACH;IAEA,OAAON;AACT;AAEA;;;;;;;;;;;;;;;;;;;;;;;;CAwBC,GACD,OAAO,IAAMS,OAAO,WAAe;qCAAXC;QAAAA;;IACtB,+CAA+C;IAC/C,IAAIA,OAAOH,MAAM,IAAI,GAAG;QACtB,OAAOF,SAAAA;mBAASP,MAAMY,MAAM,CAAC,EAAE,EAAEA,MAAM,CAAC,EAAE,EAAEL;;IAC9C,CAAC;IAED,2CAA2C;IAC3C,OAAOP,MAAAA,MAAAA,KAAAA,GAAM,qBAAGY;AAClB,EAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;CAyBC,GACD,OAAO,IAAMC,WAAW,WAAe;qCAAXD;QAAAA;;IAC1B,mDAAmD;IACnD,IAAIA,OAAOH,MAAM,IAAI,GAAG;QACtB,OAAOF,SAAAA;mBAASP,MAAMD,QAAQa,MAAM,CAAC,EAAE,GAAGA,MAAM,CAAC,EAAE,EAAEL;;IACvD,CAAC;IAED,+CAA+C;IAC/C,OAAOP,MAAMD,QAAQa,MAAM,CAAC,EAAE,GAAGA,MAAM,CAAC,EAAE,EAAEA,MAAM,CAAC,EAAE;AACvD,EAAC"}
|
package/dist/find/find.test.js
CHANGED
|
@@ -9,7 +9,7 @@ test("find", function(t) {
|
|
|
9
9
|
{
|
|
10
10
|
id: 2,
|
|
11
11
|
body: "dolor"
|
|
12
|
-
}
|
|
12
|
+
}
|
|
13
13
|
];
|
|
14
14
|
t.deepEqual(find([
|
|
15
15
|
function(element) {
|
|
@@ -45,7 +45,7 @@ test("findWith", function(t) {
|
|
|
45
45
|
{
|
|
46
46
|
id: 2,
|
|
47
47
|
body: "dolor"
|
|
48
|
-
}
|
|
48
|
+
}
|
|
49
49
|
];
|
|
50
50
|
t.deepEqual(findWith({
|
|
51
51
|
id: 2,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/find/find.test.js"],"sourcesContent":["/* eslint-disable unicorn/no-null */\n\nimport test from \"tape\"\n\nimport { find, findWith } from \"./find.js\"\n\ntest(\"find\", t => {\n const comments = [\n { id: 1, body: \"\" },\n { id: 2, body: \"dolor\" },\n ]\n\n t.deepEqual(\n find([element => element.id, item => item === 2], null, comments),\n { id: 2, body: \"dolor\" },\n \"find with id:2 should return found object (uncurried multipe functions)\"\n )\n\n t.deepEqual(\n find(element => element.id === 2)(comments),\n { id: 2, body: \"dolor\" },\n \"find with id:2 should return found object\"\n )\n\n t.equal(\n find(element => element.id === 3)(comments),\n undefined,\n \"find with id:3 should return undefined (not found)\"\n )\n\n t.deepEqual(\n find(element => element.id === 3, {})(comments),\n {},\n \"find with id:3 should return default not found value\"\n )\n\n t.end()\n})\n\ntest(\"findWith\", t => {\n const comments = [\n { id: 1, body: \"\" },\n { id: 2, body: \"dolor\" },\n ]\n\n t.deepEqual(\n findWith({\n id: 2,\n body: input => input === \"dolor\",\n })(comments),\n { id: 2, body: \"dolor\" },\n \"given [matching object with value and predicate fields] should [return existing item]\"\n )\n\n t.deepEqual(\n findWith({ id: 2 })([]),\n undefined,\n \"find with id:2 in empty array should return undefined\"\n )\n\n t.deepEqual(\n findWith({ id: 2 })(comments),\n { id: 2, body: \"dolor\" },\n \"find with id:2 should return found object\"\n )\n\n t.equals(\n findWith({ id: 3 })(comments),\n undefined,\n \"find with id:3 should return undefined (not found)\"\n )\n\n t.deepEquals(\n findWith({ id: 3 }, {})(comments),\n {},\n \"find with id:3 should return default value (not found)\"\n )\n t.end()\n})\n"],"names":["test","find","findWith","t","comments","id","body","deepEqual","element","item","equal","undefined","end","input","equals","deepEquals"],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/find/find.test.js"],"sourcesContent":["/* eslint-disable unicorn/no-null */\n\nimport test from \"tape\"\n\nimport { find, findWith } from \"./find.js\"\n\ntest(\"find\", t => {\n const comments = [\n { id: 1, body: \"\" },\n { id: 2, body: \"dolor\" },\n ]\n\n t.deepEqual(\n find([element => element.id, item => item === 2], null, comments),\n { id: 2, body: \"dolor\" },\n \"find with id:2 should return found object (uncurried multipe functions)\"\n )\n\n t.deepEqual(\n find(element => element.id === 2)(comments),\n { id: 2, body: \"dolor\" },\n \"find with id:2 should return found object\"\n )\n\n t.equal(\n find(element => element.id === 3)(comments),\n undefined,\n \"find with id:3 should return undefined (not found)\"\n )\n\n t.deepEqual(\n find(element => element.id === 3, {})(comments),\n {},\n \"find with id:3 should return default not found value\"\n )\n\n t.end()\n})\n\ntest(\"findWith\", t => {\n const comments = [\n { id: 1, body: \"\" },\n { id: 2, body: \"dolor\" },\n ]\n\n t.deepEqual(\n findWith({\n id: 2,\n body: input => input === \"dolor\",\n })(comments),\n { id: 2, body: \"dolor\" },\n \"given [matching object with value and predicate fields] should [return existing item]\"\n )\n\n t.deepEqual(\n findWith({ id: 2 })([]),\n undefined,\n \"find with id:2 in empty array should return undefined\"\n )\n\n t.deepEqual(\n findWith({ id: 2 })(comments),\n { id: 2, body: \"dolor\" },\n \"find with id:2 should return found object\"\n )\n\n t.equals(\n findWith({ id: 3 })(comments),\n undefined,\n \"find with id:3 should return undefined (not found)\"\n )\n\n t.deepEquals(\n findWith({ id: 3 }, {})(comments),\n {},\n \"find with id:3 should return default value (not found)\"\n )\n t.end()\n})\n"],"names":["test","find","findWith","t","comments","id","body","deepEqual","element","item","equal","undefined","end","input","equals","deepEquals"],"mappings":"AAAA,kCAAkC,GAElC,OAAOA,UAAU,OAAM;AAEvB,SAASC,IAAI,EAAEC,QAAQ,QAAQ,YAAW;AAE1CF,KAAK,QAAQG,SAAAA,GAAK;IAChB,IAAMC,WAAW;QACf;YAAEC,IAAI;YAAGC,MAAM;QAAG;QAClB;YAAED,IAAI;YAAGC,MAAM;QAAQ;KACxB;IAEDH,EAAEI,SAAS,CACTN,KAAK;QAACO,SAAAA;mBAAWA,QAAQH,EAAE;;QAAEI,SAAAA;mBAAQA,SAAS;;KAAE,EAAE,IAAI,EAAEL,WACxD;QAAEC,IAAI;QAAGC,MAAM;IAAQ,GACvB;IAGFH,EAAEI,SAAS,CACTN,KAAKO,SAAAA;eAAWA,QAAQH,EAAE,KAAK;OAAGD,WAClC;QAAEC,IAAI;QAAGC,MAAM;IAAQ,GACvB;IAGFH,EAAEO,KAAK,CACLT,KAAKO,SAAAA;eAAWA,QAAQH,EAAE,KAAK;OAAGD,WAClCO,WACA;IAGFR,EAAEI,SAAS,CACTN,KAAKO,SAAAA;eAAWA,QAAQH,EAAE,KAAK;OAAG,CAAC,GAAGD,WACtC,CAAC,GACD;IAGFD,EAAES,GAAG;AACP;AAEAZ,KAAK,YAAYG,SAAAA,GAAK;IACpB,IAAMC,WAAW;QACf;YAAEC,IAAI;YAAGC,MAAM;QAAG;QAClB;YAAED,IAAI;YAAGC,MAAM;QAAQ;KACxB;IAEDH,EAAEI,SAAS,CACTL,SAAS;QACPG,IAAI;QACJC,MAAMO,SAAAA;mBAASA,UAAU;;IAC3B,GAAGT,WACH;QAAEC,IAAI;QAAGC,MAAM;IAAQ,GACvB;IAGFH,EAAEI,SAAS,CACTL,SAAS;QAAEG,IAAI;IAAE,GAAG,EAAE,GACtBM,WACA;IAGFR,EAAEI,SAAS,CACTL,SAAS;QAAEG,IAAI;IAAE,GAAGD,WACpB;QAAEC,IAAI;QAAGC,MAAM;IAAQ,GACvB;IAGFH,EAAEW,MAAM,CACNZ,SAAS;QAAEG,IAAI;IAAE,GAAGD,WACpBO,WACA;IAGFR,EAAEY,UAAU,CACVb,SAAS;QAAEG,IAAI;IAAE,GAAG,CAAC,GAAGD,WACxB,CAAC,GACD;IAEFD,EAAES,GAAG;AACP"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _to_consumable_array from "@swc/helpers/src/_to_consumable_array.mjs";
|
|
2
2
|
import { pipe } from "../pipe/pipe.js";
|
|
3
3
|
import { curry } from "../curry/curry.js";
|
|
4
4
|
import { isMatch } from "../is-match/is-match.js";
|
|
5
5
|
var _findIndex = function(_fn, _input) {
|
|
6
|
-
var fn = Array.isArray(_fn) ? pipe.apply(void 0,
|
|
6
|
+
var fn = Array.isArray(_fn) ? pipe.apply(void 0, _to_consumable_array(_fn)) : _fn;
|
|
7
7
|
var input = Array.isArray(_input) ? _input : [
|
|
8
8
|
_input
|
|
9
9
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/find-index/find-index.js"],"sourcesContent":["import { pipe } from \"../pipe/pipe.js\"\nimport { curry } from \"../curry/curry.js\"\nimport { isMatch } from \"../is-match/is-match.js\"\n\nconst _findIndex = (_fn, _input) => {\n const fn = Array.isArray(_fn) ? pipe(..._fn) : _fn\n const input = Array.isArray(_input) ? _input : [_input]\n\n for (let i = 0, length = input.length; i < length; i++) {\n const found = fn(input[i], i, input)\n\n if (found === true) {\n return i\n }\n }\n\n return -1\n}\n\n/**\n * Find the position the first element that satisfies a predicate function\n *\n * @param {Function|Function[]} fn Predicate applied to each element\n * @param {Object[]} source Source array to iterate over\n *\n * @returns {number} Position of found element or -1 if not found\n *\n * @name findIndex\n * @tag Array\n * @signature (fn: Function, source: Object[]): Number\n *\n * @example\n * const comments = [{id: 1, body: \"\"}, {id: 2, body: \"dolor\"}]\n *\n * findIndex(item => item.body === \"lorem\")(comments)\n * // => -1\n *\n * findIndex([get(\"body\"), equals(\"dolor\")], null, comments)\n * // => 1\n */\nexport const findIndex = curry(_findIndex)\n\nexport const findIndexWith = curry((subset, input) =>\n _findIndex(isMatch(subset), input)\n)\n"],"names":["pipe","curry","isMatch","_findIndex","_fn","_input","fn","Array","isArray","input","i","length","found","findIndex","findIndexWith","subset"],"mappings":"AAAA;AAAA,SAASA,IAAI,QAAQ,
|
|
1
|
+
{"version":3,"sources":["../../src/find-index/find-index.js"],"sourcesContent":["import { pipe } from \"../pipe/pipe.js\"\nimport { curry } from \"../curry/curry.js\"\nimport { isMatch } from \"../is-match/is-match.js\"\n\nconst _findIndex = (_fn, _input) => {\n const fn = Array.isArray(_fn) ? pipe(..._fn) : _fn\n const input = Array.isArray(_input) ? _input : [_input]\n\n for (let i = 0, length = input.length; i < length; i++) {\n const found = fn(input[i], i, input)\n\n if (found === true) {\n return i\n }\n }\n\n return -1\n}\n\n/**\n * Find the position the first element that satisfies a predicate function\n *\n * @param {Function|Function[]} fn Predicate applied to each element\n * @param {Object[]} source Source array to iterate over\n *\n * @returns {number} Position of found element or -1 if not found\n *\n * @name findIndex\n * @tag Array\n * @signature (fn: Function, source: Object[]): Number\n *\n * @example\n * const comments = [{id: 1, body: \"\"}, {id: 2, body: \"dolor\"}]\n *\n * findIndex(item => item.body === \"lorem\")(comments)\n * // => -1\n *\n * findIndex([get(\"body\"), equals(\"dolor\")], null, comments)\n * // => 1\n */\nexport const findIndex = curry(_findIndex)\n\nexport const findIndexWith = curry((subset, input) =>\n _findIndex(isMatch(subset), input)\n)\n"],"names":["pipe","curry","isMatch","_findIndex","_fn","_input","fn","Array","isArray","input","i","length","found","findIndex","findIndexWith","subset"],"mappings":"AAAA;AAAA,SAASA,IAAI,QAAQ,kBAAiB;AACtC,SAASC,KAAK,QAAQ,oBAAmB;AACzC,SAASC,OAAO,QAAQ,0BAAyB;AAEjD,IAAMC,aAAa,SAACC,KAAKC,QAAW;IAClC,IAAMC,KAAKC,MAAMC,OAAO,CAACJ,OAAOJ,KAAAA,MAAAA,KAAAA,GAAK,qBAAGI,QAAOA,GAAG;IAClD,IAAMK,QAAQF,MAAMC,OAAO,CAACH,UAAUA,SAAS;QAACA;KAAO;IAEvD,IAAK,IAAIK,IAAI,GAAGC,SAASF,MAAME,MAAM,EAAED,IAAIC,QAAQD,IAAK;QACtD,IAAME,QAAQN,GAAGG,KAAK,CAACC,EAAE,EAAEA,GAAGD;QAE9B,IAAIG,UAAU,IAAI,EAAE;YAClB,OAAOF;QACT,CAAC;IACH;IAEA,OAAO,CAAC;AACV;AAEA;;;;;;;;;;;;;;;;;;;;CAoBC,GACD,OAAO,IAAMG,YAAYZ,MAAME,YAAW;AAE1C,OAAO,IAAMW,gBAAgBb,MAAM,SAACc,QAAQN;WAC1CN,WAAWD,QAAQa,SAASN;GAC7B"}
|
|
@@ -9,7 +9,7 @@ test("findIndex", function(t) {
|
|
|
9
9
|
{
|
|
10
10
|
id: 2,
|
|
11
11
|
body: "dolor"
|
|
12
|
-
}
|
|
12
|
+
}
|
|
13
13
|
];
|
|
14
14
|
t.equals(findIndex(function(element) {
|
|
15
15
|
return element.id === 2;
|
|
@@ -36,7 +36,7 @@ test("findIndexWith", function(t) {
|
|
|
36
36
|
{
|
|
37
37
|
id: 2,
|
|
38
38
|
body: "dolor"
|
|
39
|
-
}
|
|
39
|
+
}
|
|
40
40
|
];
|
|
41
41
|
t.equals(findIndexWith({
|
|
42
42
|
id: 2
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/find-index/find-index.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { findIndex, findIndexWith } from \"./find-index.js\"\n\ntest(\"findIndex\", t => {\n const comments = [\n { id: 1, body: \"\" },\n { id: 2, body: \"dolor\" },\n ]\n\n t.equals(\n findIndex(element => element.id === 2)(comments),\n 1,\n \"index with id:2 should be 1\"\n )\n\n t.equals(\n findIndex([element => element.id, item => item === 2], comments),\n 1,\n \"index with id:2 should be 1 (uncurried multipe functions)\"\n )\n\n t.equals(\n findIndex(element => element.id === 3)(comments),\n -1,\n \"index with id:3 should be -1 (not found)\"\n )\n\n t.end()\n})\n\ntest(\"findIndexWith\", t => {\n const comments = [\n { id: 1, body: \"\" },\n { id: 2, body: \"dolor\" },\n ]\n\n t.equals(\n findIndexWith({ id: 2 })([]),\n -1,\n \"index of id:2 in empty array should be -1\"\n )\n\n t.equals(findIndexWith({ id: 2 })(comments), 1, \"index of id:2 should be 1\")\n\n t.equals(\n findIndexWith({ id: 3 })(comments),\n -1,\n \"index id:3 should be -1 (not found)\"\n )\n\n t.end()\n})\n"],"names":["test","findIndex","findIndexWith","t","comments","id","body","equals","element","item","end"],"mappings":"AAAA,OAAOA,
|
|
1
|
+
{"version":3,"sources":["../../src/find-index/find-index.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { findIndex, findIndexWith } from \"./find-index.js\"\n\ntest(\"findIndex\", t => {\n const comments = [\n { id: 1, body: \"\" },\n { id: 2, body: \"dolor\" },\n ]\n\n t.equals(\n findIndex(element => element.id === 2)(comments),\n 1,\n \"index with id:2 should be 1\"\n )\n\n t.equals(\n findIndex([element => element.id, item => item === 2], comments),\n 1,\n \"index with id:2 should be 1 (uncurried multipe functions)\"\n )\n\n t.equals(\n findIndex(element => element.id === 3)(comments),\n -1,\n \"index with id:3 should be -1 (not found)\"\n )\n\n t.end()\n})\n\ntest(\"findIndexWith\", t => {\n const comments = [\n { id: 1, body: \"\" },\n { id: 2, body: \"dolor\" },\n ]\n\n t.equals(\n findIndexWith({ id: 2 })([]),\n -1,\n \"index of id:2 in empty array should be -1\"\n )\n\n t.equals(findIndexWith({ id: 2 })(comments), 1, \"index of id:2 should be 1\")\n\n t.equals(\n findIndexWith({ id: 3 })(comments),\n -1,\n \"index id:3 should be -1 (not found)\"\n )\n\n t.end()\n})\n"],"names":["test","findIndex","findIndexWith","t","comments","id","body","equals","element","item","end"],"mappings":"AAAA,OAAOA,UAAU,OAAM;AAEvB,SAASC,SAAS,EAAEC,aAAa,QAAQ,kBAAiB;AAE1DF,KAAK,aAAaG,SAAAA,GAAK;IACrB,IAAMC,WAAW;QACf;YAAEC,IAAI;YAAGC,MAAM;QAAG;QAClB;YAAED,IAAI;YAAGC,MAAM;QAAQ;KACxB;IAEDH,EAAEI,MAAM,CACNN,UAAUO,SAAAA;eAAWA,QAAQH,EAAE,KAAK;OAAGD,WACvC,GACA;IAGFD,EAAEI,MAAM,CACNN,UAAU;QAACO,SAAAA;mBAAWA,QAAQH,EAAE;;QAAEI,SAAAA;mBAAQA,SAAS;;KAAE,EAAEL,WACvD,GACA;IAGFD,EAAEI,MAAM,CACNN,UAAUO,SAAAA;eAAWA,QAAQH,EAAE,KAAK;OAAGD,WACvC,CAAC,GACD;IAGFD,EAAEO,GAAG;AACP;AAEAV,KAAK,iBAAiBG,SAAAA,GAAK;IACzB,IAAMC,WAAW;QACf;YAAEC,IAAI;YAAGC,MAAM;QAAG;QAClB;YAAED,IAAI;YAAGC,MAAM;QAAQ;KACxB;IAEDH,EAAEI,MAAM,CACNL,cAAc;QAAEG,IAAI;IAAE,GAAG,EAAE,GAC3B,CAAC,GACD;IAGFF,EAAEI,MAAM,CAACL,cAAc;QAAEG,IAAI;IAAE,GAAGD,WAAW,GAAG;IAEhDD,EAAEI,MAAM,CACNL,cAAc;QAAEG,IAAI;IAAE,GAAGD,WACzB,CAAC,GACD;IAGFD,EAAEO,GAAG;AACP"}
|
package/dist/first/first.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/first/first.js"],"sourcesContent":["/**\n * Get left most element of array\n *\n * @param {Array} input The source\n *\n * @returns {any}\n *\n * @tag Array\n * @signature (source: Array): mixed\n *\n * @example\n * first([1, 2, 3])\n * // => 1\n *\n * first([])\n * // => undefined\n */\nexport const first = input =>\n (Array.isArray(input) || typeof input === \"string\") && input.length !== 0\n ? input[0]\n : undefined\n"],"names":["first","input","Array","isArray","length","undefined"],"mappings":"AAAA;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../src/first/first.js"],"sourcesContent":["/**\n * Get left most element of array\n *\n * @param {Array} input The source\n *\n * @returns {any}\n *\n * @tag Array\n * @signature (source: Array): mixed\n *\n * @example\n * first([1, 2, 3])\n * // => 1\n *\n * first([])\n * // => undefined\n */\nexport const first = input =>\n (Array.isArray(input) || typeof input === \"string\") && input.length !== 0\n ? input[0]\n : undefined\n"],"names":["first","input","Array","isArray","length","undefined"],"mappings":"AAAA;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,IAAMA,QAAQC,SAAAA;WACnB,AAACC,CAAAA,MAAMC,OAAO,CAACF,UAAU,OAAOA,UAAU,QAAO,KAAMA,MAAMG,MAAM,KAAK,IACpEH,KAAK,CAAC,EAAE,GACRI,SAAS;EAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/first/first.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { first } from \"./first.js\"\n\ntest(\"first\", t => {\n t.equal(first(\"xyz\"), \"x\", \"From string should return first char\")\n t.equal(first([1, 2, 3]), 1, \"From number array should return first element\")\n t.equal(first([]), undefined, \"From empty array should return undefined\")\n t.equal(first(2), undefined, \"From number should return undefined\")\n t.equal(first({}), undefined, \"From object should return undefined\")\n t.equal(\n first(() => {}),\n undefined,\n \"From function should return undefined\"\n )\n\n t.end()\n})\n"],"names":["test","first","t","equal","undefined","end"],"mappings":"AAAA,OAAOA,
|
|
1
|
+
{"version":3,"sources":["../../src/first/first.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { first } from \"./first.js\"\n\ntest(\"first\", t => {\n t.equal(first(\"xyz\"), \"x\", \"From string should return first char\")\n t.equal(first([1, 2, 3]), 1, \"From number array should return first element\")\n t.equal(first([]), undefined, \"From empty array should return undefined\")\n t.equal(first(2), undefined, \"From number should return undefined\")\n t.equal(first({}), undefined, \"From object should return undefined\")\n t.equal(\n first(() => {}),\n undefined,\n \"From function should return undefined\"\n )\n\n t.end()\n})\n"],"names":["test","first","t","equal","undefined","end"],"mappings":"AAAA,OAAOA,UAAU,OAAM;AAEvB,SAASC,KAAK,QAAQ,aAAY;AAElCD,KAAK,SAASE,SAAAA,GAAK;IACjBA,EAAEC,KAAK,CAACF,MAAM,QAAQ,KAAK;IAC3BC,EAAEC,KAAK,CAACF,MAAM;QAAC;QAAG;QAAG;KAAE,GAAG,GAAG;IAC7BC,EAAEC,KAAK,CAACF,MAAM,EAAE,GAAGG,WAAW;IAC9BF,EAAEC,KAAK,CAACF,MAAM,IAAIG,WAAW;IAC7BF,EAAEC,KAAK,CAACF,MAAM,CAAC,IAAIG,WAAW;IAC9BF,EAAEC,KAAK,CACLF,MAAM,WAAM,CAAC,IACbG,WACA;IAGFF,EAAEG,GAAG;AACP"}
|
package/dist/flatten/flatten.js
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _define_property from "@swc/helpers/src/_define_property.mjs";
|
|
2
|
+
import _object_spread from "@swc/helpers/src/_object_spread.mjs";
|
|
3
|
+
import _object_spread_props from "@swc/helpers/src/_object_spread_props.mjs";
|
|
4
|
+
import _sliced_to_array from "@swc/helpers/src/_sliced_to_array.mjs";
|
|
5
|
+
import _to_consumable_array from "@swc/helpers/src/_to_consumable_array.mjs";
|
|
2
6
|
import { reduce } from "../reduce/reduce.js";
|
|
3
7
|
import { is, isObject } from "../is/is.js";
|
|
4
8
|
var flattenArray = reduce(function(acc, item) {
|
|
5
|
-
return Array.isArray(item) ?
|
|
9
|
+
return Array.isArray(item) ? _to_consumable_array(acc).concat(_to_consumable_array(flattenArray(item))) : _to_consumable_array(acc).concat([
|
|
6
10
|
item
|
|
7
11
|
]);
|
|
8
12
|
}, []);
|
|
9
13
|
var flattenObject = function(input, prefix) {
|
|
10
14
|
return reduce(function(acc, param) {
|
|
11
|
-
var _param =
|
|
12
|
-
return isObject(value) ?
|
|
15
|
+
var _param = _sliced_to_array(param, 2), key = _param[0], value = _param[1];
|
|
16
|
+
return isObject(value) ? _object_spread({}, acc, flattenObject(value, is(prefix) ? "".concat(prefix, "__").concat(key) : key)) : _object_spread_props(_object_spread({}, acc), _define_property({}, is(prefix) ? "".concat(prefix, "__").concat(key) : key, value));
|
|
13
17
|
}, {})(Object.entries(input));
|
|
14
18
|
};
|
|
15
19
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/flatten/flatten.js"],"sourcesContent":["import { reduce } from \"../reduce/reduce.js\"\nimport { is, isObject } from \"../is/is.js\"\n\nconst flattenArray = reduce(\n (acc, item) =>\n Array.isArray(item) ? [...acc, ...flattenArray(item)] : [...acc, item],\n []\n)\n\nconst flattenObject = (input, prefix) =>\n reduce((acc, [key, value]) => {\n return isObject(value)\n ? {\n ...acc,\n ...flattenObject(value, is(prefix) ? `${prefix}__${key}` : key),\n }\n : {\n ...acc,\n [is(prefix) ? `${prefix}__${key}` : key]: value,\n }\n }, {})(Object.entries(input))\n\n/**\n * Recursively concat all arrays intro a single array\n *\n * @param {Array|Object} input Array or Object to flatten\n *\n * @returns {Array} 1 level deep array\n *\n * @example\n * flatten([1, [2], [3, [4]]])\n * // => [1, 2, 3, 4]\n *\n * flatten({test: {a: 1, b: {c: 2}}})\n * // => {\n * test__a: 1,\n * test__b__c: 2\n * }\n */\nconst flatten = input => {\n if (Array.isArray(input)) {\n return flattenArray(input)\n }\n\n if (typeof input === \"object\") {\n return flattenObject(input)\n }\n\n return input\n}\n\nexport { flatten }\n"],"names":["reduce","is","isObject","flattenArray","acc","item","Array","isArray","flattenObject","input","prefix","key","value","Object","entries","flatten"],"mappings":"AAAA
|
|
1
|
+
{"version":3,"sources":["../../src/flatten/flatten.js"],"sourcesContent":["import { reduce } from \"../reduce/reduce.js\"\nimport { is, isObject } from \"../is/is.js\"\n\nconst flattenArray = reduce(\n (acc, item) =>\n Array.isArray(item) ? [...acc, ...flattenArray(item)] : [...acc, item],\n []\n)\n\nconst flattenObject = (input, prefix) =>\n reduce((acc, [key, value]) => {\n return isObject(value)\n ? {\n ...acc,\n ...flattenObject(value, is(prefix) ? `${prefix}__${key}` : key),\n }\n : {\n ...acc,\n [is(prefix) ? `${prefix}__${key}` : key]: value,\n }\n }, {})(Object.entries(input))\n\n/**\n * Recursively concat all arrays intro a single array\n *\n * @param {Array|Object} input Array or Object to flatten\n *\n * @returns {Array} 1 level deep array\n *\n * @example\n * flatten([1, [2], [3, [4]]])\n * // => [1, 2, 3, 4]\n *\n * flatten({test: {a: 1, b: {c: 2}}})\n * // => {\n * test__a: 1,\n * test__b__c: 2\n * }\n */\nconst flatten = input => {\n if (Array.isArray(input)) {\n return flattenArray(input)\n }\n\n if (typeof input === \"object\") {\n return flattenObject(input)\n }\n\n return input\n}\n\nexport { flatten }\n"],"names":["reduce","is","isObject","flattenArray","acc","item","Array","isArray","flattenObject","input","prefix","key","value","Object","entries","flatten"],"mappings":"AAAA;;;;;AAAA,SAASA,MAAM,QAAQ,sBAAqB;AAC5C,SAASC,EAAE,EAAEC,QAAQ,QAAQ,cAAa;AAE1C,IAAMC,eAAeH,OACnB,SAACI,KAAKC;WACJC,MAAMC,OAAO,CAACF,QAAQ,AAAC,qBAAGD,YAAK,qBAAGD,aAAaE,UAAS,AAAC,qBAAGD,YAAJ;QAASC;KAAK,CAAA;GACxE,EAAE;AAGJ,IAAMG,gBAAgB,SAACC,OAAOC;WAC5BV,OAAO,SAACI,YAAsB;iDAAhBO,iBAAKC;QACjB,OAAOV,SAASU,SACZ,mBACKR,KACAI,cAAcI,OAAOX,GAAGS,UAAU,AAAC,GAAaC,OAAXD,QAAO,MAAQ,OAAJC,OAAQA,GAAG,KAEhE,wCACKP,MACH,qBAACH,GAAGS,UAAU,AAAC,GAAaC,OAAXD,QAAO,MAAQ,OAAJC,OAAQA,GAAG,EAAGC,OAC3C;IACP,GAAG,CAAC,GAAGC,OAAOC,OAAO,CAACL;;AAExB;;;;;;;;;;;;;;;;CAgBC,GACD,IAAMM,UAAUN,SAAAA,OAAS;IACvB,IAAIH,MAAMC,OAAO,CAACE,QAAQ;QACxB,OAAON,aAAaM;IACtB,CAAC;IAED,IAAI,OAAOA,UAAU,UAAU;QAC7B,OAAOD,cAAcC;IACvB,CAAC;IAED,OAAOA;AACT;AAEA,SAASM,OAAO,GAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/flatten/flatten.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { flatten } from \"./flatten.js\"\n\ntest(\"flatten\", t => {\n t.equals(flatten(3), 3, \"Flatten primitive returns same value\")\n t.deepEqual(flatten([]), [], \"[] should equal []\")\n t.deepEqual(flatten([[[]]]), [], \"[[[]]] should equal []\")\n t.deepEqual(flatten([[[1]]]), [1], \"[[[1]]] should equal [1]\")\n t.deepEqual(\n flatten([1, [2], [3, [4]]]),\n [1, 2, 3, 4],\n \"[1, [2], [3, [4]], []] should equal [1, 2, 3, 4]\"\n )\n\n t.deepEqual(\n flatten({\n test: {\n inside: \"one\",\n another: \"two\",\n lvl: {\n three: \"3\",\n },\n },\n lorem: \"ipsum\",\n an_array: [1, 2],\n }),\n {\n test__inside: \"one\",\n test__another: \"two\",\n test__lvl__three: \"3\",\n lorem: \"ipsum\",\n an_array: [1, 2],\n },\n \"Nested objects should return one lvl deep object\"\n )\n\n t.end()\n})\n"],"names":["test","flatten","t","equals","deepEqual","inside","another","lvl","three","lorem","an_array","test__inside","test__another","test__lvl__three","end"],"mappings":"AAAA,OAAOA,
|
|
1
|
+
{"version":3,"sources":["../../src/flatten/flatten.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { flatten } from \"./flatten.js\"\n\ntest(\"flatten\", t => {\n t.equals(flatten(3), 3, \"Flatten primitive returns same value\")\n t.deepEqual(flatten([]), [], \"[] should equal []\")\n t.deepEqual(flatten([[[]]]), [], \"[[[]]] should equal []\")\n t.deepEqual(flatten([[[1]]]), [1], \"[[[1]]] should equal [1]\")\n t.deepEqual(\n flatten([1, [2], [3, [4]]]),\n [1, 2, 3, 4],\n \"[1, [2], [3, [4]], []] should equal [1, 2, 3, 4]\"\n )\n\n t.deepEqual(\n flatten({\n test: {\n inside: \"one\",\n another: \"two\",\n lvl: {\n three: \"3\",\n },\n },\n lorem: \"ipsum\",\n an_array: [1, 2],\n }),\n {\n test__inside: \"one\",\n test__another: \"two\",\n test__lvl__three: \"3\",\n lorem: \"ipsum\",\n an_array: [1, 2],\n },\n \"Nested objects should return one lvl deep object\"\n )\n\n t.end()\n})\n"],"names":["test","flatten","t","equals","deepEqual","inside","another","lvl","three","lorem","an_array","test__inside","test__another","test__lvl__three","end"],"mappings":"AAAA,OAAOA,UAAU,OAAM;AAEvB,SAASC,OAAO,QAAQ,eAAc;AAEtCD,KAAK,WAAWE,SAAAA,GAAK;IACnBA,EAAEC,MAAM,CAACF,QAAQ,IAAI,GAAG;IACxBC,EAAEE,SAAS,CAACH,QAAQ,EAAE,GAAG,EAAE,EAAE;IAC7BC,EAAEE,SAAS,CAACH,QAAQ;QAAC;YAAC,EAAE;SAAC;KAAC,GAAG,EAAE,EAAE;IACjCC,EAAEE,SAAS,CAACH,QAAQ;QAAC;YAAC;gBAAC;aAAE;SAAC;KAAC,GAAG;QAAC;KAAE,EAAE;IACnCC,EAAEE,SAAS,CACTH,QAAQ;QAAC;QAAG;YAAC;SAAE;QAAE;YAAC;YAAG;gBAAC;aAAE;SAAC;KAAC,GAC1B;QAAC;QAAG;QAAG;QAAG;KAAE,EACZ;IAGFC,EAAEE,SAAS,CACTH,QAAQ;QACND,MAAM;YACJK,QAAQ;YACRC,SAAS;YACTC,KAAK;gBACHC,OAAO;YACT;QACF;QACAC,OAAO;QACPC,UAAU;YAAC;YAAG;SAAE;IAClB,IACA;QACEC,cAAc;QACdC,eAAe;QACfC,kBAAkB;QAClBJ,OAAO;QACPC,UAAU;YAAC;YAAG;SAAE;IAClB,GACA;IAGFR,EAAEY,GAAG;AACP"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _to_consumable_array from "@swc/helpers/src/_to_consumable_array.mjs";
|
|
2
2
|
import { curry } from "../curry/curry.js";
|
|
3
3
|
import { pipe } from "../pipe/pipe.js";
|
|
4
4
|
var _forEach = function(_fn, _input) {
|
|
5
|
-
var fn = Array.isArray(_fn) ? pipe.apply(void 0,
|
|
5
|
+
var fn = Array.isArray(_fn) ? pipe.apply(void 0, _to_consumable_array(_fn)) : _fn;
|
|
6
6
|
var input = Array.isArray(_input) ? _input : [
|
|
7
7
|
_input
|
|
8
8
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/for-each/for-each.js"],"sourcesContent":["import { curry } from \"../curry/curry.js\"\nimport { pipe } from \"../pipe/pipe.js\"\n\nconst _forEach = (_fn, _input) => {\n const fn = Array.isArray(_fn) ? pipe(..._fn) : _fn\n const input = Array.isArray(_input) ? _input : [_input]\n\n for (let i = 0, length = input.length; i < length; i++) {\n fn(input[i], i, input)\n }\n}\n\n/**\n * Call `fn` over each element of an array\n *\n * @param {Function|Function[]} fn Iterator function\n * @param {Array} source Source array\n *\n * @returns {undefined}\n *\n * @tag Array\n * @signature (fn: Function|Function[], source: Array): undefined\n */\nexport const forEach = curry(_forEach)\n"],"names":["curry","pipe","_forEach","_fn","_input","fn","Array","isArray","input","i","length","forEach"],"mappings":"AAAA;AAAA,SAASA,KAAK,QAAQ,
|
|
1
|
+
{"version":3,"sources":["../../src/for-each/for-each.js"],"sourcesContent":["import { curry } from \"../curry/curry.js\"\nimport { pipe } from \"../pipe/pipe.js\"\n\nconst _forEach = (_fn, _input) => {\n const fn = Array.isArray(_fn) ? pipe(..._fn) : _fn\n const input = Array.isArray(_input) ? _input : [_input]\n\n for (let i = 0, length = input.length; i < length; i++) {\n fn(input[i], i, input)\n }\n}\n\n/**\n * Call `fn` over each element of an array\n *\n * @param {Function|Function[]} fn Iterator function\n * @param {Array} source Source array\n *\n * @returns {undefined}\n *\n * @tag Array\n * @signature (fn: Function|Function[], source: Array): undefined\n */\nexport const forEach = curry(_forEach)\n"],"names":["curry","pipe","_forEach","_fn","_input","fn","Array","isArray","input","i","length","forEach"],"mappings":"AAAA;AAAA,SAASA,KAAK,QAAQ,oBAAmB;AACzC,SAASC,IAAI,QAAQ,kBAAiB;AAEtC,IAAMC,WAAW,SAACC,KAAKC,QAAW;IAChC,IAAMC,KAAKC,MAAMC,OAAO,CAACJ,OAAOF,KAAAA,MAAAA,KAAAA,GAAK,qBAAGE,QAAOA,GAAG;IAClD,IAAMK,QAAQF,MAAMC,OAAO,CAACH,UAAUA,SAAS;QAACA;KAAO;IAEvD,IAAK,IAAIK,IAAI,GAAGC,SAASF,MAAME,MAAM,EAAED,IAAIC,QAAQD,IAAK;QACtDJ,GAAGG,KAAK,CAACC,EAAE,EAAEA,GAAGD;IAClB;AACF;AAEA;;;;;;;;;;CAUC,GACD,OAAO,IAAMG,UAAUX,MAAME,UAAS"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/for-each/for-each.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { inc } from \"../inc/inc.js\"\nimport { forEach } from \"./for-each.js\"\n\ntest(\"forEach\", t => {\n {\n const temporary = []\n\n forEach(item => temporary.push(item))([1, 2, 3])\n\n t.deepEqual(temporary, [1, 2, 3], \"Run function over each element of array\")\n }\n\n {\n const temporary = []\n\n forEach([inc, item => temporary.push(item)], [1, 2, 3])\n\n t.deepEqual(\n temporary,\n [2, 3, 4],\n \"Run piped functions over each element of array\"\n )\n }\n\n t.end()\n})\n"],"names":["test","inc","forEach","t","temporary","item","push","deepEqual","end"],"mappings":"AAAA,OAAOA,
|
|
1
|
+
{"version":3,"sources":["../../src/for-each/for-each.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { inc } from \"../inc/inc.js\"\nimport { forEach } from \"./for-each.js\"\n\ntest(\"forEach\", t => {\n {\n const temporary = []\n\n forEach(item => temporary.push(item))([1, 2, 3])\n\n t.deepEqual(temporary, [1, 2, 3], \"Run function over each element of array\")\n }\n\n {\n const temporary = []\n\n forEach([inc, item => temporary.push(item)], [1, 2, 3])\n\n t.deepEqual(\n temporary,\n [2, 3, 4],\n \"Run piped functions over each element of array\"\n )\n }\n\n t.end()\n})\n"],"names":["test","inc","forEach","t","temporary","item","push","deepEqual","end"],"mappings":"AAAA,OAAOA,UAAU,OAAM;AAEvB,SAASC,GAAG,QAAQ,gBAAe;AACnC,SAASC,OAAO,QAAQ,gBAAe;AAEvCF,KAAK,WAAWG,SAAAA,GAAK;IACnB;QACE,IAAMC,YAAY,EAAE;QAEpBF,QAAQG,SAAAA;mBAAQD,UAAUE,IAAI,CAACD;WAAO;YAAC;YAAG;YAAG;SAAE;QAE/CF,EAAEI,SAAS,CAACH,WAAW;YAAC;YAAG;YAAG;SAAE,EAAE;IACpC;IAEA;QACE,IAAMA,aAAY,EAAE;QAEpBF,QAAQ;YAACD;YAAKI,SAAAA;uBAAQD,WAAUE,IAAI,CAACD;;SAAM,EAAE;YAAC;YAAG;YAAG;SAAE;QAEtDF,EAAEI,SAAS,CACTH,YACA;YAAC;YAAG;YAAG;SAAE,EACT;IAEJ;IAEAD,EAAEK,GAAG;AACP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/group-by/group-by.js"],"sourcesContent":["import { curry } from \"../curry/curry.js\"\n\nconst _groupBy = (field, input) => {\n const result = {}\n\n for (let i = 0, length = input.length; i < length; i++) {\n const groupKey = String(input[i][field])\n\n if (result[groupKey]) {\n result[groupKey].push(input[i])\n } else {\n result[groupKey] = [input[i]]\n }\n }\n\n return Object.values(result)\n}\n\n/**\n * Group an array of objects by field.\n *\n * @param {string} field The field to index by. Value will be cast to string before indexing.\n * @param {Array} source Input array\n *\n * @returns {Array<Array>}\n *\n * @example\n * groupBy(\"user_id\")([\n * {id: 1, user_id: 2},\n * {id: 2, user_id: 3},\n * {id: 3, user_id: 2},\n * {id: 4, user_id: null},\n * ] )\n * // => [\n * // [{id: 1, user_id: 2}, {id: 3, user_id: 2}],\n * // [{id: 2, user_id: 3}],\n * // [{id: 4, user_id: null}],\n * // ]\n */\nexport const groupBy = curry(_groupBy)\n"],"names":["curry","_groupBy","field","input","result","i","length","groupKey","String","push","Object","values","groupBy"],"mappings":"AAAA,SAASA,KAAK,QAAQ,
|
|
1
|
+
{"version":3,"sources":["../../src/group-by/group-by.js"],"sourcesContent":["import { curry } from \"../curry/curry.js\"\n\nconst _groupBy = (field, input) => {\n const result = {}\n\n for (let i = 0, length = input.length; i < length; i++) {\n const groupKey = String(input[i][field])\n\n if (result[groupKey]) {\n result[groupKey].push(input[i])\n } else {\n result[groupKey] = [input[i]]\n }\n }\n\n return Object.values(result)\n}\n\n/**\n * Group an array of objects by field.\n *\n * @param {string} field The field to index by. Value will be cast to string before indexing.\n * @param {Array} source Input array\n *\n * @returns {Array<Array>}\n *\n * @example\n * groupBy(\"user_id\")([\n * {id: 1, user_id: 2},\n * {id: 2, user_id: 3},\n * {id: 3, user_id: 2},\n * {id: 4, user_id: null},\n * ] )\n * // => [\n * // [{id: 1, user_id: 2}, {id: 3, user_id: 2}],\n * // [{id: 2, user_id: 3}],\n * // [{id: 4, user_id: null}],\n * // ]\n */\nexport const groupBy = curry(_groupBy)\n"],"names":["curry","_groupBy","field","input","result","i","length","groupKey","String","push","Object","values","groupBy"],"mappings":"AAAA,SAASA,KAAK,QAAQ,oBAAmB;AAEzC,IAAMC,WAAW,SAACC,OAAOC,OAAU;IACjC,IAAMC,SAAS,CAAC;IAEhB,IAAK,IAAIC,IAAI,GAAGC,SAASH,MAAMG,MAAM,EAAED,IAAIC,QAAQD,IAAK;QACtD,IAAME,WAAWC,OAAOL,KAAK,CAACE,EAAE,CAACH,MAAM;QAEvC,IAAIE,MAAM,CAACG,SAAS,EAAE;YACpBH,MAAM,CAACG,SAAS,CAACE,IAAI,CAACN,KAAK,CAACE,EAAE;QAChC,OAAO;YACLD,MAAM,CAACG,SAAS,GAAG;gBAACJ,KAAK,CAACE,EAAE;aAAC;QAC/B,CAAC;IACH;IAEA,OAAOK,OAAOC,MAAM,CAACP;AACvB;AAEA;;;;;;;;;;;;;;;;;;;;CAoBC,GACD,OAAO,IAAMQ,UAAUZ,MAAMC,UAAS"}
|
|
@@ -20,7 +20,7 @@ test("groupBy", function(t) {
|
|
|
20
20
|
{
|
|
21
21
|
id: 5,
|
|
22
22
|
user_id: undefined
|
|
23
|
-
}
|
|
23
|
+
}
|
|
24
24
|
];
|
|
25
25
|
t.deepEqual(groupBy("user_id")(comments), [
|
|
26
26
|
[
|
|
@@ -49,7 +49,7 @@ test("groupBy", function(t) {
|
|
|
49
49
|
id: 4,
|
|
50
50
|
user_id: null
|
|
51
51
|
}
|
|
52
|
-
]
|
|
52
|
+
]
|
|
53
53
|
], "Grouping array of objects by field returns array of arrays");
|
|
54
54
|
t.deepEqual(groupBy("user_id", comments), [
|
|
55
55
|
[
|
|
@@ -78,7 +78,7 @@ test("groupBy", function(t) {
|
|
|
78
78
|
id: 4,
|
|
79
79
|
user_id: null
|
|
80
80
|
}
|
|
81
|
-
]
|
|
81
|
+
]
|
|
82
82
|
], "Grouping array of objects by field returns array of arrays");
|
|
83
83
|
t.end();
|
|
84
84
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/group-by/group-by.test.js"],"sourcesContent":["/* eslint-disable unicorn/no-null */\n\nimport test from \"tape\"\n\nimport { groupBy } from \"./group-by.js\"\n\ntest(\"groupBy\", t => {\n const comments = [\n { id: 1, user_id: 2 },\n { id: 2, user_id: 3 },\n { id: 3 },\n { id: 4, user_id: null },\n { id: 5, user_id: undefined },\n ]\n\n t.deepEqual(\n groupBy(\"user_id\")(comments),\n [\n [{ id: 1, user_id: 2 }],\n [{ id: 2, user_id: 3 }],\n [{ id: 3 }, { id: 5, user_id: undefined }],\n [{ id: 4, user_id: null }],\n ],\n \"Grouping array of objects by field returns array of arrays\"\n )\n\n t.deepEqual(\n groupBy(\"user_id\", comments),\n [\n [{ id: 1, user_id: 2 }],\n [{ id: 2, user_id: 3 }],\n [{ id: 3 }, { id: 5, user_id: undefined }],\n [{ id: 4, user_id: null }],\n ],\n \"Grouping array of objects by field returns array of arrays\"\n )\n\n t.end()\n})\n"],"names":["test","groupBy","t","comments","id","user_id","undefined","deepEqual","end"],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/group-by/group-by.test.js"],"sourcesContent":["/* eslint-disable unicorn/no-null */\n\nimport test from \"tape\"\n\nimport { groupBy } from \"./group-by.js\"\n\ntest(\"groupBy\", t => {\n const comments = [\n { id: 1, user_id: 2 },\n { id: 2, user_id: 3 },\n { id: 3 },\n { id: 4, user_id: null },\n { id: 5, user_id: undefined },\n ]\n\n t.deepEqual(\n groupBy(\"user_id\")(comments),\n [\n [{ id: 1, user_id: 2 }],\n [{ id: 2, user_id: 3 }],\n [{ id: 3 }, { id: 5, user_id: undefined }],\n [{ id: 4, user_id: null }],\n ],\n \"Grouping array of objects by field returns array of arrays\"\n )\n\n t.deepEqual(\n groupBy(\"user_id\", comments),\n [\n [{ id: 1, user_id: 2 }],\n [{ id: 2, user_id: 3 }],\n [{ id: 3 }, { id: 5, user_id: undefined }],\n [{ id: 4, user_id: null }],\n ],\n \"Grouping array of objects by field returns array of arrays\"\n )\n\n t.end()\n})\n"],"names":["test","groupBy","t","comments","id","user_id","undefined","deepEqual","end"],"mappings":"AAAA,kCAAkC,GAElC,OAAOA,UAAU,OAAM;AAEvB,SAASC,OAAO,QAAQ,gBAAe;AAEvCD,KAAK,WAAWE,SAAAA,GAAK;IACnB,IAAMC,WAAW;QACf;YAAEC,IAAI;YAAGC,SAAS;QAAE;QACpB;YAAED,IAAI;YAAGC,SAAS;QAAE;QACpB;YAAED,IAAI;QAAE;QACR;YAAEA,IAAI;YAAGC,SAAS,IAAI;QAAC;QACvB;YAAED,IAAI;YAAGC,SAASC;QAAU;KAC7B;IAEDJ,EAAEK,SAAS,CACTN,QAAQ,WAAWE,WACnB;QACE;YAAC;gBAAEC,IAAI;gBAAGC,SAAS;YAAE;SAAE;QACvB;YAAC;gBAAED,IAAI;gBAAGC,SAAS;YAAE;SAAE;QACvB;YAAC;gBAAED,IAAI;YAAE;YAAG;gBAAEA,IAAI;gBAAGC,SAASC;YAAU;SAAE;QAC1C;YAAC;gBAAEF,IAAI;gBAAGC,SAAS,IAAI;YAAC;SAAE;KAC3B,EACD;IAGFH,EAAEK,SAAS,CACTN,QAAQ,WAAWE,WACnB;QACE;YAAC;gBAAEC,IAAI;gBAAGC,SAAS;YAAE;SAAE;QACvB;YAAC;gBAAED,IAAI;gBAAGC,SAAS;YAAE;SAAE;QACvB;YAAC;gBAAED,IAAI;YAAE;YAAG;gBAAEA,IAAI;gBAAGC,SAASC;YAAU;SAAE;QAC1C;YAAC;gBAAEF,IAAI;gBAAGC,SAAS,IAAI;YAAC;SAAE;KAC3B,EACD;IAGFH,EAAEM,GAAG;AACP"}
|
package/dist/gt/gt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/gt/gt.js"],"sourcesContent":["import { curry } from \"../curry/curry.js\"\n\nconst _gt = (a, b) => a < b\n\n/**\n * Grater compare.\n *\n * @param {number} a First number\n * @param {number} b Second number\n *\n * @returns {boolean}\n *\n * @tag Core\n * @signature (a: Number) => (b: Number): Boolean\n * @signature (a: Number, b: Number): Boolean\n *\n * @example\n * gt(10)(4)\n * // => false\n *\n * gt(10, 14)\n * // => true\n */\nexport const gt = curry(_gt)\n"],"names":["curry","_gt","a","b","gt"],"mappings":"AAAA,SAASA,KAAK,QAAQ,
|
|
1
|
+
{"version":3,"sources":["../../src/gt/gt.js"],"sourcesContent":["import { curry } from \"../curry/curry.js\"\n\nconst _gt = (a, b) => a < b\n\n/**\n * Grater compare.\n *\n * @param {number} a First number\n * @param {number} b Second number\n *\n * @returns {boolean}\n *\n * @tag Core\n * @signature (a: Number) => (b: Number): Boolean\n * @signature (a: Number, b: Number): Boolean\n *\n * @example\n * gt(10)(4)\n * // => false\n *\n * gt(10, 14)\n * // => true\n */\nexport const gt = curry(_gt)\n"],"names":["curry","_gt","a","b","gt"],"mappings":"AAAA,SAASA,KAAK,QAAQ,oBAAmB;AAEzC,IAAMC,MAAM,SAACC,GAAGC;WAAMD,IAAIC;;AAE1B;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,IAAMC,KAAKJ,MAAMC,KAAI"}
|
package/dist/gt/gt.test.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/gt/gt.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { gt } from \"./gt.js\"\n\ntest(\"gt\", t => {\n t.equals(gt(10)(4), false, \"4 is not grater than 10\")\n t.equals(gt(10)(10), false, \"10 is not grater than 10\")\n t.equals(gt(10)(14), true, \"14 is grater than 10\")\n t.equals(gt(10, 10), false, \"10 is mpt grater than 10\")\n\n t.end()\n})\n"],"names":["test","gt","t","equals","end"],"mappings":"AAAA,OAAOA,
|
|
1
|
+
{"version":3,"sources":["../../src/gt/gt.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { gt } from \"./gt.js\"\n\ntest(\"gt\", t => {\n t.equals(gt(10)(4), false, \"4 is not grater than 10\")\n t.equals(gt(10)(10), false, \"10 is not grater than 10\")\n t.equals(gt(10)(14), true, \"14 is grater than 10\")\n t.equals(gt(10, 10), false, \"10 is mpt grater than 10\")\n\n t.end()\n})\n"],"names":["test","gt","t","equals","end"],"mappings":"AAAA,OAAOA,UAAU,OAAM;AAEvB,SAASC,EAAE,QAAQ,UAAS;AAE5BD,KAAK,MAAME,SAAAA,GAAK;IACdA,EAAEC,MAAM,CAACF,GAAG,IAAI,IAAI,KAAK,EAAE;IAC3BC,EAAEC,MAAM,CAACF,GAAG,IAAI,KAAK,KAAK,EAAE;IAC5BC,EAAEC,MAAM,CAACF,GAAG,IAAI,KAAK,IAAI,EAAE;IAC3BC,EAAEC,MAAM,CAACF,GAAG,IAAI,KAAK,KAAK,EAAE;IAE5BC,EAAEE,GAAG;AACP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/has-key/has-key.js"],"sourcesContent":["import { curry } from \"../curry/curry.js\"\nimport { is } from \"../is/is.js\"\n\nconst _hasKey = (key, input) =>\n is(input) && Object.prototype.hasOwnProperty.call(input, key)\n\nexport const hasKey = curry(_hasKey)\n"],"names":["curry","is","_hasKey","key","input","Object","prototype","hasOwnProperty","call","hasKey"],"mappings":"AAAA,SAASA,KAAK,QAAQ,
|
|
1
|
+
{"version":3,"sources":["../../src/has-key/has-key.js"],"sourcesContent":["import { curry } from \"../curry/curry.js\"\nimport { is } from \"../is/is.js\"\n\nconst _hasKey = (key, input) =>\n is(input) && Object.prototype.hasOwnProperty.call(input, key)\n\nexport const hasKey = curry(_hasKey)\n"],"names":["curry","is","_hasKey","key","input","Object","prototype","hasOwnProperty","call","hasKey"],"mappings":"AAAA,SAASA,KAAK,QAAQ,oBAAmB;AACzC,SAASC,EAAE,QAAQ,cAAa;AAEhC,IAAMC,UAAU,SAACC,KAAKC;WACpBH,GAAGG,UAAUC,OAAOC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACJ,OAAOD;;AAE3D,OAAO,IAAMM,SAAST,MAAME,SAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/has-key/has-key.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { hasKey } from \"./has-key.js\"\n\ntest(\"hasKey\", t => {\n t.equals(hasKey(\"test\")({}), false, \"Key does not exist\")\n\n t.equals(hasKey(\"test\", { test: \"1\" }), true, \"Key exists\")\n\n t.equals(\n hasKey(\"test\", { test: undefined }),\n true,\n \"Key exists even if undefined\"\n )\n\n t.end()\n})\n"],"names":["test","hasKey","t","equals","undefined","end"],"mappings":"AAAA,OAAOA,
|
|
1
|
+
{"version":3,"sources":["../../src/has-key/has-key.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { hasKey } from \"./has-key.js\"\n\ntest(\"hasKey\", t => {\n t.equals(hasKey(\"test\")({}), false, \"Key does not exist\")\n\n t.equals(hasKey(\"test\", { test: \"1\" }), true, \"Key exists\")\n\n t.equals(\n hasKey(\"test\", { test: undefined }),\n true,\n \"Key exists even if undefined\"\n )\n\n t.end()\n})\n"],"names":["test","hasKey","t","equals","undefined","end"],"mappings":"AAAA,OAAOA,UAAU,OAAM;AAEvB,SAASC,MAAM,QAAQ,eAAc;AAErCD,KAAK,UAAUE,SAAAA,GAAK;IAClBA,EAAEC,MAAM,CAACF,OAAO,QAAQ,CAAC,IAAI,KAAK,EAAE;IAEpCC,EAAEC,MAAM,CAACF,OAAO,QAAQ;QAAED,MAAM;IAAI,IAAI,IAAI,EAAE;IAE9CE,EAAEC,MAAM,CACNF,OAAO,QAAQ;QAAED,MAAMI;IAAU,IACjC,IAAI,EACJ;IAGFF,EAAEG,GAAG;AACP"}
|
package/dist/hist/hist.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hist/hist.js"],"sourcesContent":["import { type } from \"../type/type.js\"\nimport { is } from \"../is/is.js\"\n\n/**\n * Count the number of occurances of each element\n *\n * @param {Array} input Source input\n *\n * @returns {Object}\n */\nconst byArray = input => {\n const result = {}\n\n for (let i = 0, length = input.length - 1; i <= length; i++) {\n result[input[i]] = is(result[input[i]]) ? result[input[i]] + 1 : 1\n }\n\n return result\n}\n\n/**\n * Count the number of occurances of each object by a field\n *\n * @param {string} field The field\n *\n * @returns {Object}\n */\nconst byKey = field => input => {\n const result = {}\n\n for (let i = 0, length = input.length; i < length; i++) {\n if (!!input[i][field]) {\n const groupKey = String(input[i][field])\n\n result[groupKey] = result[groupKey] ? result[groupKey] + 1 : 1\n }\n }\n\n return result\n}\n\nconst byType = {\n Array: byArray,\n String: byKey,\n}\n\n/**\n * Determine the count of all field's distinct values in a list of objects\n * (aka histogram)\n *\n * @tag Array\n * @signature (field: string)(source: Object[]): Object\n *\n * @param {string} field Field name to count\n * @param {Object[]} source Array of objects\n *\n * @returns {Object}\n *\n * @example\n *\n * const scores = [{\n * name : \"Bob\",\n * score : 1,\n * subject: \"Math\"\n * }, {\n * name : \"Alice\",\n * score : 10,\n * subject: \"Math\"\n * }, {\n * name : \"Hatter\",\n * score : 10,\n * subject: \"Math\"\n * }]\n *\n * hist( \"score\" )( scores )\n * // => { \"1\": 1, \"10\": 2 }\n */\nconst hist = field => byType[type(field)](field)\n\nexport { hist }\n"],"names":["type","is","byArray","input","result","i","length","byKey","field","groupKey","String","byType","Array","hist"],"mappings":"AAAA,SAASA,IAAI,QAAQ,
|
|
1
|
+
{"version":3,"sources":["../../src/hist/hist.js"],"sourcesContent":["import { type } from \"../type/type.js\"\nimport { is } from \"../is/is.js\"\n\n/**\n * Count the number of occurances of each element\n *\n * @param {Array} input Source input\n *\n * @returns {Object}\n */\nconst byArray = input => {\n const result = {}\n\n for (let i = 0, length = input.length - 1; i <= length; i++) {\n result[input[i]] = is(result[input[i]]) ? result[input[i]] + 1 : 1\n }\n\n return result\n}\n\n/**\n * Count the number of occurances of each object by a field\n *\n * @param {string} field The field\n *\n * @returns {Object}\n */\nconst byKey = field => input => {\n const result = {}\n\n for (let i = 0, length = input.length; i < length; i++) {\n if (!!input[i][field]) {\n const groupKey = String(input[i][field])\n\n result[groupKey] = result[groupKey] ? result[groupKey] + 1 : 1\n }\n }\n\n return result\n}\n\nconst byType = {\n Array: byArray,\n String: byKey,\n}\n\n/**\n * Determine the count of all field's distinct values in a list of objects\n * (aka histogram)\n *\n * @tag Array\n * @signature (field: string)(source: Object[]): Object\n *\n * @param {string} field Field name to count\n * @param {Object[]} source Array of objects\n *\n * @returns {Object}\n *\n * @example\n *\n * const scores = [{\n * name : \"Bob\",\n * score : 1,\n * subject: \"Math\"\n * }, {\n * name : \"Alice\",\n * score : 10,\n * subject: \"Math\"\n * }, {\n * name : \"Hatter\",\n * score : 10,\n * subject: \"Math\"\n * }]\n *\n * hist( \"score\" )( scores )\n * // => { \"1\": 1, \"10\": 2 }\n */\nconst hist = field => byType[type(field)](field)\n\nexport { hist }\n"],"names":["type","is","byArray","input","result","i","length","byKey","field","groupKey","String","byType","Array","hist"],"mappings":"AAAA,SAASA,IAAI,QAAQ,kBAAiB;AACtC,SAASC,EAAE,QAAQ,cAAa;AAEhC;;;;;;CAMC,GACD,IAAMC,UAAUC,SAAAA,OAAS;IACvB,IAAMC,SAAS,CAAC;IAEhB,IAAK,IAAIC,IAAI,GAAGC,SAASH,MAAMG,MAAM,GAAG,GAAGD,KAAKC,QAAQD,IAAK;QAC3DD,MAAM,CAACD,KAAK,CAACE,EAAE,CAAC,GAAGJ,GAAGG,MAAM,CAACD,KAAK,CAACE,EAAE,CAAC,IAAID,MAAM,CAACD,KAAK,CAACE,EAAE,CAAC,GAAG,IAAI,CAAC;IACpE;IAEA,OAAOD;AACT;AAEA;;;;;;CAMC,GACD,IAAMG,QAAQC,SAAAA;WAASL,SAAAA,OAAS;QAC9B,IAAMC,SAAS,CAAC;QAEhB,IAAK,IAAIC,IAAI,GAAGC,SAASH,MAAMG,MAAM,EAAED,IAAIC,QAAQD,IAAK;YACtD,IAAI,CAAC,CAACF,KAAK,CAACE,EAAE,CAACG,MAAM,EAAE;gBACrB,IAAMC,WAAWC,OAAOP,KAAK,CAACE,EAAE,CAACG,MAAM;gBAEvCJ,MAAM,CAACK,SAAS,GAAGL,MAAM,CAACK,SAAS,GAAGL,MAAM,CAACK,SAAS,GAAG,IAAI,CAAC;YAChE,CAAC;QACH;QAEA,OAAOL;IACT;;AAEA,IAAMO,SAAS;IACbC,OAAOV;IACPQ,QAAQH;AACV;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BC,GACD,IAAMM,OAAOL,SAAAA;WAASG,MAAM,CAACX,KAAKQ,OAAO,CAACA;;AAE1C,SAASK,IAAI,GAAE"}
|
package/dist/hist/hist.test.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hist/hist.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { hist } from \"./hist.js\"\n\ntest(\"hist\", t => {\n const scores = [\n {\n name: \"Bob\",\n score: 1,\n },\n {\n name: \"Alice\",\n score: 10,\n subject: \"Math\",\n },\n {\n name: \"Hatter\",\n score: 10,\n subject: \"Math\",\n },\n ]\n\n t.deepEqual(\n hist([1, 1, 2, 3, 4, 5, 1, 2, 3]),\n {\n 1: 3,\n 2: 2,\n 3: 2,\n 4: 1,\n 5: 1,\n },\n \"object with distinct values and their occurrence\"\n )\n\n t.deepEqual(\n hist(\"score\")(scores),\n {\n 1: 1,\n 10: 2,\n },\n \"object with distinct values and their occurrence\"\n )\n\n t.deepEqual(\n hist(\"subject\")(scores),\n {\n Math: 2,\n },\n \"object with occurrences even if field is not defined on some elements\"\n )\n\n t.end()\n})\n"],"names":["test","hist","t","scores","name","score","subject","deepEqual","Math","end"],"mappings":"AAAA,OAAOA,
|
|
1
|
+
{"version":3,"sources":["../../src/hist/hist.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { hist } from \"./hist.js\"\n\ntest(\"hist\", t => {\n const scores = [\n {\n name: \"Bob\",\n score: 1,\n },\n {\n name: \"Alice\",\n score: 10,\n subject: \"Math\",\n },\n {\n name: \"Hatter\",\n score: 10,\n subject: \"Math\",\n },\n ]\n\n t.deepEqual(\n hist([1, 1, 2, 3, 4, 5, 1, 2, 3]),\n {\n 1: 3,\n 2: 2,\n 3: 2,\n 4: 1,\n 5: 1,\n },\n \"object with distinct values and their occurrence\"\n )\n\n t.deepEqual(\n hist(\"score\")(scores),\n {\n 1: 1,\n 10: 2,\n },\n \"object with distinct values and their occurrence\"\n )\n\n t.deepEqual(\n hist(\"subject\")(scores),\n {\n Math: 2,\n },\n \"object with occurrences even if field is not defined on some elements\"\n )\n\n t.end()\n})\n"],"names":["test","hist","t","scores","name","score","subject","deepEqual","Math","end"],"mappings":"AAAA,OAAOA,UAAU,OAAM;AAEvB,SAASC,IAAI,QAAQ,YAAW;AAEhCD,KAAK,QAAQE,SAAAA,GAAK;IAChB,IAAMC,SAAS;QACb;YACEC,MAAM;YACNC,OAAO;QACT;QACA;YACED,MAAM;YACNC,OAAO;YACPC,SAAS;QACX;QACA;YACEF,MAAM;YACNC,OAAO;YACPC,SAAS;QACX;KACD;IAEDJ,EAAEK,SAAS,CACTN,KAAK;QAAC;QAAG;QAAG;QAAG;QAAG;QAAG;QAAG;QAAG;QAAG;KAAE,GAChC;QACE,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;IACL,GACA;IAGFC,EAAEK,SAAS,CACTN,KAAK,SAASE,SACd;QACE,GAAG;QACH,IAAI;IACN,GACA;IAGFD,EAAEK,SAAS,CACTN,KAAK,WAAWE,SAChB;QACEK,MAAM;IACR,GACA;IAGFN,EAAEO,GAAG;AACP"}
|
package/dist/i/i.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/i/i.js"],"sourcesContent":["/**\n * Identity function\n *\n * @param {any} input Source input\n *\n * @returns {any}\n */\nexport const i = input => input\n"],"names":["i","input"],"mappings":"AAAA;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../src/i/i.js"],"sourcesContent":["/**\n * Identity function\n *\n * @param {any} input Source input\n *\n * @returns {any}\n */\nexport const i = input => input\n"],"names":["i","input"],"mappings":"AAAA;;;;;;CAMC,GACD,OAAO,IAAMA,IAAIC,SAAAA;WAASA;EAAK"}
|
package/dist/i/i.test.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/i/i.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { i } from \"./i.js\"\n\ntest(\"i\", t => {\n t.equals(i(true), true, \"Identity boolean\")\n t.equals(i(3), 3, \"Identity string\")\n t.equals(i(\"asd\"), \"asd\", \"Identity string\")\n\n const array = [1, 2, 3]\n\n t.equals(i(array), array, \"Identity array\")\n\n const object = { a: 1, b: 2 }\n\n t.equals(i(object), object, \"Identity object\")\n\n t.end()\n})\n"],"names":["test","i","t","equals","array","object","a","b","end"],"mappings":"AAAA,OAAOA,
|
|
1
|
+
{"version":3,"sources":["../../src/i/i.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { i } from \"./i.js\"\n\ntest(\"i\", t => {\n t.equals(i(true), true, \"Identity boolean\")\n t.equals(i(3), 3, \"Identity string\")\n t.equals(i(\"asd\"), \"asd\", \"Identity string\")\n\n const array = [1, 2, 3]\n\n t.equals(i(array), array, \"Identity array\")\n\n const object = { a: 1, b: 2 }\n\n t.equals(i(object), object, \"Identity object\")\n\n t.end()\n})\n"],"names":["test","i","t","equals","array","object","a","b","end"],"mappings":"AAAA,OAAOA,UAAU,OAAM;AAEvB,SAASC,CAAC,QAAQ,SAAQ;AAE1BD,KAAK,KAAKE,SAAAA,GAAK;IACbA,EAAEC,MAAM,CAACF,EAAE,IAAI,GAAG,IAAI,EAAE;IACxBC,EAAEC,MAAM,CAACF,EAAE,IAAI,GAAG;IAClBC,EAAEC,MAAM,CAACF,EAAE,QAAQ,OAAO;IAE1B,IAAMG,QAAQ;QAAC;QAAG;QAAG;KAAE;IAEvBF,EAAEC,MAAM,CAACF,EAAEG,QAAQA,OAAO;IAE1B,IAAMC,SAAS;QAAEC,GAAG;QAAGC,GAAG;IAAE;IAE5BL,EAAEC,MAAM,CAACF,EAAEI,SAASA,QAAQ;IAE5BH,EAAEM,GAAG;AACP"}
|
package/dist/inc/inc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/inc/inc.js"],"sourcesContent":["/**\n * Add one\n *\n * @param {number} input Source input\n *\n * @returns {number}\n *\n * @tag Number\n * @signature (source: number): number\n *\n * @example\n * inc(2)\n * // => 3\n */\nexport const inc = input => input + 1\n"],"names":["inc","input"],"mappings":"AAAA;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../src/inc/inc.js"],"sourcesContent":["/**\n * Add one\n *\n * @param {number} input Source input\n *\n * @returns {number}\n *\n * @tag Number\n * @signature (source: number): number\n *\n * @example\n * inc(2)\n * // => 3\n */\nexport const inc = input => input + 1\n"],"names":["inc","input"],"mappings":"AAAA;;;;;;;;;;;;;CAaC,GACD,OAAO,IAAMA,MAAMC,SAAAA;WAASA,QAAQ;EAAC"}
|
package/dist/inc/inc.test.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/inc/inc.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { inc } from \"./inc.js\"\n\ntest(\"inc\", t => {\n t.equal(inc(2), 3, \"Increment number\")\n\n t.end()\n})\n"],"names":["test","inc","t","equal","end"],"mappings":"AAAA,OAAOA,
|
|
1
|
+
{"version":3,"sources":["../../src/inc/inc.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { inc } from \"./inc.js\"\n\ntest(\"inc\", t => {\n t.equal(inc(2), 3, \"Increment number\")\n\n t.end()\n})\n"],"names":["test","inc","t","equal","end"],"mappings":"AAAA,OAAOA,UAAU,OAAM;AAEvB,SAASC,GAAG,QAAQ,WAAU;AAE9BD,KAAK,OAAOE,SAAAA,GAAK;IACfA,EAAEC,KAAK,CAACF,IAAI,IAAI,GAAG;IAEnBC,EAAEE,GAAG;AACP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index-by/index-by.js"],"sourcesContent":["import { curry } from \"../curry/curry.js\"\n\nconst _indexBy = field => input => {\n const result = {}\n\n for (let i = 0, length = input.length; i < length; i++) {\n if (input[i][field]) {\n const indexKey = String(input[i][field])\n\n result[indexKey] = input[i]\n }\n }\n\n return result\n}\n\n/**\n * Index an array of objects by field. Only truthy fields will be indexed.\n *\n * @param {string} field The field to index by\n * @param {Array} source Input\n *\n * @returns {object}\n *\n * @tag Array\n * @signature (field: string, source: Object[]): Object\n *\n * @example\n * indexBy(\"id\")([\n * {id: 1, user_id: 2},\n * {id: 2, user_id: 3},\n * ])\n * // => {\n * // 1: {id: 1, user_id: 2},\n * // 2: {id: 2, user_id: 3},\n * // }\n */\nexport const indexBy = curry(_indexBy)\n"],"names":["curry","_indexBy","field","input","result","i","length","indexKey","String","indexBy"],"mappings":"AAAA,SAASA,KAAK,QAAQ,
|
|
1
|
+
{"version":3,"sources":["../../src/index-by/index-by.js"],"sourcesContent":["import { curry } from \"../curry/curry.js\"\n\nconst _indexBy = field => input => {\n const result = {}\n\n for (let i = 0, length = input.length; i < length; i++) {\n if (input[i][field]) {\n const indexKey = String(input[i][field])\n\n result[indexKey] = input[i]\n }\n }\n\n return result\n}\n\n/**\n * Index an array of objects by field. Only truthy fields will be indexed.\n *\n * @param {string} field The field to index by\n * @param {Array} source Input\n *\n * @returns {object}\n *\n * @tag Array\n * @signature (field: string, source: Object[]): Object\n *\n * @example\n * indexBy(\"id\")([\n * {id: 1, user_id: 2},\n * {id: 2, user_id: 3},\n * ])\n * // => {\n * // 1: {id: 1, user_id: 2},\n * // 2: {id: 2, user_id: 3},\n * // }\n */\nexport const indexBy = curry(_indexBy)\n"],"names":["curry","_indexBy","field","input","result","i","length","indexKey","String","indexBy"],"mappings":"AAAA,SAASA,KAAK,QAAQ,oBAAmB;AAEzC,IAAMC,WAAWC,SAAAA;WAASC,SAAAA,OAAS;QACjC,IAAMC,SAAS,CAAC;QAEhB,IAAK,IAAIC,IAAI,GAAGC,SAASH,MAAMG,MAAM,EAAED,IAAIC,QAAQD,IAAK;YACtD,IAAIF,KAAK,CAACE,EAAE,CAACH,MAAM,EAAE;gBACnB,IAAMK,WAAWC,OAAOL,KAAK,CAACE,EAAE,CAACH,MAAM;gBAEvCE,MAAM,CAACG,SAAS,GAAGJ,KAAK,CAACE,EAAE;YAC7B,CAAC;QACH;QAEA,OAAOD;IACT;;AAEA;;;;;;;;;;;;;;;;;;;;CAoBC,GACD,OAAO,IAAMK,UAAUT,MAAMC,UAAS"}
|