@asd14/m 8.0.0 → 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.map +1 -1
- package/dist/all/all.test.js.map +1 -1
- 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.map +1 -1
- package/dist/append/append.test.js.map +1 -1
- package/dist/bottom/bottom.js.map +1 -1
- package/dist/bottom/bottom.test.js.map +1 -1
- 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.map +1 -1
- package/dist/clone/clone.test.js.map +1 -1
- 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.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.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.map +1 -1
- package/dist/curry/curry.test.js.map +1 -1
- 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.map +1 -1
- 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.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.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.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.map +1 -1
- package/dist/flatten/flatten.test.js.map +1 -1
- 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.map +1 -1
- package/dist/intersect/intersect.test.js +2 -2
- 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.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.map +1 -1
- 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.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.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.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.map +1 -1
- package/dist/merge/merge.test.js.map +1 -1
- 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.map +1 -1
- package/dist/move/move.test.js.map +1 -1
- 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.map +1 -1
- package/dist/page/page.test.js.map +1 -1
- 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.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.map +1 -1
- package/dist/pipe/pipe.test.js.map +1 -1
- package/dist/pipe-p/pipe-p.js.map +1 -1
- package/dist/pipe-p/pipe-p.test.js.map +1 -1
- 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.map +1 -1
- package/dist/prepend/prepend.test.js.map +1 -1
- 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.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.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.map +1 -1
- package/dist/reduce/reduce.test.js.map +1 -1
- 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.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.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 +6 -6
- 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.map +1 -1
- 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.map +1 -1
- package/dist/split/split.test.js.map +1 -1
- 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.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.map +1 -1
- package/dist/top/top.test.js.map +1 -1
- package/dist/trim/trim.js.map +1 -1
- package/dist/trim/trim.test.js.map +1 -1
- 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.map +1 -1
- package/dist/update/update.test.js.map +1 -1
- package/dist/upsert/upsert.js.map +1 -1
- package/dist/upsert/upsert.test.js.map +1 -1
- package/dist/values/values.js.map +1 -1
- package/dist/values/values.test.js.map +1 -1
- package/dist/when/when.js.map +1 -1
- package/dist/when/when.test.js.map +1 -1
- 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 +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/rename-file/rename-file.js"],"sourcesContent":["/* eslint-disable unicorn/prefer-node-protocol */\n\nimport path from \"path\"\n\nimport { pipe } from \"../pipe/pipe.js\"\nimport { trim } from \"../trim/trim.js\"\nimport { split } from \"../split/split.js\"\nimport { push } from \"../push/push.js\"\nimport { unite } from \"../unite/unite.js\"\nimport { dropLast } from \"../drop-last/drop-last.js\"\n\nconst removeTrailingSlash = input =>\n input[input.length - 1] === path.sep ? input.slice(0, -1) : input\n\n/**\n * Rename a file\n *\n * @param {string} newName New file name\n * @param {string} input Absolute file path\n *\n * @returns {string}\n */\nconst renameFile = newName =>\n pipe(\n removeTrailingSlash,\n split(path.sep),\n dropLast,\n push(trim(path.sep)(newName)),\n unite(path.sep)\n )\n\nexport { renameFile }\n"],"names":["path","pipe","trim","split","push","unite","dropLast","removeTrailingSlash","input","length","sep","slice","renameFile","newName"],"mappings":"AAAA,+CAA+C,GAE/C,OAAOA,
|
|
1
|
+
{"version":3,"sources":["../../src/rename-file/rename-file.js"],"sourcesContent":["/* eslint-disable unicorn/prefer-node-protocol */\n\nimport path from \"path\"\n\nimport { pipe } from \"../pipe/pipe.js\"\nimport { trim } from \"../trim/trim.js\"\nimport { split } from \"../split/split.js\"\nimport { push } from \"../push/push.js\"\nimport { unite } from \"../unite/unite.js\"\nimport { dropLast } from \"../drop-last/drop-last.js\"\n\nconst removeTrailingSlash = input =>\n input[input.length - 1] === path.sep ? input.slice(0, -1) : input\n\n/**\n * Rename a file\n *\n * @param {string} newName New file name\n * @param {string} input Absolute file path\n *\n * @returns {string}\n */\nconst renameFile = newName =>\n pipe(\n removeTrailingSlash,\n split(path.sep),\n dropLast,\n push(trim(path.sep)(newName)),\n unite(path.sep)\n )\n\nexport { renameFile }\n"],"names":["path","pipe","trim","split","push","unite","dropLast","removeTrailingSlash","input","length","sep","slice","renameFile","newName"],"mappings":"AAAA,+CAA+C,GAE/C,OAAOA,UAAU,OAAM;AAEvB,SAASC,IAAI,QAAQ,kBAAiB;AACtC,SAASC,IAAI,QAAQ,kBAAiB;AACtC,SAASC,KAAK,QAAQ,oBAAmB;AACzC,SAASC,IAAI,QAAQ,kBAAiB;AACtC,SAASC,KAAK,QAAQ,oBAAmB;AACzC,SAASC,QAAQ,QAAQ,4BAA2B;AAEpD,IAAMC,sBAAsBC,SAAAA;WAC1BA,KAAK,CAACA,MAAMC,MAAM,GAAG,EAAE,KAAKT,KAAKU,GAAG,GAAGF,MAAMG,KAAK,CAAC,GAAG,CAAC,KAAKH,KAAK;;AAEnE;;;;;;;CAOC,GACD,IAAMI,aAAaC,SAAAA;WACjBZ,KACEM,qBACAJ,MAAMH,KAAKU,GAAG,GACdJ,UACAF,KAAKF,KAAKF,KAAKU,GAAG,EAAEG,WACpBR,MAAML,KAAKU,GAAG;;AAGlB,SAASE,UAAU,GAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/rename-file/rename-file.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { renameFile } from \"./rename-file.js\"\n\ntest(\"renameFile\", t => {\n t.equals(\n renameFile(\"ipsum\")(\"/home/user/lorem\"),\n \"/home/user/ipsum\",\n \"Rename file with full path\"\n )\n\n t.equals(\n renameFile(\"ipsum\")(\"/home/user/lorem/\"),\n \"/home/user/ipsum\",\n \"Rename file with trailing slash in path\"\n )\n\n t.equals(\n renameFile(\"ipsum/\")(\"/home/user/lorem/\"),\n \"/home/user/ipsum\",\n \"Rename file with trailing slash in path and new file name\"\n )\n\n t.equals(\n renameFile(\"/ipsum\")(\"/home/user/lorem\"),\n \"/home/user/ipsum\",\n \"Rename file with trailing slash in new file name\"\n )\n\n t.equals(\n renameFile(\"ipsum\")(\"lorem\"),\n \"ipsum\",\n \"Rename file with only fileName\"\n )\n\n t.equals(\n renameFile(\"ipsum\")(renameFile(\"ipsum\")(\"/lorem/test\")),\n \"/lorem/ipsum\",\n \"Idempotent\"\n )\n t.end()\n})\n"],"names":["test","renameFile","t","equals","end"],"mappings":"AAAA,OAAOA,
|
|
1
|
+
{"version":3,"sources":["../../src/rename-file/rename-file.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { renameFile } from \"./rename-file.js\"\n\ntest(\"renameFile\", t => {\n t.equals(\n renameFile(\"ipsum\")(\"/home/user/lorem\"),\n \"/home/user/ipsum\",\n \"Rename file with full path\"\n )\n\n t.equals(\n renameFile(\"ipsum\")(\"/home/user/lorem/\"),\n \"/home/user/ipsum\",\n \"Rename file with trailing slash in path\"\n )\n\n t.equals(\n renameFile(\"ipsum/\")(\"/home/user/lorem/\"),\n \"/home/user/ipsum\",\n \"Rename file with trailing slash in path and new file name\"\n )\n\n t.equals(\n renameFile(\"/ipsum\")(\"/home/user/lorem\"),\n \"/home/user/ipsum\",\n \"Rename file with trailing slash in new file name\"\n )\n\n t.equals(\n renameFile(\"ipsum\")(\"lorem\"),\n \"ipsum\",\n \"Rename file with only fileName\"\n )\n\n t.equals(\n renameFile(\"ipsum\")(renameFile(\"ipsum\")(\"/lorem/test\")),\n \"/lorem/ipsum\",\n \"Idempotent\"\n )\n t.end()\n})\n"],"names":["test","renameFile","t","equals","end"],"mappings":"AAAA,OAAOA,UAAU,OAAM;AAEvB,SAASC,UAAU,QAAQ,mBAAkB;AAE7CD,KAAK,cAAcE,SAAAA,GAAK;IACtBA,EAAEC,MAAM,CACNF,WAAW,SAAS,qBACpB,oBACA;IAGFC,EAAEC,MAAM,CACNF,WAAW,SAAS,sBACpB,oBACA;IAGFC,EAAEC,MAAM,CACNF,WAAW,UAAU,sBACrB,oBACA;IAGFC,EAAEC,MAAM,CACNF,WAAW,UAAU,qBACrB,oBACA;IAGFC,EAAEC,MAAM,CACNF,WAAW,SAAS,UACpB,SACA;IAGFC,EAAEC,MAAM,CACNF,WAAW,SAASA,WAAW,SAAS,iBACxC,gBACA;IAEFC,EAAEE,GAAG;AACP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/repeat/repeat.js"],"sourcesContent":["import { pipe } from \"../pipe/pipe.js\"\n\nconst _repeat = (_fn, count = 0) => {\n const result = []\n const fn = Array.isArray(_fn) ? pipe(..._fn) : _fn\n const isFunction = typeof fn === \"function\"\n\n for (let i = 0; i < count; i++) {\n result.push(isFunction ? fn(i, result) : fn)\n }\n\n return result\n}\n\n/**\n * Return an array of fixed size containing a specified value or function result\n *\n * @param {Function|any} fn Function or value to repeat\n * @param {number} input Number of times\n * @param {...any} params Function params\n *\n * @returns {Array}\n *\n * @name repeat\n * @tag Array\n * @signature (fn: Function|any) => (count: Number): Array\n *\n * @example\n * repeat(2)(3)\n * // => [2, 2, 2]\n *\n * repeat(index => index + 1, 3)\n * // => [1, 2, 3]\n */\nexport const repeat = (...params) => {\n // @signature (fn) => (input)\n if (params.length <= 1) {\n return input => _repeat(params[0], input)\n }\n\n // @signature (fn, input)\n return _repeat(...params)\n}\n"],"names":["pipe","_repeat","_fn","count","result","fn","Array","isArray","isFunction","i","push","repeat","params","length","input"],"mappings":"AAAA;AAAA,SAASA,IAAI,QAAQ,
|
|
1
|
+
{"version":3,"sources":["../../src/repeat/repeat.js"],"sourcesContent":["import { pipe } from \"../pipe/pipe.js\"\n\nconst _repeat = (_fn, count = 0) => {\n const result = []\n const fn = Array.isArray(_fn) ? pipe(..._fn) : _fn\n const isFunction = typeof fn === \"function\"\n\n for (let i = 0; i < count; i++) {\n result.push(isFunction ? fn(i, result) : fn)\n }\n\n return result\n}\n\n/**\n * Return an array of fixed size containing a specified value or function result\n *\n * @param {Function|any} fn Function or value to repeat\n * @param {number} input Number of times\n * @param {...any} params Function params\n *\n * @returns {Array}\n *\n * @name repeat\n * @tag Array\n * @signature (fn: Function|any) => (count: Number): Array\n *\n * @example\n * repeat(2)(3)\n * // => [2, 2, 2]\n *\n * repeat(index => index + 1, 3)\n * // => [1, 2, 3]\n */\nexport const repeat = (...params) => {\n // @signature (fn) => (input)\n if (params.length <= 1) {\n return input => _repeat(params[0], input)\n }\n\n // @signature (fn, input)\n return _repeat(...params)\n}\n"],"names":["pipe","_repeat","_fn","count","result","fn","Array","isArray","isFunction","i","push","repeat","params","length","input"],"mappings":"AAAA;AAAA,SAASA,IAAI,QAAQ,kBAAiB;AAEtC,IAAMC,UAAU,SAACC,KAAmB;QAAdC,yEAAQ;IAC5B,IAAMC,SAAS,EAAE;IACjB,IAAMC,KAAKC,MAAMC,OAAO,CAACL,OAAOF,KAAAA,MAAAA,KAAAA,GAAK,qBAAGE,QAAOA,GAAG;IAClD,IAAMM,aAAa,OAAOH,OAAO;IAEjC,IAAK,IAAII,IAAI,GAAGA,IAAIN,OAAOM,IAAK;QAC9BL,OAAOM,IAAI,CAACF,aAAaH,GAAGI,GAAGL,UAAUC,EAAE;IAC7C;IAEA,OAAOD;AACT;AAEA;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,IAAMO,SAAS,WAAe;qCAAXC;QAAAA;;IACxB,6BAA6B;IAC7B,IAAIA,OAAOC,MAAM,IAAI,GAAG;QACtB,OAAOC,SAAAA;mBAASb,QAAQW,MAAM,CAAC,EAAE,EAAEE;;IACrC,CAAC;IAED,yBAAyB;IACzB,OAAOb,QAAAA,MAAAA,KAAAA,GAAQ,qBAAGW;AACpB,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/repeat/repeat.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { repeat } from \"./repeat.js\"\n\nconst inc = x => x + 1\n\ntest(\"repeat\", t => {\n t.deepEqual(repeat(inc)(5), [1, 2, 3, 4, 5], \"Repeat function curried\")\n t.deepEqual(repeat(inc, 2), [1, 2], \"Repeat function uncurried \")\n t.deepEqual(repeat([inc, inc], 2), [2, 3], \"Repeat with function chain\")\n\n t.deepEqual(repeat(inc)(), [], \"Repeat without count\")\n t.deepEqual(repeat(3, 2), [3, 3], \"Repeat value curried \")\n\n t.end()\n})\n"],"names":["test","repeat","inc","x","t","deepEqual","end"],"mappings":"AAAA,OAAOA,
|
|
1
|
+
{"version":3,"sources":["../../src/repeat/repeat.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { repeat } from \"./repeat.js\"\n\nconst inc = x => x + 1\n\ntest(\"repeat\", t => {\n t.deepEqual(repeat(inc)(5), [1, 2, 3, 4, 5], \"Repeat function curried\")\n t.deepEqual(repeat(inc, 2), [1, 2], \"Repeat function uncurried \")\n t.deepEqual(repeat([inc, inc], 2), [2, 3], \"Repeat with function chain\")\n\n t.deepEqual(repeat(inc)(), [], \"Repeat without count\")\n t.deepEqual(repeat(3, 2), [3, 3], \"Repeat value curried \")\n\n t.end()\n})\n"],"names":["test","repeat","inc","x","t","deepEqual","end"],"mappings":"AAAA,OAAOA,UAAU,OAAM;AAEvB,SAASC,MAAM,QAAQ,cAAa;AAEpC,IAAMC,MAAMC,SAAAA;WAAKA,IAAI;;AAErBH,KAAK,UAAUI,SAAAA,GAAK;IAClBA,EAAEC,SAAS,CAACJ,OAAOC,KAAK,IAAI;QAAC;QAAG;QAAG;QAAG;QAAG;KAAE,EAAE;IAC7CE,EAAEC,SAAS,CAACJ,OAAOC,KAAK,IAAI;QAAC;QAAG;KAAE,EAAE;IACpCE,EAAEC,SAAS,CAACJ,OAAO;QAACC;QAAKA;KAAI,EAAE,IAAI;QAAC;QAAG;KAAE,EAAE;IAE3CE,EAAEC,SAAS,CAACJ,OAAOC,QAAQ,EAAE,EAAE;IAC/BE,EAAEC,SAAS,CAACJ,OAAO,GAAG,IAAI;QAAC;QAAG;KAAE,EAAE;IAElCG,EAAEE,GAAG;AACP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/replace/replace.js"],"sourcesContent":["import { map } from \"../map/map.js\"\nimport { isMatch } from \"../is-match/is-match.js\"\nimport { type } from \"../type/type.js\"\n\n/**\n * Replace substring in string\n *\n * @param {string} oldString The old string\n * @param {string} newString The new string\n *\n * @returns {string}\n */\nconst replaceString = (oldString, newString) => input =>\n String.prototype.replace.call(input, oldString, newString)\n\n/**\n * Replace element in array (shallow equal)\n *\n * @param {any} oldElm\n * @param {any} newElm\n *\n * @returns {Array}\n */\nconst replaceArray = (oldElm, newElm) => input => {\n const result = []\n\n for (let i = 0, length = input.length - 1; i <= length; i++) {\n if (oldElm === input[i]) {\n result.push(newElm)\n } else {\n result.push(input[i])\n }\n }\n\n return result\n}\n\n/**\n * Replace substring if source is string, replace element (shallow equal) if\n * source is Array\n *\n * @param {string|any} oldElm\n * @param {string|any} newElm\n * @param {string|Array} source\n *\n * @returns {string|Array}\n *\n * @tag String,Array\n * @signature (oldElm: string|any, newElm: string|any) => (source: Array): Array\n *\n */\nconst replace = (oldElm, newElm) => input => {\n const inputType = type(input)\n const byType = {\n String: replaceString,\n Array: replaceArray,\n }\n\n return byType[inputType](oldElm, newElm)(input)\n}\n\n/**\n * Replace object element in array using filter object\n *\n * @tag Array\n * @signature (filter: Obj, replace: Obj|Function) => (source: Obj[]): Obj[]\n *\n * @param {Object} filter Filter object to match against each element\n * @param {Object} newValue Object to replace matching elements\n * @param {Object[]} source\n *\n * @returns {Array}\n *\n * @example\n * replaceWith(\n * {id: 2},\n * {id: 2, title: \"boss\", isBoss: true}\n * )([\n * {id: 2, title:\"minion\"}\n * {id: 3, title:\"minion\"}\n * ])\n * // => [\n * // {id: 2, title:\"boss\", isBoss: true},\n * // {id: 3, title:\"minion\"}\n * // ]\n *\n * replaceWith({ id: 2 }, item => ({\n * ...item,\n * content: [\"new\", \"updated\", \"field\"],\n * }))([\n * { id: 1, name: \"foo\", content: [] },\n * { id: 2, name: \"bar\", content: [] },\n * ])\n * // [\n * // { id: 1, name: \"foo\", content: [] },\n * // { id: 2, name: \"bar\", content: [\"new\", \"updated\", \"field\"] },\n * // ],\n */\nconst replaceWith = (filter, newValue) =>\n map(item =>\n isMatch(filter)(item)\n ? typeof newValue === \"function\"\n ? newValue(item)\n : newValue\n : item\n )\n\nexport { replace, replaceWith }\n"],"names":["map","isMatch","type","replaceString","oldString","newString","input","String","prototype","replace","call","replaceArray","oldElm","newElm","result","i","length","push","inputType","byType","Array","replaceWith","filter","newValue","item"],"mappings":"AAAA,SAASA,GAAG,QAAQ,
|
|
1
|
+
{"version":3,"sources":["../../src/replace/replace.js"],"sourcesContent":["import { map } from \"../map/map.js\"\nimport { isMatch } from \"../is-match/is-match.js\"\nimport { type } from \"../type/type.js\"\n\n/**\n * Replace substring in string\n *\n * @param {string} oldString The old string\n * @param {string} newString The new string\n *\n * @returns {string}\n */\nconst replaceString = (oldString, newString) => input =>\n String.prototype.replace.call(input, oldString, newString)\n\n/**\n * Replace element in array (shallow equal)\n *\n * @param {any} oldElm\n * @param {any} newElm\n *\n * @returns {Array}\n */\nconst replaceArray = (oldElm, newElm) => input => {\n const result = []\n\n for (let i = 0, length = input.length - 1; i <= length; i++) {\n if (oldElm === input[i]) {\n result.push(newElm)\n } else {\n result.push(input[i])\n }\n }\n\n return result\n}\n\n/**\n * Replace substring if source is string, replace element (shallow equal) if\n * source is Array\n *\n * @param {string|any} oldElm\n * @param {string|any} newElm\n * @param {string|Array} source\n *\n * @returns {string|Array}\n *\n * @tag String,Array\n * @signature (oldElm: string|any, newElm: string|any) => (source: Array): Array\n *\n */\nconst replace = (oldElm, newElm) => input => {\n const inputType = type(input)\n const byType = {\n String: replaceString,\n Array: replaceArray,\n }\n\n return byType[inputType](oldElm, newElm)(input)\n}\n\n/**\n * Replace object element in array using filter object\n *\n * @tag Array\n * @signature (filter: Obj, replace: Obj|Function) => (source: Obj[]): Obj[]\n *\n * @param {Object} filter Filter object to match against each element\n * @param {Object} newValue Object to replace matching elements\n * @param {Object[]} source\n *\n * @returns {Array}\n *\n * @example\n * replaceWith(\n * {id: 2},\n * {id: 2, title: \"boss\", isBoss: true}\n * )([\n * {id: 2, title:\"minion\"}\n * {id: 3, title:\"minion\"}\n * ])\n * // => [\n * // {id: 2, title:\"boss\", isBoss: true},\n * // {id: 3, title:\"minion\"}\n * // ]\n *\n * replaceWith({ id: 2 }, item => ({\n * ...item,\n * content: [\"new\", \"updated\", \"field\"],\n * }))([\n * { id: 1, name: \"foo\", content: [] },\n * { id: 2, name: \"bar\", content: [] },\n * ])\n * // [\n * // { id: 1, name: \"foo\", content: [] },\n * // { id: 2, name: \"bar\", content: [\"new\", \"updated\", \"field\"] },\n * // ],\n */\nconst replaceWith = (filter, newValue) =>\n map(item =>\n isMatch(filter)(item)\n ? typeof newValue === \"function\"\n ? newValue(item)\n : newValue\n : item\n )\n\nexport { replace, replaceWith }\n"],"names":["map","isMatch","type","replaceString","oldString","newString","input","String","prototype","replace","call","replaceArray","oldElm","newElm","result","i","length","push","inputType","byType","Array","replaceWith","filter","newValue","item"],"mappings":"AAAA,SAASA,GAAG,QAAQ,gBAAe;AACnC,SAASC,OAAO,QAAQ,0BAAyB;AACjD,SAASC,IAAI,QAAQ,kBAAiB;AAEtC;;;;;;;CAOC,GACD,IAAMC,gBAAgB,SAACC,WAAWC;WAAcC,SAAAA;eAC9CC,OAAOC,SAAS,CAACC,OAAO,CAACC,IAAI,CAACJ,OAAOF,WAAWC;;;AAElD;;;;;;;CAOC,GACD,IAAMM,eAAe,SAACC,QAAQC;WAAWP,SAAAA,OAAS;QAChD,IAAMQ,SAAS,EAAE;QAEjB,IAAK,IAAIC,IAAI,GAAGC,SAASV,MAAMU,MAAM,GAAG,GAAGD,KAAKC,QAAQD,IAAK;YAC3D,IAAIH,WAAWN,KAAK,CAACS,EAAE,EAAE;gBACvBD,OAAOG,IAAI,CAACJ;YACd,OAAO;gBACLC,OAAOG,IAAI,CAACX,KAAK,CAACS,EAAE;YACtB,CAAC;QACH;QAEA,OAAOD;IACT;;AAEA;;;;;;;;;;;;;CAaC,GACD,IAAML,UAAU,SAACG,QAAQC;WAAWP,SAAAA,OAAS;QAC3C,IAAMY,YAAYhB,KAAKI;QACvB,IAAMa,SAAS;YACbZ,QAAQJ;YACRiB,OAAOT;QACT;QAEA,OAAOQ,MAAM,CAACD,UAAU,CAACN,QAAQC,QAAQP;IAC3C;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCC,GACD,IAAMe,cAAc,SAACC,QAAQC;WAC3BvB,IAAIwB,SAAAA;eACFvB,QAAQqB,QAAQE,QACZ,OAAOD,aAAa,aAClBA,SAASC,QACTD,QAAQ,GACVC,IAAI;;;AAGZ,SAASf,OAAO,EAAEY,WAAW,GAAE"}
|
|
@@ -45,7 +45,7 @@ test("replace(With)", function(t) {
|
|
|
45
45
|
{
|
|
46
46
|
id: 3,
|
|
47
47
|
title: "minion"
|
|
48
|
-
}
|
|
48
|
+
}
|
|
49
49
|
]), [
|
|
50
50
|
{
|
|
51
51
|
id: 2,
|
|
@@ -55,7 +55,7 @@ test("replace(With)", function(t) {
|
|
|
55
55
|
{
|
|
56
56
|
id: 3,
|
|
57
57
|
title: "minion"
|
|
58
|
-
}
|
|
58
|
+
}
|
|
59
59
|
], "Replace existing object");
|
|
60
60
|
t.deepEqual(replaceWith({
|
|
61
61
|
"!name": "alice"
|
|
@@ -74,7 +74,7 @@ test("replace(With)", function(t) {
|
|
|
74
74
|
{
|
|
75
75
|
name: "george",
|
|
76
76
|
title: "third"
|
|
77
|
-
}
|
|
77
|
+
}
|
|
78
78
|
]), [
|
|
79
79
|
{
|
|
80
80
|
name: "alice",
|
|
@@ -87,7 +87,7 @@ test("replace(With)", function(t) {
|
|
|
87
87
|
{
|
|
88
88
|
name: "bobby",
|
|
89
89
|
title: "tables"
|
|
90
|
-
}
|
|
90
|
+
}
|
|
91
91
|
], "Replace multiple objects by using negate in filter object");
|
|
92
92
|
t.deepEquals(replaceWith({
|
|
93
93
|
id: 2
|
|
@@ -109,7 +109,7 @@ test("replace(With)", function(t) {
|
|
|
109
109
|
id: 2,
|
|
110
110
|
name: "bar",
|
|
111
111
|
content: []
|
|
112
|
-
}
|
|
112
|
+
}
|
|
113
113
|
]), [
|
|
114
114
|
{
|
|
115
115
|
id: 1,
|
|
@@ -124,7 +124,7 @@ test("replace(With)", function(t) {
|
|
|
124
124
|
"updated",
|
|
125
125
|
"field"
|
|
126
126
|
]
|
|
127
|
-
}
|
|
127
|
+
}
|
|
128
128
|
], "Replace object with custom update function");
|
|
129
129
|
t.end();
|
|
130
130
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/replace/replace.test.js"],"sourcesContent":["import test from \"tape\"\nimport { replace, replaceWith } from \"./replace.js\"\n\ntest(\"replace(With)\", t => {\n t.equals(\n replace(\"test\", \"ipsum\")(\"lorem test\"),\n \"lorem ipsum\",\n \"Replace substring in string\"\n )\n\n t.equals(\n replace(\"testx\", \"ipsum\")(\"lorem test\"),\n \"lorem test\",\n \"Replacement string does not exist\"\n )\n\n t.deepEquals(\n replace(\"test\", \"ipsum\")([\"lorem\", \"test\"]),\n [\"lorem\", \"ipsum\"],\n \"Replace string element in array source\"\n )\n\n t.deepEquals(\n replace(\"testx\", \"ipsum\")([\"lorem\", \"test\"]),\n [\"lorem\", \"test\"],\n \"Replacement string does not exist in array source\"\n )\n\n const input = [\"lorem\", \"test\"]\n\n t.notEquals(replace(\"test\", \"ipsum\")(input), input, \"Imutable\")\n\n t.deepEquals(\n replace(\"test\", \"ipsum\")(replace(\"test\", \"ipsum\")([\"lorem\", \"test\"])),\n [\"lorem\", \"ipsum\"],\n \"Idempotent\"\n )\n\n t.deepEqual(\n replaceWith(\n { id: 2 },\n { id: 2, title: \"boss\", isBoss: true }\n )([\n { id: 2, title: \"minion\" },\n { id: 3, title: \"minion\" },\n ]),\n [\n { id: 2, title: \"boss\", isBoss: true },\n { id: 3, title: \"minion\" },\n ],\n \"Replace existing object\"\n )\n\n t.deepEqual(\n replaceWith(\n { \"!name\": \"alice\" },\n { name: \"bobby\", title: \"tables\" }\n )([\n { name: \"alice\", title: \"first\" },\n { name: \"bob\", title: \"second\" },\n { name: \"george\", title: \"third\" },\n ]),\n [\n { name: \"alice\", title: \"first\" },\n { name: \"bobby\", title: \"tables\" },\n { name: \"bobby\", title: \"tables\" },\n ],\n \"Replace multiple objects by using negate in filter object\"\n )\n\n t.deepEquals(\n replaceWith({ id: 2 }, item => ({\n ...item,\n content: [\"new\", \"updated\", \"field\"],\n }))([\n { id: 1, name: \"foo\", content: [] },\n { id: 2, name: \"bar\", content: [] },\n ]),\n [\n { id: 1, name: \"foo\", content: [] },\n { id: 2, name: \"bar\", content: [\"new\", \"updated\", \"field\"] },\n ],\n \"Replace object with custom update function\"\n )\n\n t.end()\n})\n"],"names":["test","replace","replaceWith","t","equals","deepEquals","input","notEquals","deepEqual","id","title","isBoss","name","item","content","end"],"mappings":"AAAA;;AAAA,OAAOA,
|
|
1
|
+
{"version":3,"sources":["../../src/replace/replace.test.js"],"sourcesContent":["import test from \"tape\"\nimport { replace, replaceWith } from \"./replace.js\"\n\ntest(\"replace(With)\", t => {\n t.equals(\n replace(\"test\", \"ipsum\")(\"lorem test\"),\n \"lorem ipsum\",\n \"Replace substring in string\"\n )\n\n t.equals(\n replace(\"testx\", \"ipsum\")(\"lorem test\"),\n \"lorem test\",\n \"Replacement string does not exist\"\n )\n\n t.deepEquals(\n replace(\"test\", \"ipsum\")([\"lorem\", \"test\"]),\n [\"lorem\", \"ipsum\"],\n \"Replace string element in array source\"\n )\n\n t.deepEquals(\n replace(\"testx\", \"ipsum\")([\"lorem\", \"test\"]),\n [\"lorem\", \"test\"],\n \"Replacement string does not exist in array source\"\n )\n\n const input = [\"lorem\", \"test\"]\n\n t.notEquals(replace(\"test\", \"ipsum\")(input), input, \"Imutable\")\n\n t.deepEquals(\n replace(\"test\", \"ipsum\")(replace(\"test\", \"ipsum\")([\"lorem\", \"test\"])),\n [\"lorem\", \"ipsum\"],\n \"Idempotent\"\n )\n\n t.deepEqual(\n replaceWith(\n { id: 2 },\n { id: 2, title: \"boss\", isBoss: true }\n )([\n { id: 2, title: \"minion\" },\n { id: 3, title: \"minion\" },\n ]),\n [\n { id: 2, title: \"boss\", isBoss: true },\n { id: 3, title: \"minion\" },\n ],\n \"Replace existing object\"\n )\n\n t.deepEqual(\n replaceWith(\n { \"!name\": \"alice\" },\n { name: \"bobby\", title: \"tables\" }\n )([\n { name: \"alice\", title: \"first\" },\n { name: \"bob\", title: \"second\" },\n { name: \"george\", title: \"third\" },\n ]),\n [\n { name: \"alice\", title: \"first\" },\n { name: \"bobby\", title: \"tables\" },\n { name: \"bobby\", title: \"tables\" },\n ],\n \"Replace multiple objects by using negate in filter object\"\n )\n\n t.deepEquals(\n replaceWith({ id: 2 }, item => ({\n ...item,\n content: [\"new\", \"updated\", \"field\"],\n }))([\n { id: 1, name: \"foo\", content: [] },\n { id: 2, name: \"bar\", content: [] },\n ]),\n [\n { id: 1, name: \"foo\", content: [] },\n { id: 2, name: \"bar\", content: [\"new\", \"updated\", \"field\"] },\n ],\n \"Replace object with custom update function\"\n )\n\n t.end()\n})\n"],"names":["test","replace","replaceWith","t","equals","deepEquals","input","notEquals","deepEqual","id","title","isBoss","name","item","content","end"],"mappings":"AAAA;;AAAA,OAAOA,UAAU,OAAM;AACvB,SAASC,OAAO,EAAEC,WAAW,QAAQ,eAAc;AAEnDF,KAAK,iBAAiBG,SAAAA,GAAK;IACzBA,EAAEC,MAAM,CACNH,QAAQ,QAAQ,SAAS,eACzB,eACA;IAGFE,EAAEC,MAAM,CACNH,QAAQ,SAAS,SAAS,eAC1B,cACA;IAGFE,EAAEE,UAAU,CACVJ,QAAQ,QAAQ,SAAS;QAAC;QAAS;KAAO,GAC1C;QAAC;QAAS;KAAQ,EAClB;IAGFE,EAAEE,UAAU,CACVJ,QAAQ,SAAS,SAAS;QAAC;QAAS;KAAO,GAC3C;QAAC;QAAS;KAAO,EACjB;IAGF,IAAMK,QAAQ;QAAC;QAAS;KAAO;IAE/BH,EAAEI,SAAS,CAACN,QAAQ,QAAQ,SAASK,QAAQA,OAAO;IAEpDH,EAAEE,UAAU,CACVJ,QAAQ,QAAQ,SAASA,QAAQ,QAAQ,SAAS;QAAC;QAAS;KAAO,IACnE;QAAC;QAAS;KAAQ,EAClB;IAGFE,EAAEK,SAAS,CACTN,YACE;QAAEO,IAAI;IAAE,GACR;QAAEA,IAAI;QAAGC,OAAO;QAAQC,QAAQ,IAAI;IAAC,GACrC;QACA;YAAEF,IAAI;YAAGC,OAAO;QAAS;QACzB;YAAED,IAAI;YAAGC,OAAO;QAAS;KAC1B,GACD;QACE;YAAED,IAAI;YAAGC,OAAO;YAAQC,QAAQ,IAAI;QAAC;QACrC;YAAEF,IAAI;YAAGC,OAAO;QAAS;KAC1B,EACD;IAGFP,EAAEK,SAAS,CACTN,YACE;QAAE,SAAS;IAAQ,GACnB;QAAEU,MAAM;QAASF,OAAO;IAAS,GACjC;QACA;YAAEE,MAAM;YAASF,OAAO;QAAQ;QAChC;YAAEE,MAAM;YAAOF,OAAO;QAAS;QAC/B;YAAEE,MAAM;YAAUF,OAAO;QAAQ;KAClC,GACD;QACE;YAAEE,MAAM;YAASF,OAAO;QAAQ;QAChC;YAAEE,MAAM;YAASF,OAAO;QAAS;QACjC;YAAEE,MAAM;YAASF,OAAO;QAAS;KAClC,EACD;IAGFP,EAAEE,UAAU,CACVH,YAAY;QAAEO,IAAI;IAAE,GAAGI,SAAAA;eAAS,wCAC3BA;YACHC,SAAS;gBAAC;gBAAO;gBAAW;aAAQ;;OAClC;QACF;YAAEL,IAAI;YAAGG,MAAM;YAAOE,SAAS,EAAE;QAAC;QAClC;YAAEL,IAAI;YAAGG,MAAM;YAAOE,SAAS,EAAE;QAAC;KACnC,GACD;QACE;YAAEL,IAAI;YAAGG,MAAM;YAAOE,SAAS,EAAE;QAAC;QAClC;YAAEL,IAAI;YAAGG,MAAM;YAAOE,SAAS;gBAAC;gBAAO;gBAAW;aAAQ;QAAC;KAC5D,EACD;IAGFX,EAAEY,GAAG;AACP"}
|
package/dist/same/same.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/same/same.js"],"sourcesContent":["/**\n * Curried funtion that always returns the input given\n *\n * @param {any} input Something, anything\n *\n * @returns {any}\n */\nexport const same = input => () => input\n"],"names":["same","input"],"mappings":"AAAA;;;;;;CAMC,GACD,OAAO,IAAMA,
|
|
1
|
+
{"version":3,"sources":["../../src/same/same.js"],"sourcesContent":["/**\n * Curried funtion that always returns the input given\n *\n * @param {any} input Something, anything\n *\n * @returns {any}\n */\nexport const same = input => () => input\n"],"names":["same","input"],"mappings":"AAAA;;;;;;CAMC,GACD,OAAO,IAAMA,OAAOC,SAAAA;WAAS;eAAMA;;EAAK"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/same/same.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { same } from \"./same.js\"\n\ntest(\"same\", t => {\n const object = {}\n\n t.equals(\n same(object)(),\n object,\n \"Give value as input, get the same value in return\"\n )\n\n t.end()\n})\n"],"names":["test","same","t","object","equals","end"],"mappings":"AAAA,OAAOA,
|
|
1
|
+
{"version":3,"sources":["../../src/same/same.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { same } from \"./same.js\"\n\ntest(\"same\", t => {\n const object = {}\n\n t.equals(\n same(object)(),\n object,\n \"Give value as input, get the same value in return\"\n )\n\n t.end()\n})\n"],"names":["test","same","t","object","equals","end"],"mappings":"AAAA,OAAOA,UAAU,OAAM;AAEvB,SAASC,IAAI,QAAQ,YAAW;AAEhCD,KAAK,QAAQE,SAAAA,GAAK;IAChB,IAAMC,SAAS,CAAC;IAEhBD,EAAEE,MAAM,CACNH,KAAKE,WACLA,QACA;IAGFD,EAAEG,GAAG;AACP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/sequence/sequence.js"],"sourcesContent":["import { is } from \"../is/is.js\"\n\nconst alwaysTrue = () => true\n\nexport const sequenceWhile = (predicateFn, input) => {\n if (typeof predicateFn !== \"function\") {\n throw new TypeError(\n `Invalid predicate control function. Expected function but got \"${JSON.stringify(\n predicateFn\n )}\"`\n )\n }\n\n if (!Array.isArray(input) || (Array.isArray(input) && input.length === 0)) {\n throw new TypeError(\n `Invalid source array. Expected array of functions but got \"${JSON.stringify(\n input\n )}\"`\n )\n }\n\n let index = 0\n const resolved = []\n\n const queueNext = promise =>\n promise.then(result => {\n resolved.push(result)\n\n if (predicateFn(result) === true) {\n const nextPromiseFn = input[++index]\n\n if (is(nextPromiseFn)) {\n return queueNext(Promise.resolve(nextPromiseFn(result)))\n }\n\n // no more functions to process\n return resolved\n }\n\n // predicate function failed, return what already resolved and stop\n // processing further\n return resolved\n })\n\n return queueNext(Promise.resolve(input[0]()))\n}\n\nexport const sequence = input => sequenceWhile(alwaysTrue, input)\n"],"names":["is","alwaysTrue","sequenceWhile","predicateFn","input","TypeError","JSON","stringify","Array","isArray","length","index","resolved","queueNext","promise","then","result","push","nextPromiseFn","Promise","resolve","sequence"],"mappings":"AAAA,SAASA,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"sources":["../../src/sequence/sequence.js"],"sourcesContent":["import { is } from \"../is/is.js\"\n\nconst alwaysTrue = () => true\n\nexport const sequenceWhile = (predicateFn, input) => {\n if (typeof predicateFn !== \"function\") {\n throw new TypeError(\n `Invalid predicate control function. Expected function but got \"${JSON.stringify(\n predicateFn\n )}\"`\n )\n }\n\n if (!Array.isArray(input) || (Array.isArray(input) && input.length === 0)) {\n throw new TypeError(\n `Invalid source array. Expected array of functions but got \"${JSON.stringify(\n input\n )}\"`\n )\n }\n\n let index = 0\n const resolved = []\n\n const queueNext = promise =>\n promise.then(result => {\n resolved.push(result)\n\n if (predicateFn(result) === true) {\n const nextPromiseFn = input[++index]\n\n if (is(nextPromiseFn)) {\n return queueNext(Promise.resolve(nextPromiseFn(result)))\n }\n\n // no more functions to process\n return resolved\n }\n\n // predicate function failed, return what already resolved and stop\n // processing further\n return resolved\n })\n\n return queueNext(Promise.resolve(input[0]()))\n}\n\nexport const sequence = input => sequenceWhile(alwaysTrue, input)\n"],"names":["is","alwaysTrue","sequenceWhile","predicateFn","input","TypeError","JSON","stringify","Array","isArray","length","index","resolved","queueNext","promise","then","result","push","nextPromiseFn","Promise","resolve","sequence"],"mappings":"AAAA,SAASA,EAAE,QAAQ,cAAa;AAEhC,IAAMC,aAAa;WAAM,IAAI;;AAE7B,OAAO,IAAMC,gBAAgB,SAACC,aAAaC,OAAU;IACnD,IAAI,OAAOD,gBAAgB,YAAY;QACrC,MAAM,IAAIE,UACR,AAAC,kEAEC,OAFgEC,KAAKC,SAAS,CAC9EJ,cACA,MACH;IACH,CAAC;IAED,IAAI,CAACK,MAAMC,OAAO,CAACL,UAAWI,MAAMC,OAAO,CAACL,UAAUA,MAAMM,MAAM,KAAK,GAAI;QACzE,MAAM,IAAIL,UACR,AAAC,8DAEC,OAF4DC,KAAKC,SAAS,CAC1EH,QACA,MACH;IACH,CAAC;IAED,IAAIO,QAAQ;IACZ,IAAMC,WAAW,EAAE;IAEnB,IAAMC,YAAYC,SAAAA;eAChBA,QAAQC,IAAI,CAACC,SAAAA,QAAU;YACrBJ,SAASK,IAAI,CAACD;YAEd,IAAIb,YAAYa,YAAY,IAAI,EAAE;gBAChC,IAAME,gBAAgBd,KAAK,CAAC,EAAEO,MAAM;gBAEpC,IAAIX,GAAGkB,gBAAgB;oBACrB,OAAOL,UAAUM,QAAQC,OAAO,CAACF,cAAcF;gBACjD,CAAC;gBAED,+BAA+B;gBAC/B,OAAOJ;YACT,CAAC;YAED,mEAAmE;YACnE,qBAAqB;YACrB,OAAOA;QACT;;IAEF,OAAOC,UAAUM,QAAQC,OAAO,CAAChB,KAAK,CAAC,EAAE;AAC3C,EAAC;AAED,OAAO,IAAMiB,WAAWjB,SAAAA;WAASF,cAAcD,YAAYG;EAAM"}
|
|
@@ -35,7 +35,7 @@ test("sequence", function(t) {
|
|
|
35
35
|
Promise.resolve(3),
|
|
36
36
|
Promise.resolve(4)
|
|
37
37
|
]);
|
|
38
|
-
}
|
|
38
|
+
}
|
|
39
39
|
];
|
|
40
40
|
return sequence(input).then(function(result) {
|
|
41
41
|
t.deepEqual([
|
|
@@ -118,7 +118,7 @@ test("sequenceWith", function(t) {
|
|
|
118
118
|
function(previous) {
|
|
119
119
|
sum += previous;
|
|
120
120
|
return delay(10, 5);
|
|
121
|
-
}
|
|
121
|
+
}
|
|
122
122
|
]);
|
|
123
123
|
}).then(function(result) {
|
|
124
124
|
t.deepEqual([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/sequence/sequence.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { isTrue } from \"../is/is.js\"\nimport { sequence, sequenceWhile } from \"./sequence.js\"\n\nconst delay = (ms, value) =>\n new Promise(resolve => setTimeout(() => resolve(value), ms))\n\ntest(\"sequence\", t => {\n t.throws(\n () => sequence(),\n /Invalid source array. Expected array of functions but got \"undefined\"/,\n \"Throw error when source array is not array\"\n )\n\n t.throws(\n () => sequence([]),\n /Invalid source array. Expected array of functions but got \"\\[]\"/,\n \"Throw error when source array is empty\"\n )\n\n let sum = 0\n\n const input = [\n () => {\n sum++\n\n return 1\n },\n previous => {\n sum += previous\n\n return delay(10, 2)\n },\n previous => {\n sum += previous\n\n return Promise.resolve(\"abc\")\n },\n previous => {\n sum += previous\n\n return Promise.all([Promise.resolve(3), Promise.resolve(4)])\n },\n ]\n\n return sequence(input).then(result => {\n t.deepEqual(\n [sum, result],\n [`${1 + 1 + 2}abc`, [1, 2, \"abc\", [3, 4]]],\n \"All promise functions run in sequence, each having access to previous result\"\n )\n\n t.end()\n })\n})\n\ntest(\"sequenceWith\", t => {\n t.throws(\n () => sequenceWhile(),\n /Invalid predicate control function. Expected function but got \"undefined\"/,\n \"Throw error when predicate function invalid\"\n )\n\n let sum = 1\n\n return sequenceWhile(isTrue, [() => true, () => false, () => true])\n .then(result => {\n t.deepEqual(\n result,\n [true, false],\n \"Two promise fn resolve with array of both resolved values\"\n )\n })\n .then(() => sequenceWhile(isTrue, [() => true]))\n .then(result => {\n t.deepEqual(\n result,\n [true],\n \"One successfull promise fn resolve with array of resolved value\"\n )\n })\n .then(() => sequenceWhile(isTrue, [() => false]))\n .then(result => {\n t.deepEqual(\n result,\n [false],\n \"One failing promise fn resolve with array of resolved value\"\n )\n })\n .then(() =>\n sequenceWhile(\n input => input <= 5,\n [\n () => 1,\n\n previous => {\n sum += previous\n\n return delay(10, 2)\n },\n\n previous => {\n sum += previous\n\n return delay(10, 100)\n },\n\n previous => {\n sum += previous\n\n return delay(10, 2)\n },\n\n previous => {\n sum += previous\n\n return delay(10, 5)\n },\n ]\n )\n )\n .then(result => {\n t.deepEqual(\n [sum, result],\n [1 + 1 + 2, [1, 2, 100]],\n \"Promise functions run in sequence until control fn fails. No further promises will run\"\n )\n\n t.end()\n })\n})\n"],"names":["test","isTrue","sequence","sequenceWhile","delay","ms","value","Promise","resolve","setTimeout","t","throws","sum","input","previous","all","then","result","deepEqual","end"],"mappings":"AAAA,OAAOA,
|
|
1
|
+
{"version":3,"sources":["../../src/sequence/sequence.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { isTrue } from \"../is/is.js\"\nimport { sequence, sequenceWhile } from \"./sequence.js\"\n\nconst delay = (ms, value) =>\n new Promise(resolve => setTimeout(() => resolve(value), ms))\n\ntest(\"sequence\", t => {\n t.throws(\n () => sequence(),\n /Invalid source array. Expected array of functions but got \"undefined\"/,\n \"Throw error when source array is not array\"\n )\n\n t.throws(\n () => sequence([]),\n /Invalid source array. Expected array of functions but got \"\\[]\"/,\n \"Throw error when source array is empty\"\n )\n\n let sum = 0\n\n const input = [\n () => {\n sum++\n\n return 1\n },\n previous => {\n sum += previous\n\n return delay(10, 2)\n },\n previous => {\n sum += previous\n\n return Promise.resolve(\"abc\")\n },\n previous => {\n sum += previous\n\n return Promise.all([Promise.resolve(3), Promise.resolve(4)])\n },\n ]\n\n return sequence(input).then(result => {\n t.deepEqual(\n [sum, result],\n [`${1 + 1 + 2}abc`, [1, 2, \"abc\", [3, 4]]],\n \"All promise functions run in sequence, each having access to previous result\"\n )\n\n t.end()\n })\n})\n\ntest(\"sequenceWith\", t => {\n t.throws(\n () => sequenceWhile(),\n /Invalid predicate control function. Expected function but got \"undefined\"/,\n \"Throw error when predicate function invalid\"\n )\n\n let sum = 1\n\n return sequenceWhile(isTrue, [() => true, () => false, () => true])\n .then(result => {\n t.deepEqual(\n result,\n [true, false],\n \"Two promise fn resolve with array of both resolved values\"\n )\n })\n .then(() => sequenceWhile(isTrue, [() => true]))\n .then(result => {\n t.deepEqual(\n result,\n [true],\n \"One successfull promise fn resolve with array of resolved value\"\n )\n })\n .then(() => sequenceWhile(isTrue, [() => false]))\n .then(result => {\n t.deepEqual(\n result,\n [false],\n \"One failing promise fn resolve with array of resolved value\"\n )\n })\n .then(() =>\n sequenceWhile(\n input => input <= 5,\n [\n () => 1,\n\n previous => {\n sum += previous\n\n return delay(10, 2)\n },\n\n previous => {\n sum += previous\n\n return delay(10, 100)\n },\n\n previous => {\n sum += previous\n\n return delay(10, 2)\n },\n\n previous => {\n sum += previous\n\n return delay(10, 5)\n },\n ]\n )\n )\n .then(result => {\n t.deepEqual(\n [sum, result],\n [1 + 1 + 2, [1, 2, 100]],\n \"Promise functions run in sequence until control fn fails. No further promises will run\"\n )\n\n t.end()\n })\n})\n"],"names":["test","isTrue","sequence","sequenceWhile","delay","ms","value","Promise","resolve","setTimeout","t","throws","sum","input","previous","all","then","result","deepEqual","end"],"mappings":"AAAA,OAAOA,UAAU,OAAM;AAEvB,SAASC,MAAM,QAAQ,cAAa;AACpC,SAASC,QAAQ,EAAEC,aAAa,QAAQ,gBAAe;AAEvD,IAAMC,QAAQ,SAACC,IAAIC;WACjB,IAAIC,QAAQC,SAAAA;eAAWC,WAAW;mBAAMD,QAAQF;WAAQD;;;AAE1DL,KAAK,YAAYU,SAAAA,GAAK;IACpBA,EAAEC,MAAM,CACN;eAAMT;OACN,yEACA;IAGFQ,EAAEC,MAAM,CACN;eAAMT,SAAS,EAAE;OACjB,mEACA;IAGF,IAAIU,MAAM;IAEV,IAAMC,QAAQ;QACZ,WAAM;YACJD;YAEA,OAAO;QACT;QACAE,SAAAA,UAAY;YACVF,OAAOE;YAEP,OAAOV,MAAM,IAAI;QACnB;QACAU,SAAAA,UAAY;YACV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AOV,MAAM,IAAI;YACnB;YAEAU,SAAAA,UAAY;gBACVF,OAAOE;gBAEP,OAAOV,MAAM,IAAI;YACnB;YAEAU,SAAAA,UAAY;gBACVF,OAAOE;gBAEP,OAAOV,MAAM,IAAI;YACnB;SACD;OAGJY,IAAI,CAACC,SAAAA,QAAU;QACdP,EAAEQ,SAAS,CACT;YAACN;YAAKK;SAAO,EACb;YAAC,IAAI,IAAI;YAAG;gBAAC;gBAAG;gBAAG;aAAI;SAAC,EACxB;QAGFP,EAAES,GAAG;IACP;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/sort/sort-with.js"],"sourcesContent":["import { is } from \"../is/is.js\"\n\nconst _compareTwoValues = (direction, a, b) => {\n const valueIfFieldMissing =\n direction === \"asc\" ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY\n const aValue = is(a) ? a : valueIfFieldMissing\n const bValue = is(b) ? b : valueIfFieldMissing\n\n if (a === null && b === undefined) {\n return direction === \"desc\" ? -1 : 1\n }\n\n if (a === undefined && b === null) {\n return direction === \"desc\" ? 1 : -1\n }\n\n if (aValue === bValue) {\n return 0\n }\n\n if (aValue < bValue) {\n return direction === \"desc\" ? 1 : -1\n }\n\n // aValue > bValue\n return direction === \"desc\" ? -1 : 1\n}\n\nconst _validateProps = subset => {\n const sorters = Object.entries(subset)\n\n for (const [key, sorter] of sorters) {\n const [sortFn, direction = \"asc\"] = Array.isArray(sorter)\n ? sorter\n : typeof sorter === \"function\"\n ? [sorter]\n : [undefined, sorter]\n\n if (direction !== \"asc\" && direction !== \"desc\") {\n throw new Error(\n `@asd14/m/sortWith: Unsuported sort direction for key \"${key}\". Accepting \"asc\" or \"desc\", received \"${direction}\".`\n )\n }\n\n if (\n typeof sortFn === \"function\" &&\n (sortFn.length === 0 || sortFn.length > 2)\n ) {\n throw new Error(\n `@asd14/m/sortWith: Unsuported sort function signature for key \"${key}\". Accepting function with one or two parameters, received ${sortFn.length}.`\n )\n }\n }\n}\n\nconst _sortWith = (subset, input) => {\n _validateProps(subset)\n\n const sorters = Object.entries(subset)\n\n return [...input].sort((a, b) => {\n for (let i = 0; i < sorters.length; ++i) {\n const [key, sorter] = sorters[i]\n const [sortFn, direction = \"asc\"] = Array.isArray(sorter)\n ? sorter\n : typeof sorter === \"function\"\n ? [sorter]\n : [undefined, sorter]\n const isLastSorter = i === sorters.length - 1\n\n let result\n\n if (typeof sortFn === \"function\") {\n // one param, treat as lens: (source) => source.field\n // two params, treas as compare func: (a, b) => a - b\n\n result =\n sortFn.length === 2\n ? sortFn(a[key], b[key])\n : _compareTwoValues(direction, sortFn(a[key]), sortFn(b[key]))\n } else {\n // { key: \"direction\" }\n result = _compareTwoValues(direction, a[key], b[key])\n }\n\n if (result !== 0 || isLastSorter) {\n return result\n }\n }\n })\n}\n\n/**\n * Sort an array of objects by multiple fields\n *\n * @param {Object} subset\n * @param {Array} source\n *\n * @param {...any} params\n * @returns {Array}\n *\n * @name sortWith\n * @tag Array\n * @signature (subset: Object, source: Array): Array\n *\n * @see {@link sort}\n * @see {@link sortBy}\n *\n * @example\n * sortWith({position: \"asc\"},\n * { id: 1, position: 3 },\n * { id: 2, position: 2 },\n * { id: 3 },\n * { id: 4, position: 5 },\n * { id: 5, position: null },\n * ])\n * // [\n * // { id: 2, position: 2 },\n * // { id: 1, position: 3 },\n * // { id: 4, position: 5 },\n * // { id: 5, position: null },\n * // { id: 3 },\n * //]\n */\nexport const sortWith = (...params) => {\n // @signature (subset) => (source)\n if (params.length <= 1) {\n return input => _sortWith(params[0], input)\n }\n\n // @signature (subset, source)\n return _sortWith(...params)\n}\n"],"names":["is","_compareTwoValues","direction","a","b","valueIfFieldMissing","Number","POSITIVE_INFINITY","NEGATIVE_INFINITY","aValue","bValue","undefined","_validateProps","subset","sorters","Object","entries","key","sorter","Array","isArray","sortFn","Error","length","_sortWith","input","sort","i","isLastSorter","result","sortWith","params"],"mappings":"AAAA;;AAAA,SAASA,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"sources":["../../src/sort/sort-with.js"],"sourcesContent":["import { is } from \"../is/is.js\"\n\nconst _compareTwoValues = (direction, a, b) => {\n const valueIfFieldMissing =\n direction === \"asc\" ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY\n const aValue = is(a) ? a : valueIfFieldMissing\n const bValue = is(b) ? b : valueIfFieldMissing\n\n if (a === null && b === undefined) {\n return direction === \"desc\" ? -1 : 1\n }\n\n if (a === undefined && b === null) {\n return direction === \"desc\" ? 1 : -1\n }\n\n if (aValue === bValue) {\n return 0\n }\n\n if (aValue < bValue) {\n return direction === \"desc\" ? 1 : -1\n }\n\n // aValue > bValue\n return direction === \"desc\" ? -1 : 1\n}\n\nconst _validateProps = subset => {\n const sorters = Object.entries(subset)\n\n for (const [key, sorter] of sorters) {\n const [sortFn, direction = \"asc\"] = Array.isArray(sorter)\n ? sorter\n : typeof sorter === \"function\"\n ? [sorter]\n : [undefined, sorter]\n\n if (direction !== \"asc\" && direction !== \"desc\") {\n throw new Error(\n `@asd14/m/sortWith: Unsuported sort direction for key \"${key}\". Accepting \"asc\" or \"desc\", received \"${direction}\".`\n )\n }\n\n if (\n typeof sortFn === \"function\" &&\n (sortFn.length === 0 || sortFn.length > 2)\n ) {\n throw new Error(\n `@asd14/m/sortWith: Unsuported sort function signature for key \"${key}\". Accepting function with one or two parameters, received ${sortFn.length}.`\n )\n }\n }\n}\n\nconst _sortWith = (subset, input) => {\n _validateProps(subset)\n\n const sorters = Object.entries(subset)\n\n return [...input].sort((a, b) => {\n for (let i = 0; i < sorters.length; ++i) {\n const [key, sorter] = sorters[i]\n const [sortFn, direction = \"asc\"] = Array.isArray(sorter)\n ? sorter\n : typeof sorter === \"function\"\n ? [sorter]\n : [undefined, sorter]\n const isLastSorter = i === sorters.length - 1\n\n let result\n\n if (typeof sortFn === \"function\") {\n // one param, treat as lens: (source) => source.field\n // two params, treas as compare func: (a, b) => a - b\n\n result =\n sortFn.length === 2\n ? sortFn(a[key], b[key])\n : _compareTwoValues(direction, sortFn(a[key]), sortFn(b[key]))\n } else {\n // { key: \"direction\" }\n result = _compareTwoValues(direction, a[key], b[key])\n }\n\n if (result !== 0 || isLastSorter) {\n return result\n }\n }\n })\n}\n\n/**\n * Sort an array of objects by multiple fields\n *\n * @param {Object} subset\n * @param {Array} source\n *\n * @param {...any} params\n * @returns {Array}\n *\n * @name sortWith\n * @tag Array\n * @signature (subset: Object, source: Array): Array\n *\n * @see {@link sort}\n * @see {@link sortBy}\n *\n * @example\n * sortWith({position: \"asc\"},\n * { id: 1, position: 3 },\n * { id: 2, position: 2 },\n * { id: 3 },\n * { id: 4, position: 5 },\n * { id: 5, position: null },\n * ])\n * // [\n * // { id: 2, position: 2 },\n * // { id: 1, position: 3 },\n * // { id: 4, position: 5 },\n * // { id: 5, position: null },\n * // { id: 3 },\n * //]\n */\nexport const sortWith = (...params) => {\n // @signature (subset) => (source)\n if (params.length <= 1) {\n return input => _sortWith(params[0], input)\n }\n\n // @signature (subset, source)\n return _sortWith(...params)\n}\n"],"names":["is","_compareTwoValues","direction","a","b","valueIfFieldMissing","Number","POSITIVE_INFINITY","NEGATIVE_INFINITY","aValue","bValue","undefined","_validateProps","subset","sorters","Object","entries","key","sorter","Array","isArray","sortFn","Error","length","_sortWith","input","sort","i","isLastSorter","result","sortWith","params"],"mappings":"AAAA;;AAAA,SAASA,EAAE,QAAQ,cAAa;AAEhC,IAAMC,oBAAoB,SAACC,WAAWC,GAAGC,GAAM;IAC7C,IAAMC,sBACJH,cAAc,QAAQI,OAAOC,iBAAiB,GAAGD,OAAOE,iBAAiB;IAC3E,IAAMC,SAAST,GAAGG,KAAKA,IAAIE,mBAAmB;IAC9C,IAAMK,SAASV,GAAGI,KAAKA,IAAIC,mBAAmB;IAE9C,IAAIF,MAAM,IAAI,IAAIC,MAAMO,WAAW;QACjC,OAAOT,cAAc,SAAS,CAAC,IAAI,CAAC;IACtC,CAAC;IAED,IAAIC,MAAMQ,aAAaP,MAAM,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GA,IAAIb,QAAQS,MAAM,EAAE,EAAEI,EAAG;YACvC,IAAsBb,sBAAAA,OAAO,CAACa,EAAE,MAAzBV,MAAeH,OAAVI,SAAUJ;YACtB,IAAoCK,uBAAAA,MAAMC,OAAO,CAACF,UAC9CA,SACA,OAAOA,WAAW,aAClB;gBAACA;aAAO,GACR;gBAACP;gBAAWO;aAAO,MAJhBG,SAA6BF,QAArBjB,MAAqBiB,QAArBjB,YAAAA,iBAAY,QAAZA;YAKf,IAAM0B,eAAeD,MAAMb,QAAQS,MAAM,GAAG;YAE5C,IAAIM,SAAAA,KAAAA;YAEJ,IAAI,OAAOR,WAAW,YAAY;gBAChC,qDAAqD;gBACrD,qDAAqD;gBAErDQ,SACER,OAAOE,MAAM,KAAK,IACdF,OAAOlB,CAAC,CAACc,IAAI,EAAEb,CAAC,CAACa,IAAI,IACrBhB,kBAAkBC,WAAWmB,OAAOlB,CAAC,CAACc,IAAI,GAAGI,OAAOjB,CAAC,CAACa,IAAI,EAAE;YACpE,OAAO;gBACL,uBAAuB;gBACvBY,SAAS5B,kBAAkBC,WAAWC,CAAC,CAACc,IAAI,EAAEb,CAAC,CAACa,IAAI;YACtD,CAAC;YAED,IAAIY,WAAW,KAAKD,cAAc;gBAChC,OAAOC;YACT,CAAC;QACH;IACF;AACF;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BC,GACD,OAAO,IAAMC,WAAW,WAAe;qCAAXC;QAAAA;;IAC1B,kCAAkC;IAClC,IAAIA,OAAOR,MAAM,IAAI,GAAG;QACtB,OAAOE,SAAAA;mBAASD,UAAUO,MAAM,CAAC,EAAE,EAAEN;;IACvC,CAAC;IAED,8BAA8B;IAC9B,OAAOD,UAAAA,MAAAA,KAAAA,GAAU,qBAAGO;AACtB,EAAC"}
|
package/dist/sort/sort.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/sort/sort.js"],"sourcesContent":["import { curry } from \"../curry/curry.js\"\n\nconst _sort = (direction, input) =>\n [...input].sort((a, b) =>\n a === b ? 0 : direction === \"asc\" ? (a < b ? -1 : 1) : a < b ? 1 : -1\n )\n\n/**\n * Sort primitive array\n *\n * @param {...any} params\n * @param {string} [params.direction=\"asc\"]\n * @param {Array} params.input\n *\n * @returns {Array}\n *\n * @name sort\n * @tag Array\n * @signature (direction: string, input: Array) => Array\n * @signature (input: Array) => Array\n *\n * @see {@link sortBy}\n * @see {@link sortWith}\n *\n * @example\n * sort([3, 2, 1])\n * // => [1, 2, 3]\n *\n * sort(\"desc\", [1, 2, 3])\n * // => [3, 2, 1]\n */\nexport const sort = (...params) => {\n // @signature (input)\n if (Array.isArray(params[0])) {\n return _sort(\"asc\", params[0])\n }\n\n // @signature (direction) => (input)\n if (params.length <= 1) {\n return input => _sort(params[0], input)\n }\n\n // @signature (direction, input)\n return _sort(...params)\n}\n\n/**\n * Sort array using custom function\n *\n * @param {Function} fn Sort function\n * @param {Array} input\n *\n * @returns {Array}\n *\n * @name sortBy\n * @tag Array\n * @signature (fn: Function, input: Array) => Array\n *\n * @see {@link sort}\n * @see {@link sortWith}\n *\n * @example\n * sortBy((a, b) => a.id - b.id, [{id: 2}, {id: 1}])\n * // => [{id: 1}, {id: 2}]\n */\nexport const sortBy = curry((fn, input) => [...input].sort(fn))\n"],"names":["curry","_sort","direction","input","sort","a","b","params","Array","isArray","length","sortBy","fn"],"mappings":"AAAA;AAAA,SAASA,KAAK,QAAQ,
|
|
1
|
+
{"version":3,"sources":["../../src/sort/sort.js"],"sourcesContent":["import { curry } from \"../curry/curry.js\"\n\nconst _sort = (direction, input) =>\n [...input].sort((a, b) =>\n a === b ? 0 : direction === \"asc\" ? (a < b ? -1 : 1) : a < b ? 1 : -1\n )\n\n/**\n * Sort primitive array\n *\n * @param {...any} params\n * @param {string} [params.direction=\"asc\"]\n * @param {Array} params.input\n *\n * @returns {Array}\n *\n * @name sort\n * @tag Array\n * @signature (direction: string, input: Array) => Array\n * @signature (input: Array) => Array\n *\n * @see {@link sortBy}\n * @see {@link sortWith}\n *\n * @example\n * sort([3, 2, 1])\n * // => [1, 2, 3]\n *\n * sort(\"desc\", [1, 2, 3])\n * // => [3, 2, 1]\n */\nexport const sort = (...params) => {\n // @signature (input)\n if (Array.isArray(params[0])) {\n return _sort(\"asc\", params[0])\n }\n\n // @signature (direction) => (input)\n if (params.length <= 1) {\n return input => _sort(params[0], input)\n }\n\n // @signature (direction, input)\n return _sort(...params)\n}\n\n/**\n * Sort array using custom function\n *\n * @param {Function} fn Sort function\n * @param {Array} input\n *\n * @returns {Array}\n *\n * @name sortBy\n * @tag Array\n * @signature (fn: Function, input: Array) => Array\n *\n * @see {@link sort}\n * @see {@link sortWith}\n *\n * @example\n * sortBy((a, b) => a.id - b.id, [{id: 2}, {id: 1}])\n * // => [{id: 1}, {id: 2}]\n */\nexport const sortBy = curry((fn, input) => [...input].sort(fn))\n"],"names":["curry","_sort","direction","input","sort","a","b","params","Array","isArray","length","sortBy","fn"],"mappings":"AAAA;AAAA,SAASA,KAAK,QAAQ,oBAAmB;AAEzC,IAAMC,QAAQ,SAACC,WAAWC;WACxB,AAAC,qBAAGA,OAAOC,IAAI,CAAC,SAACC,GAAGC;eAClBD,MAAMC,IAAI,IAAIJ,cAAc,QAASG,IAAIC,IAAI,CAAC,IAAI,CAAC,GAAID,IAAIC,IAAI,IAAI,CAAC,CAAC;;;AAGzE;;;;;;;;;;;;;;;;;;;;;;;CAuBC,GACD,OAAO,IAAMF,OAAO,WAAe;qCAAXG;QAAAA;;IACtB,qBAAqB;IACrB,IAAIC,MAAMC,OAAO,CAACF,MAAM,CAAC,EAAE,GAAG;QAC5B,OAAON,MAAM,OAAOM,MAAM,CAAC,EAAE;IAC/B,CAAC;IAED,oCAAoC;IACpC,IAAIA,OAAOG,MAAM,IAAI,GAAG;QACtB,OAAOP,SAAAA;mBAASF,MAAMM,MAAM,CAAC,EAAE,EAAEJ;;IACnC,CAAC;IAED,gCAAgC;IAChC,OAAOF,MAAAA,MAAAA,KAAAA,GAAM,qBAAGM;AAClB,EAAC;AAED;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,IAAMI,SAASX,MAAM,SAACY,IAAIT;WAAU,AAAC,qBAAGA,OAAOC,IAAI,CAACQ;GAAI"}
|
package/dist/sort/sort.test.js
CHANGED
|
@@ -46,7 +46,7 @@ test("sortBy", function(t) {
|
|
|
46
46
|
{
|
|
47
47
|
id: 2,
|
|
48
48
|
position: 2
|
|
49
|
-
}
|
|
49
|
+
}
|
|
50
50
|
]), [
|
|
51
51
|
{
|
|
52
52
|
id: 2,
|
|
@@ -59,7 +59,7 @@ test("sortBy", function(t) {
|
|
|
59
59
|
{
|
|
60
60
|
id: 4,
|
|
61
61
|
position: 5
|
|
62
|
-
}
|
|
62
|
+
}
|
|
63
63
|
], "given [an array of objects and a custom compare function] should [return an sorted array]");
|
|
64
64
|
t.deepEqual(sortBy(function(a, b) {
|
|
65
65
|
return a.position - b.position;
|
|
@@ -82,7 +82,7 @@ test("sortBy", function(t) {
|
|
|
82
82
|
{
|
|
83
83
|
id: 4,
|
|
84
84
|
position: 5
|
|
85
|
-
}
|
|
85
|
+
}
|
|
86
86
|
]), [
|
|
87
87
|
{
|
|
88
88
|
id: 5,
|
|
@@ -102,7 +102,7 @@ test("sortBy", function(t) {
|
|
|
102
102
|
{
|
|
103
103
|
id: 4,
|
|
104
104
|
position: 5
|
|
105
|
-
}
|
|
105
|
+
}
|
|
106
106
|
], "given [an array of objects and a custom compare function] should [return an sorted array (curried)]");
|
|
107
107
|
t.end();
|
|
108
108
|
});
|
|
@@ -130,7 +130,7 @@ test("sortWith", function(t) {
|
|
|
130
130
|
id: 6,
|
|
131
131
|
position: 0,
|
|
132
132
|
isActive: false
|
|
133
|
-
}
|
|
133
|
+
}
|
|
134
134
|
]), [
|
|
135
135
|
{
|
|
136
136
|
id: 1,
|
|
@@ -151,7 +151,7 @@ test("sortWith", function(t) {
|
|
|
151
151
|
id: 3,
|
|
152
152
|
position: 4,
|
|
153
153
|
isActive: false
|
|
154
|
-
}
|
|
154
|
+
}
|
|
155
155
|
], "given [an array of objects and a subset of 2 fields with different directions] should [return a sorted array]");
|
|
156
156
|
t.deepEqual(sortWith({
|
|
157
157
|
isActive: "desc",
|
|
@@ -187,7 +187,7 @@ test("sortWith", function(t) {
|
|
|
187
187
|
id: 12,
|
|
188
188
|
createdAt: "12-02-2003",
|
|
189
189
|
isActive: null
|
|
190
|
-
}
|
|
190
|
+
}
|
|
191
191
|
]), [
|
|
192
192
|
{
|
|
193
193
|
id: 2,
|
|
@@ -217,7 +217,7 @@ test("sortWith", function(t) {
|
|
|
217
217
|
{
|
|
218
218
|
id: 11,
|
|
219
219
|
createdAt: "12-02-2003"
|
|
220
|
-
}
|
|
220
|
+
}
|
|
221
221
|
], "given [an array of objects and a subset of 2 fields, one with a compare function] should [return a sorted array]");
|
|
222
222
|
t.deepEqual(sortWith({
|
|
223
223
|
createdAt: function(input) {
|
|
@@ -247,7 +247,7 @@ test("sortWith", function(t) {
|
|
|
247
247
|
{
|
|
248
248
|
id: 11,
|
|
249
249
|
createdAt: "12-02-2003"
|
|
250
|
-
}
|
|
250
|
+
}
|
|
251
251
|
]), [
|
|
252
252
|
{
|
|
253
253
|
id: 3,
|
|
@@ -272,7 +272,7 @@ test("sortWith", function(t) {
|
|
|
272
272
|
id: 4,
|
|
273
273
|
createdAt: "12-02-2011",
|
|
274
274
|
isActive: true
|
|
275
|
-
}
|
|
275
|
+
}
|
|
276
276
|
], "given [an array of objects and a subset with a field transformer function] should [return a sorted array]");
|
|
277
277
|
t.deepEqual(sortWith({
|
|
278
278
|
createdAt: [
|
|
@@ -305,7 +305,7 @@ test("sortWith", function(t) {
|
|
|
305
305
|
{
|
|
306
306
|
id: 11,
|
|
307
307
|
createdAt: "12-02-2003"
|
|
308
|
-
}
|
|
308
|
+
}
|
|
309
309
|
]), [
|
|
310
310
|
{
|
|
311
311
|
id: 4,
|
|
@@ -330,7 +330,7 @@ test("sortWith", function(t) {
|
|
|
330
330
|
id: 3,
|
|
331
331
|
createdAt: "12-02-2001",
|
|
332
332
|
isActive: false
|
|
333
|
-
}
|
|
333
|
+
}
|
|
334
334
|
], "given [an array of objects, a subset with a field transformer function and explicit direction] should [return a sorted array]");
|
|
335
335
|
t.deepEqual(sortWith({
|
|
336
336
|
createdAt: [
|
|
@@ -363,7 +363,7 @@ test("sortWith", function(t) {
|
|
|
363
363
|
{
|
|
364
364
|
id: 11,
|
|
365
365
|
createdAt: "12-02-2003"
|
|
366
|
-
}
|
|
366
|
+
}
|
|
367
367
|
]), [
|
|
368
368
|
{
|
|
369
369
|
id: 4,
|
|
@@ -388,7 +388,7 @@ test("sortWith", function(t) {
|
|
|
388
388
|
id: 3,
|
|
389
389
|
createdAt: "12-02-2001",
|
|
390
390
|
isActive: false
|
|
391
|
-
}
|
|
391
|
+
}
|
|
392
392
|
], "given [an array of objects, a subset with a field transformer function and explicit direction] should [return a sorted array]");
|
|
393
393
|
t.throws(function() {
|
|
394
394
|
return sortWith({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/sort/sort.test.js"],"sourcesContent":["/* eslint-disable unicorn/no-null,new-cap */\n\nimport test from \"tape\"\n\nimport { sort, sortBy } from \"./sort.js\"\nimport { sortWith } from \"./sort-with.js\"\n\ntest(\"sort\", t => {\n t.deepEqual(\n sort([3, 2, 1]),\n [1, 2, 3],\n \"given [an array with unsorted numbers] should [return an asc sorted array]\"\n )\n\n t.deepEqual(\n sort(\"desc\", [2, 4, 1]),\n [4, 2, 1],\n \"given [an array with unsorted numbers] should [return an desc sorted array]\"\n )\n\n t.deepEqual(\n sort(\"desc\")([\"a\", \"c\", \"b\"]),\n [\"c\", \"b\", \"a\"],\n \"given [an array with unsorted string] should [return an desc sorted array (curried)]\"\n )\n\n t.end()\n})\n\ntest(\"sortBy\", t => {\n t.deepEqual(\n sortBy(\n (a, b) => a.position - b.position,\n [\n { id: 4, position: 5 },\n { id: 1, position: 3 },\n { id: 2, position: 2 },\n ]\n ),\n [\n { id: 2, position: 2 },\n { id: 1, position: 3 },\n { id: 4, position: 5 },\n ],\n \"given [an array of objects and a custom compare function] should [return an sorted array]\"\n )\n\n t.deepEqual(\n sortBy((a, b) => a.position - b.position)([\n { id: 5, position: null },\n { id: 3 },\n { id: 1, position: 3 },\n { id: 2, position: 2 },\n { id: 4, position: 5 },\n ]),\n [\n { id: 5, position: null },\n { id: 3 },\n { id: 2, position: 2 },\n { id: 1, position: 3 },\n { id: 4, position: 5 },\n ],\n \"given [an array of objects and a custom compare function] should [return an sorted array (curried)]\"\n )\n\n t.end()\n})\n\ntest(\"sortWith\", t => {\n t.deepEqual(\n sortWith(\n {\n isActive: \"desc\",\n position: \"asc\",\n },\n [\n { id: 4, position: 5, isActive: true },\n { id: 1, position: 3, isActive: true },\n { id: 3, position: 4, isActive: false },\n { id: 6, position: 0, isActive: false },\n ]\n ),\n [\n { id: 1, position: 3, isActive: true },\n { id: 4, position: 5, isActive: true },\n { id: 6, position: 0, isActive: false },\n { id: 3, position: 4, isActive: false },\n ],\n \"given [an array of objects and a subset of 2 fields with different directions] should [return a sorted array]\"\n )\n\n t.deepEqual(\n sortWith(\n {\n isActive: \"desc\",\n createdAt: (a, b) => new Date(a).getTime() - new Date(b).getTime(),\n },\n [\n { id: 5, createdAt: \"12-02-2010\", isActive: false },\n { id: 4, createdAt: \"12-02-2011\", isActive: true },\n { id: 6, createdAt: \"12-02-2005\", isActive: false },\n { id: 2, createdAt: \"12-02-2003\", isActive: true },\n { id: 11, createdAt: \"12-02-2003\" },\n { id: 12, createdAt: \"12-02-2003\", isActive: null },\n ]\n ),\n [\n { id: 2, createdAt: \"12-02-2003\", isActive: true },\n { id: 4, createdAt: \"12-02-2011\", isActive: true },\n { id: 6, createdAt: \"12-02-2005\", isActive: false },\n { id: 5, createdAt: \"12-02-2010\", isActive: false },\n { id: 12, createdAt: \"12-02-2003\", isActive: null },\n { id: 11, createdAt: \"12-02-2003\" },\n ],\n \"given [an array of objects and a subset of 2 fields, one with a compare function] should [return a sorted array]\"\n )\n\n t.deepEqual(\n sortWith({\n createdAt: input => new Date(input).getTime(),\n })([\n { id: 5, createdAt: \"12-02-2010\", isActive: false },\n { id: 4, createdAt: \"12-02-2011\", isActive: true },\n { id: 3, createdAt: \"12-02-2001\", isActive: false },\n { id: 6, createdAt: \"12-02-2005\", isActive: false },\n { id: 11, createdAt: \"12-02-2003\" },\n ]),\n [\n { id: 3, createdAt: \"12-02-2001\", isActive: false },\n { id: 11, createdAt: \"12-02-2003\" },\n { id: 6, createdAt: \"12-02-2005\", isActive: false },\n { id: 5, createdAt: \"12-02-2010\", isActive: false },\n { id: 4, createdAt: \"12-02-2011\", isActive: true },\n ],\n \"given [an array of objects and a subset with a field transformer function] should [return a sorted array]\"\n )\n\n t.deepEqual(\n sortWith(\n {\n createdAt: [input => new Date(input).getTime(), \"desc\"],\n },\n [\n { id: 5, createdAt: \"12-02-2010\", isActive: false },\n { id: 4, createdAt: \"12-02-2011\", isActive: true },\n { id: 3, createdAt: \"12-02-2001\", isActive: false },\n { id: 6, createdAt: \"12-02-2005\", isActive: false },\n { id: 11, createdAt: \"12-02-2003\" },\n ]\n ),\n [\n { id: 4, createdAt: \"12-02-2011\", isActive: true },\n { id: 5, createdAt: \"12-02-2010\", isActive: false },\n { id: 6, createdAt: \"12-02-2005\", isActive: false },\n { id: 11, createdAt: \"12-02-2003\" },\n { id: 3, createdAt: \"12-02-2001\", isActive: false },\n ],\n \"given [an array of objects, a subset with a field transformer function and explicit direction] should [return a sorted array]\"\n )\n\n t.deepEqual(\n sortWith(\n {\n createdAt: [input => new Date(input).getTime(), \"desc\"],\n },\n [\n { id: 5, createdAt: \"12-02-2010\", isActive: false },\n { id: 4, createdAt: \"12-02-2011\", isActive: true },\n { id: 3, createdAt: \"12-02-2001\", isActive: false },\n { id: 6, createdAt: \"12-02-2005\", isActive: false },\n { id: 11, createdAt: \"12-02-2003\" },\n ]\n ),\n [\n { id: 4, createdAt: \"12-02-2011\", isActive: true },\n { id: 5, createdAt: \"12-02-2010\", isActive: false },\n { id: 6, createdAt: \"12-02-2005\", isActive: false },\n { id: 11, createdAt: \"12-02-2003\" },\n { id: 3, createdAt: \"12-02-2001\", isActive: false },\n ],\n \"given [an array of objects, a subset with a field transformer function and explicit direction] should [return a sorted array]\"\n )\n\n t.throws(\n () =>\n sortWith(\n { createdAt: [input => new Date(input).getTime(), \"doesc\"] },\n []\n ),\n 'Error: @asd14/m/sortWith: Unsuported sort direction for key \"createdAt\". Accepting \"asc\" or \"desc\", received \"doesc\".',\n \"given [invalid sort direction] shold [throw]\"\n )\n\n t.throws(\n () => sortWith({ createdAt: () => 2 }, []),\n 'Error: @asd14/m/sortWith: Unsuported sort function signature for key \"createdAt\". Accepting function with one or two parameters, received 0.',\n \"given [invalid sort function] shold [throw]\"\n )\n\n t.end()\n})\n"],"names":["test","sort","sortBy","sortWith","t","deepEqual","end","a","b","position","id","isActive","createdAt","Date","getTime","input","throws"],"mappings":"AAAA,0CAA0C,GAE1C,OAAOA,IAAI,MAAM,MAAM,CAAA;AAEvB,SAASC,IAAI,EAAEC,MAAM,QAAQ,WAAW,CAAA;AACxC,SAASC,QAAQ,QAAQ,gBAAgB,CAAA;AAEzCH,IAAI,CAAC,MAAM,EAAEI,SAAAA,CAAC,EAAI;IAChBA,CAAC,CAACC,SAAS,CACTJ,IAAI,CAAC;AAAC,SAAC;AAAE,SAAC;AAAE,SAAC;KAAC,CAAC,EACf;AAAC,SAAC;AAAE,SAAC;AAAE,SAAC;KAAC,EACT,4EAA4E,CAC7E;IAEDG,CAAC,CAACC,SAAS,CACTJ,IAAI,CAAC,MAAM,EAAE;AAAC,SAAC;AAAE,SAAC;AAAE,SAAC;KAAC,CAAC,EACvB;AAAC,SAAC;AAAE,SAAC;AAAE,SAAC;KAAC,EACT,6EAA6E,CAC9E;IAEDG,CAAC,CAACC,SAAS,CACTJ,IAAI,CAAC,MAAM,CAAC,CAAC;QAAC,GAAG;Q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,SAAS,EAAE,YAAY;YAAED,QAAQ,EAAE,KAAK;SAAE;QACnD;YAAED,EAAE,EAAE,CAAC;YAAEE,SAAS,EAAE,YAAY;YAAED,QAAQ,EAAE,KAAK;SAAE;QACnD;YAAED,EAAE,EAAE,EAAE;YAAEE,SAAS,EAAE,YAAY;SAAE;KACpC,CACF,EACD;QACE;YAAEF,EAAE,EAAE,CAAC;YAAEE,SAAS,EAAE,YAAY;YAAED,QAAQ,EAAE,IAAI;SAAE;QAClD;YAAED,EAAE,EAAE,CAAC;YAAEE,SAAS,EAAE,YAAY;YAAED,QAAQ,EAAE,KAAK;SAAE;QACnD;YAAED,EAAE,EAAE,CAAC;YAAEE,SAAS,EAAE,YAAY;YAAED,QAAQ,EAAE,KAAK;SAAE;QACnD;YAAED,EAAE,EAAE,EAAE;YAAEE,SAAS,EAAE,YAAY;SAAE;QACnC;YAAEF,EAAE,EAAE,CAAC;YAAEE,SAAS,EAAE,YAAY;YAAED,QAAQ,EAAE,KAAK;SAAE;KACpD,EACD,+HAA+H,CAChI;IAEDP,CAAC,CAACY,MAAM,CACN;eACEb,QAAQ,CACN;YAAES,SAAS,EAAE;gBAACG,SAAAA,KAAK;2BAAI,IAAIF,IAAI,CAACE,KAAK,CAAC,CAACD,OAAO,EAAE;iBAAA;gBAAE,OAAO;aAAC;SAAE,EAC5D,EAAE,CACH;KAAA,EACH,uHAAuH,EACvH,8CAA8C,CAC/C;IAEDV,CAAC,CAACY,MAAM,CACN;eAAMb,QAAQ,CAAC;YAAES,SAAS,EAAE;uBAAM,CAAC;aAAA;SAAE,EAAE,EAAE,CAAC;KAAA,EAC1C,8IAA8I,EAC9I,6CAA6C,CAC9C;IAEDR,CAAC,CAACE,GAAG,EAAE;AACT,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/sort/sort.test.js"],"sourcesContent":["/* eslint-disable unicorn/no-null,new-cap */\n\nimport test from \"tape\"\n\nimport { sort, sortBy } from \"./sort.js\"\nimport { sortWith } from \"./sort-with.js\"\n\ntest(\"sort\", t => {\n t.deepEqual(\n sort([3, 2, 1]),\n [1, 2, 3],\n \"given [an array with unsorted numbers] should [return an asc sorted array]\"\n )\n\n t.deepEqual(\n sort(\"desc\", [2, 4, 1]),\n [4, 2, 1],\n \"given [an array with unsorted numbers] should [return an desc sorted array]\"\n )\n\n t.deepEqual(\n sort(\"desc\")([\"a\", \"c\", \"b\"]),\n [\"c\", \"b\", \"a\"],\n \"given [an array with unsorted string] should [return an desc sorted array (curried)]\"\n )\n\n t.end()\n})\n\ntest(\"sortBy\", t => {\n t.deepEqual(\n sortBy(\n (a, b) => a.position - b.position,\n [\n { id: 4, position: 5 },\n { id: 1, position: 3 },\n { id: 2, position: 2 },\n ]\n ),\n [\n { id: 2, position: 2 },\n { id: 1, position: 3 },\n { id: 4, position: 5 },\n ],\n \"given [an array of objects and a custom compare function] should [return an sorted array]\"\n )\n\n t.deepEqual(\n sortBy((a, b) => a.position - b.position)([\n { id: 5, position: null },\n { id: 3 },\n { id: 1, position: 3 },\n { id: 2, position: 2 },\n { id: 4, position: 5 },\n ]),\n [\n { id: 5, position: null },\n { id: 3 },\n { id: 2, position: 2 },\n { id: 1, position: 3 },\n { id: 4, position: 5 },\n ],\n \"given [an array of objects and a custom compare function] should [return an sorted array (curried)]\"\n )\n\n t.end()\n})\n\ntest(\"sortWith\", t => {\n t.deepEqual(\n sortWith(\n {\n isActive: \"desc\",\n position: \"asc\",\n },\n [\n { id: 4, position: 5, isActive: true },\n { id: 1, position: 3, isActive: true },\n { id: 3, position: 4, isActive: false },\n { id: 6, position: 0, isActive: false },\n ]\n ),\n [\n { id: 1, position: 3, isActive: true },\n { id: 4, position: 5, isActive: true },\n { id: 6, position: 0, isActive: false },\n { id: 3, position: 4, isActive: false },\n ],\n \"given [an array of objects and a subset of 2 fields with different directions] should [return a sorted array]\"\n )\n\n t.deepEqual(\n sortWith(\n {\n isActive: \"desc\",\n createdAt: (a, b) => new Date(a).getTime() - new Date(b).getTime(),\n },\n [\n { id: 5, createdAt: \"12-02-2010\", isActive: false },\n { id: 4, createdAt: \"12-02-2011\", isActive: true },\n { id: 6, createdAt: \"12-02-2005\", isActive: false },\n { id: 2, createdAt: \"12-02-2003\", isActive: true },\n { id: 11, createdAt: \"12-02-2003\" },\n { id: 12, createdAt: \"12-02-2003\", isActive: null },\n ]\n ),\n [\n { id: 2, createdAt: \"12-02-2003\", isActive: true },\n { id: 4, createdAt: \"12-02-2011\", isActive: true },\n { id: 6, createdAt: \"12-02-2005\", isActive: false },\n { id: 5, createdAt: \"12-02-2010\", isActive: false },\n { id: 12, createdAt: \"12-02-2003\", isActive: null },\n { id: 11, createdAt: \"12-02-2003\" },\n ],\n \"given [an array of objects and a subset of 2 fields, one with a compare function] should [return a sorted array]\"\n )\n\n t.deepEqual(\n sortWith({\n createdAt: input => new Date(input).getTime(),\n })([\n { id: 5, createdAt: \"12-02-2010\", isActive: false },\n { id: 4, createdAt: \"12-02-2011\", isActive: true },\n { id: 3, createdAt: \"12-02-2001\", isActive: false },\n { id: 6, createdAt: \"12-02-2005\", isActive: false },\n { id: 11, createdAt: \"12-02-2003\" },\n ]),\n [\n { id: 3, createdAt: \"12-02-2001\", isActive: false },\n { id: 11, createdAt: \"12-02-2003\" },\n { id: 6, createdAt: \"12-02-2005\", isActive: false },\n { id: 5, createdAt: \"12-02-2010\", isActive: false },\n { id: 4, createdAt: \"12-02-2011\", isActive: true },\n ],\n \"given [an array of objects and a subset with a field transformer function] should [return a sorted array]\"\n )\n\n t.deepEqual(\n sortWith(\n {\n createdAt: [input => new Date(input).getTime(), \"desc\"],\n },\n [\n { id: 5, createdAt: \"12-02-2010\", isActive: false },\n { id: 4, createdAt: \"12-02-2011\", isActive: true },\n { id: 3, createdAt: \"12-02-2001\", isActive: false },\n { id: 6, createdAt: \"12-02-2005\", isActive: false },\n { id: 11, createdAt: \"12-02-2003\" },\n ]\n ),\n [\n { id: 4, createdAt: \"12-02-2011\", isActive: true },\n { id: 5, createdAt: \"12-02-2010\", isActive: false },\n { id: 6, createdAt: \"12-02-2005\", isActive: false },\n { id: 11, createdAt: \"12-02-2003\" },\n { id: 3, createdAt: \"12-02-2001\", isActive: false },\n ],\n \"given [an array of objects, a subset with a field transformer function and explicit direction] should [return a sorted array]\"\n )\n\n t.deepEqual(\n sortWith(\n {\n createdAt: [input => new Date(input).getTime(), \"desc\"],\n },\n [\n { id: 5, createdAt: \"12-02-2010\", isActive: false },\n { id: 4, createdAt: \"12-02-2011\", isActive: true },\n { id: 3, createdAt: \"12-02-2001\", isActive: false },\n { id: 6, createdAt: \"12-02-2005\", isActive: false },\n { id: 11, createdAt: \"12-02-2003\" },\n ]\n ),\n [\n { id: 4, createdAt: \"12-02-2011\", isActive: true },\n { id: 5, createdAt: \"12-02-2010\", isActive: false },\n { id: 6, createdAt: \"12-02-2005\", isActive: false },\n { id: 11, createdAt: \"12-02-2003\" },\n { id: 3, createdAt: \"12-02-2001\", isActive: false },\n ],\n \"given [an array of objects, a subset with a field transformer function and explicit direction] should [return a sorted array]\"\n )\n\n t.throws(\n () =>\n sortWith(\n { createdAt: [input => new Date(input).getTime(), \"doesc\"] },\n []\n ),\n 'Error: @asd14/m/sortWith: Unsuported sort direction for key \"createdAt\". Accepting \"asc\" or \"desc\", received \"doesc\".',\n \"given [invalid sort direction] shold [throw]\"\n )\n\n t.throws(\n () => sortWith({ createdAt: () => 2 }, []),\n 'Error: @asd14/m/sortWith: Unsuported sort function signature for key \"createdAt\". Accepting function with one or two parameters, received 0.',\n \"given [invalid sort function] shold [throw]\"\n )\n\n t.end()\n})\n"],"names":["test","sort","sortBy","sortWith","t","deepEqual","end","a","b","position","id","isActive","createdAt","Date","getTime","input","throws"],"mappings":"AAAA,0CAA0C,GAE1C,OAAOA,UAAU,OAAM;AAEvB,SAASC,IAAI,EAAEC,MAAM,QAAQ,YAAW;AACxC,SAASC,QAAQ,QAAQ,iBAAgB;AAEzCH,KAAK,QAAQI,SAAAA,GAAK;IAChBA,EAAEC,SA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YAAGE,WAAW;YAAcD,UAAU,KAAK;QAAC;QAClD;YAAED,IAAI;YAAGE,WAAW;YAAcD,UAAU,KAAK;QAAC;QAClD;YAAED,IAAI;YAAIE,WAAW;QAAa;QAClC;YAAEF,IAAI;YAAGE,WAAW;YAAcD,UAAU,KAAK;QAAC;KACnD,EACD;IAGFP,EAAEC,SAAS,CACTF,SACE;QACES,WAAW;YAACG,SAAAA;uBAAS,IAAIF,KAAKE,OAAOD,OAAO;;YAAI;SAAO;IACzD,GACA;QACE;YAAEJ,IAAI;YAAGE,WAAW;YAAcD,UAAU,KAAK;QAAC;QAClD;YAAED,IAAI;YAAGE,WAAW;YAAcD,UAAU,IAAI;QAAC;QACjD;YAAED,IAAI;YAAGE,WAAW;YAAcD,UAAU,KAAK;QAAC;QAClD;YAAED,IAAI;YAAGE,WAAW;YAAcD,UAAU,KAAK;QAAC;QAClD;YAAED,IAAI;YAAIE,WAAW;QAAa;KACnC,GAEH;QACE;YAAEF,IAAI;YAAGE,WAAW;YAAcD,UAAU,IAAI;QAAC;QACjD;YAAED,IAAI;YAAGE,WAAW;YAAcD,UAAU,KAAK;QAAC;QAClD;YAAED,IAAI;YAAGE,WAAW;YAAcD,UAAU,KAAK;QAAC;QAClD;YAAED,IAAI;YAAIE,WAAW;QAAa;QAClC;YAAEF,IAAI;YAAGE,WAAW;YAAcD,UAAU,KAAK;QAAC;KACnD,EACD;IAGFP,EAAEY,MAAM,CACN;eACEb,SACE;YAAES,WAAW;gBAACG,SAAAA;2BAAS,IAAIF,KAAKE,OAAOD,OAAO;;gBAAI;aAAQ;QAAC,GAC3D,EAAE;OAEN,yHACA;IAGFV,EAAEY,MAAM,CACN;eAAMb,SAAS;YAAES,WAAW;uBAAM;;QAAE,GAAG,EAAE;OACzC,gJACA;IAGFR,EAAEE,GAAG;AACP"}
|
package/dist/split/split.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/split/split.js"],"sourcesContent":["const _split = (separator, input) => {\n if (!(separator instanceof RegExp) && typeof separator !== \"string\") {\n throw new TypeError(\n `split - invalid 'separator' parameter type '${typeof separator}'. 'separator' type should be a String or RegExp.`\n )\n }\n\n if (typeof input !== \"string\") {\n throw new TypeError(\n `split - invalid 'source' parameter type '${typeof input}'. 'source' type should be String.`\n )\n }\n\n return input.split(separator)\n}\n\n/**\n * Splits a String object into an array of strings by separating the string\n * into substrings, using a specified separator string to determine where to\n * make each split.\n *\n * @tag String\n * @signature (separator: string|RegExp, input:string): Array\n * @signature (separator: string|RegExp) => (input:string): Array\n *\n * @param {...any} params\n * @param {string|RegExp} params.separator Points where each split should occur\n * @param {string} params.input Input string\n *\n * @returns {Array}\n *\n * @example\n * split(\",\", \"lorem,ipsum\")\n * // [\"lorem\", \"ipsum\"]\n */\nexport const split = (...params) => {\n // @signature (separator) => (input)\n if (params.length <= 1) {\n return input => _split(params[0], input)\n }\n\n // @signature (separator, input)\n return _split(...params)\n}\n"],"names":["_split","separator","input","RegExp","TypeError","split","params","length"],"mappings":"AAAA;;AAAA,IAAMA,
|
|
1
|
+
{"version":3,"sources":["../../src/split/split.js"],"sourcesContent":["const _split = (separator, input) => {\n if (!(separator instanceof RegExp) && typeof separator !== \"string\") {\n throw new TypeError(\n `split - invalid 'separator' parameter type '${typeof separator}'. 'separator' type should be a String or RegExp.`\n )\n }\n\n if (typeof input !== \"string\") {\n throw new TypeError(\n `split - invalid 'source' parameter type '${typeof input}'. 'source' type should be String.`\n )\n }\n\n return input.split(separator)\n}\n\n/**\n * Splits a String object into an array of strings by separating the string\n * into substrings, using a specified separator string to determine where to\n * make each split.\n *\n * @tag String\n * @signature (separator: string|RegExp, input:string): Array\n * @signature (separator: string|RegExp) => (input:string): Array\n *\n * @param {...any} params\n * @param {string|RegExp} params.separator Points where each split should occur\n * @param {string} params.input Input string\n *\n * @returns {Array}\n *\n * @example\n * split(\",\", \"lorem,ipsum\")\n * // [\"lorem\", \"ipsum\"]\n */\nexport const split = (...params) => {\n // @signature (separator) => (input)\n if (params.length <= 1) {\n return input => _split(params[0], input)\n }\n\n // @signature (separator, input)\n return _split(...params)\n}\n"],"names":["_split","separator","input","RegExp","TypeError","split","params","length"],"mappings":"AAAA;;AAAA,IAAMA,SAAS,SAACC,WAAWC,OAAU;IACnC,IAAI,CAAED,CAAAA,qBAAqBE,MAAK,KAAM,OAAOF,cAAc,UAAU;QACnE,MAAM,IAAIG,UACR,AAAC,+CAA+D,OAAjB,OAAOH,0CAAP,SAAOA,UAAS,EAAC,sDACjE;IACH,CAAC;IAED,IAAI,OAAOC,UAAU,UAAU;QAC7B,MAAM,IAAIE,UACR,AAAC,4CAAwD,OAAb,OAAOF,sCAAP,SAAOA,MAAK,EAAC,uCAC1D;IACH,CAAC;IAED,OAAOA,MAAMG,KAAK,CAACJ;AACrB;AAEA;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,IAAMI,QAAQ,WAAe;qCAAXC;QAAAA;;IACvB,oCAAoC;IACpC,IAAIA,OAAOC,MAAM,IAAI,GAAG;QACtB,OAAOL,SAAAA;mBAASF,OAAOM,MAAM,CAAC,EAAE,EAAEJ;;IACpC,CAAC;IAED,gCAAgC;IAChC,OAAOF,OAAAA,MAAAA,KAAAA,GAAO,qBAAGM;AACnB,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/split/split.test.js"],"sourcesContent":["/* eslint-disable new-cap */\n\nimport test from \"tape\"\n\nimport { split } from \"./split.js\"\n\ntest(\"split\", t => {\n t.deepEqual(\n split(\",\")(\"lorem,ipsum\"),\n [\"lorem\", \"ipsum\"],\n \"given [string that contains one ',', splitting by it] should [return array with 2 strings]\"\n )\n\n t.deepEqual(\n split(/[,-]/, \"foo,bar-lorem\"),\n [\"foo\", \"bar\", \"lorem\"],\n \"given [string that contains one ',' and one '-', splitting by a RegExp matching both] should [return array with 3 strings]\"\n )\n\n t.throws(\n () => split(\",\", [1, 2, 3, 4]),\n \"TypeError: split - invalid 'source' parameter type 'object'. 'source' type should be String.\",\n \"given [non-string source] shold [throw]\"\n )\n\n t.throws(\n () => split(2, [1, 2, 3, 4]),\n \"TypeError: split - invalid 'separator' parameter type 'number'. 'separator' type should be a String or RegExp.\",\n \"given [non-string, non-regexp separator] shold [throw]\"\n )\n\n t.end()\n})\n"],"names":["test","split","t","deepEqual","throws","end"],"mappings":"AAAA,0BAA0B,GAE1B,OAAOA,
|
|
1
|
+
{"version":3,"sources":["../../src/split/split.test.js"],"sourcesContent":["/* eslint-disable new-cap */\n\nimport test from \"tape\"\n\nimport { split } from \"./split.js\"\n\ntest(\"split\", t => {\n t.deepEqual(\n split(\",\")(\"lorem,ipsum\"),\n [\"lorem\", \"ipsum\"],\n \"given [string that contains one ',', splitting by it] should [return array with 2 strings]\"\n )\n\n t.deepEqual(\n split(/[,-]/, \"foo,bar-lorem\"),\n [\"foo\", \"bar\", \"lorem\"],\n \"given [string that contains one ',' and one '-', splitting by a RegExp matching both] should [return array with 3 strings]\"\n )\n\n t.throws(\n () => split(\",\", [1, 2, 3, 4]),\n \"TypeError: split - invalid 'source' parameter type 'object'. 'source' type should be String.\",\n \"given [non-string source] shold [throw]\"\n )\n\n t.throws(\n () => split(2, [1, 2, 3, 4]),\n \"TypeError: split - invalid 'separator' parameter type 'number'. 'separator' type should be a String or RegExp.\",\n \"given [non-string, non-regexp separator] shold [throw]\"\n )\n\n t.end()\n})\n"],"names":["test","split","t","deepEqual","throws","end"],"mappings":"AAAA,0BAA0B,GAE1B,OAAOA,UAAU,OAAM;AAEvB,SAASC,KAAK,QAAQ,aAAY;AAElCD,KAAK,SAASE,SAAAA,GAAK;IACjBA,EAAEC,SAAS,CACTF,MAAM,KAAK,gBACX;QAAC;QAAS;KAAQ,EAClB;IAGFC,EAAEC,SAAS,CACTF,MAAM,QAAQ,kBACd;QAAC;QAAO;QAAO;KAAQ,EACvB;IAGFC,EAAEE,MAAM,CACN;eAAMH,MAAM,KAAK;YAAC;YAAG;YAAG;YAAG;SAAE;OAC7B,gGACA;IAGFC,EAAEE,MAAM,CACN;eAAMH,MAAM,GAAG;YAAC;YAAG;YAAG;YAAG;SAAE;OAC3B,kHACA;IAGFC,EAAEG,GAAG;AACP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/split-in-groups-of/split-in-groups-of.js"],"sourcesContent":["const _splitInGroupsOf = (size, input) => {\n if (size <= 0) {\n throw new Error(\n `splitInGroupsOf - invalid 'size' parameter value '${size}'. 'size' value should be a positive, non-zero, integer.`\n )\n }\n\n if (!Array.isArray(input)) {\n throw new TypeError(\n `splitInGroupsOf - invalid 'source' parameter type '${typeof input}'. 'source' type should be Array.`\n )\n }\n\n const result = []\n const groupCount = Math.ceil(input.length / size)\n\n for (let i = 0; i < groupCount; ++i) {\n const startIndex = i * size\n const endIndex = (i + 1) * size\n\n result.push(input.slice(startIndex, endIndex))\n }\n\n return result\n}\n\n/**\n * Split an array into multiple arrays of set size\n *\n * @tag Array\n * @signature (size: number, source: Array): Array\n * @signature (size: number) => (source: Array): Array\n *\n * @param {...any} params\n * @param {number} params.size\n * @param {Array} params.source\n *\n * @returns {Array[]}\n *\n * @example\n * split(2, [1, 2, 3, 4])\n * // [[1, 2], [3, 4]]\n */\nexport const splitInGroupsOf = (...params) => {\n // @signature (size) => (source)\n if (params.length <= 1) {\n return input => _splitInGroupsOf(params[0], input)\n }\n\n // @signature (size, source)\n return _splitInGroupsOf(...params)\n}\n"],"names":["_splitInGroupsOf","size","input","Error","Array","isArray","TypeError","result","groupCount","Math","ceil","length","i","startIndex","endIndex","push","slice","splitInGroupsOf","params"],"mappings":"AAAA;;AAAA,IAAMA,
|
|
1
|
+
{"version":3,"sources":["../../src/split-in-groups-of/split-in-groups-of.js"],"sourcesContent":["const _splitInGroupsOf = (size, input) => {\n if (size <= 0) {\n throw new Error(\n `splitInGroupsOf - invalid 'size' parameter value '${size}'. 'size' value should be a positive, non-zero, integer.`\n )\n }\n\n if (!Array.isArray(input)) {\n throw new TypeError(\n `splitInGroupsOf - invalid 'source' parameter type '${typeof input}'. 'source' type should be Array.`\n )\n }\n\n const result = []\n const groupCount = Math.ceil(input.length / size)\n\n for (let i = 0; i < groupCount; ++i) {\n const startIndex = i * size\n const endIndex = (i + 1) * size\n\n result.push(input.slice(startIndex, endIndex))\n }\n\n return result\n}\n\n/**\n * Split an array into multiple arrays of set size\n *\n * @tag Array\n * @signature (size: number, source: Array): Array\n * @signature (size: number) => (source: Array): Array\n *\n * @param {...any} params\n * @param {number} params.size\n * @param {Array} params.source\n *\n * @returns {Array[]}\n *\n * @example\n * split(2, [1, 2, 3, 4])\n * // [[1, 2], [3, 4]]\n */\nexport const splitInGroupsOf = (...params) => {\n // @signature (size) => (source)\n if (params.length <= 1) {\n return input => _splitInGroupsOf(params[0], input)\n }\n\n // @signature (size, source)\n return _splitInGroupsOf(...params)\n}\n"],"names":["_splitInGroupsOf","size","input","Error","Array","isArray","TypeError","result","groupCount","Math","ceil","length","i","startIndex","endIndex","push","slice","splitInGroupsOf","params"],"mappings":"AAAA;;AAAA,IAAMA,mBAAmB,SAACC,MAAMC,OAAU;IACxC,IAAID,QAAQ,GAAG;QACb,MAAM,IAAIE,MACR,AAAC,qDAAyD,OAALF,MAAK,6DAC3D;IACH,CAAC;IAED,IAAI,CAACG,MAAMC,OAAO,CAACH,QAAQ;QACzB,MAAM,IAAII,UACR,AAAC,sDAAkE,OAAb,OAAOJ,sCAAP,SAAOA,MAAK,EAAC,sCACpE;IACH,CAAC;IAED,IAAMK,SAAS,EAAE;IACjB,IAAMC,aAAaC,KAAKC,IAAI,CAACR,MAAMS,MAAM,GAAGV;IAE5C,IAAK,IAAIW,IAAI,GAAGA,IAAIJ,YAAY,EAAEI,EAAG;QACnC,IAAMC,aAAaD,IAAIX;QACvB,IAAMa,WAAW,AAACF,CAAAA,IAAI,CAAA,IAAKX;QAE3BM,OAAOQ,IAAI,CAACb,MAAMc,KAAK,CAACH,YAAYC;IACtC;IAEA,OAAOP;AACT;AAEA;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,IAAMU,kBAAkB,WAAe;qCAAXC;QAAAA;;IACjC,gCAAgC;IAChC,IAAIA,OAAOP,MAAM,IAAI,GAAG;QACtB,OAAOT,SAAAA;mBAASF,iBAAiBkB,MAAM,CAAC,EAAE,EAAEhB;;IAC9C,CAAC;IAED,4BAA4B;IAC5B,OAAOF,iBAAAA,MAAAA,KAAAA,GAAiB,qBAAGkB;AAC7B,EAAC"}
|