@ultraq/array-utils
Advanced tools
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports.flatten = flatten; | ||
| exports.range = range; | ||
| exports.remove = remove; | ||
| /* | ||
| * Copyright 2017, Emanuel Rabina (http://www.ultraq.net.nz/) | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| /** | ||
| * Flattens an array of arrays of infinite depth into a single-dimension array. | ||
| * | ||
| * > This method is deprecated as it is now natively in JavaScript as the `flat` | ||
| * > method on an Array instance: | ||
| * > https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat | ||
| * | ||
| * @deprecated Can be replaced with `array.flat(Infinity)` | ||
| * @param {Array<any>} array | ||
| * @return {Array<any>} Flattened array. | ||
| */ | ||
| function flatten(array) { | ||
| return array.reduce((acc, value) => { | ||
| return acc.concat(Array.isArray(value) ? flatten(value) : value); | ||
| }, []); | ||
| } | ||
| /** | ||
| * Creates an array of numbers from the starting value (inclusive) to the end | ||
| * (exclusive), with an optional step (the gap between values). | ||
| * | ||
| * @param {Number} start | ||
| * The value to start at, the first item in the returned array. | ||
| * @param {Number} end | ||
| * The value to end with, the last item in the returned array. | ||
| * @param {Number} [step=1] | ||
| * The increment/gap between values, defaults to 1. | ||
| * @return {number[]} An array encompassing the given range. | ||
| */ | ||
| function range(start, end, step = 1) { | ||
| return Array.apply(0, Array(Math.ceil((end - start) / step))).map((empty, index) => index * step + start); | ||
| } | ||
| /** | ||
| * A function to execute on each item in an array, returning truthy | ||
| * if the item passes whatever test is required for the use of this | ||
| * predicate. | ||
| * | ||
| * @template T | ||
| * @callback Predicate<T> | ||
| * @param {T} item | ||
| * @return {boolean} | ||
| */ | ||
| /** | ||
| * Remove and return the first item from `array` that matches the predicate | ||
| * function. | ||
| * | ||
| * @template T | ||
| * @param {T[]} array | ||
| * @param {Predicate<T>} predicate | ||
| * Function to test each item of the array with. If it returns a truthy value | ||
| * for the item, then that item is removed and returned. | ||
| * @return {T | undefined} The matching item, or `undefined` if no match was found. | ||
| */ | ||
| function remove(array, predicate) { | ||
| return array.find((item, index) => { | ||
| if (predicate(item)) { | ||
| array.splice(index, 1); | ||
| return item; | ||
| } | ||
| return false; | ||
| }); | ||
| } |
+22
| Changelog | ||
| ========= | ||
| ### 3.1.0 | ||
| - Migrating to pure ESM for the next major version, the following internal | ||
| changes have been made: | ||
| - Added `"type": "module"` so ESM is now the default | ||
| - Package outputs defined using an `exports` map w/ `import` pointing to the | ||
| main source and `require` to a transpiled version of the source | ||
| - Deprecate `flatten` method - it can be replaced by `array.flat(Infinity)`, | ||
| which has [baseline](https://github.com/web-platform-dx/web-features/blob/main/docs/baseline.md) | ||
| status. | ||
| ### 3.0.1 | ||
| - Generated ES/CJS files didn't have the updated browser support targets, so | ||
| this release fixes that up | ||
| ### 3.0.0 | ||
| - Dropped support for all Node versions older than 18 | ||
| - Dropped support for IE11 | ||
| - JSDocs improved and a type definition file is now generated from it |
+4
-3
| /** | ||
| * Flattens an array of arrays of infinite depth into a single-dimension array. | ||
| * | ||
| * > This is now natively in JavaScript as the `flat` method on an Array | ||
| * > instance. [Check MDN for which browsers have access to this feature](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat). | ||
| * > If you can't use `flat`, then this method will do the job 🙂 | ||
| * > This method is deprecated as it is now natively in JavaScript as the `flat` | ||
| * > method on an Array instance: | ||
| * > https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat | ||
| * | ||
| * @deprecated Can be replaced with `array.flat(Infinity)` | ||
| * @param {Array<any>} array | ||
@@ -9,0 +10,0 @@ * @return {Array<any>} Flattened array. |
+8
-7
@@ -1,10 +0,10 @@ | ||
| /* | ||
| /* | ||
| * Copyright 2017, Emanuel Rabina (http://www.ultraq.net.nz/) | ||
| * | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
@@ -20,6 +20,7 @@ * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * | ||
| * > This is now natively in JavaScript as the `flat` method on an Array | ||
| * > instance. [Check MDN for which browsers have access to this feature](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat). | ||
| * > If you can't use `flat`, then this method will do the job 🙂 | ||
| * > This method is deprecated as it is now natively in JavaScript as the `flat` | ||
| * > method on an Array instance: | ||
| * > https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat | ||
| * | ||
| * @deprecated Can be replaced with `array.flat(Infinity)` | ||
| * @param {Array<any>} array | ||
@@ -26,0 +27,0 @@ * @return {Array<any>} Flattened array. |
+21
-8
| { | ||
| "name": "@ultraq/array-utils", | ||
| "version": "3.0.1", | ||
| "version": "3.1.0", | ||
| "description": "A collection of utilities for JavaScript arrays", | ||
@@ -18,5 +18,17 @@ "author": "Emanuel Rabina <emanuelrabina@gmail.com> (http://www.ultraq.net.nz/)", | ||
| ], | ||
| "module": "array-utils.es.js", | ||
| "main": "array-utils.cjs.js", | ||
| "type": "module", | ||
| "module": "array-utils.js", | ||
| "main": "array-utils.cjs", | ||
| "types": "array-utils.d.ts", | ||
| "exports": { | ||
| "import": "./array-utils.js", | ||
| "require": "./array-utils.cjs", | ||
| "types": "./array-utils.d.ts" | ||
| }, | ||
| "files": [ | ||
| "array-utils.js", | ||
| "array-utils.cjs", | ||
| "array-utils.d.ts", | ||
| "CHANGELOG.md" | ||
| ], | ||
| "sideEffects": false, | ||
@@ -26,5 +38,4 @@ "scripts": { | ||
| "test": "jest", | ||
| "build": "npm run build:cjs && npm run build:es && npm run build:dts", | ||
| "build:cjs": "BABEL_ENV=cjs babel array-utils.js --out-file array-utils.cjs.js --source-maps", | ||
| "build:es": "BABEL_ENV=es babel array-utils.js --out-file array-utils.es.js --source-maps", | ||
| "build": "npm run build:cjs && npm run build:dts", | ||
| "build:cjs": "babel array-utils.js --out-file array-utils.cjs", | ||
| "build:dts": "tsc --allowJs --declaration --emitDeclarationOnly array-utils.js", | ||
@@ -35,6 +46,8 @@ "prepublishOnly": "npm run build" | ||
| "@babel/cli": "^7.22.15", | ||
| "@babel/preset-env": "^7.22.15", | ||
| "@babel/plugin-transform-modules-commonjs": "^7.23.3", | ||
| "@types/jest": "^29.5.4", | ||
| "eslint": "^8.48.0", | ||
| "eslint-config-ultraq": "^2.4.0", | ||
| "eslint-config-ultraq": "^3.1.3", | ||
| "eslint-plugin-import": "^2.29.1", | ||
| "eslint-plugin-jsdoc": "^46.9.1", | ||
| "jest": "^29.6.4", | ||
@@ -41,0 +54,0 @@ "typescript": "^5.2.2" |
+3
-3
@@ -31,5 +31,5 @@ | ||
| > This is now natively in JavaScript as the `flat` method on an Array instance. | ||
| > [Check MDN for which browsers have access to this feature](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat). | ||
| > If you can't use `flat`, then this method will do the job 🙂 | ||
| > This method is deprecated as it is now natively in JavaScript as the `flat` | ||
| > method on an Array instance: | ||
| > https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat | ||
@@ -36,0 +36,0 @@ - **array**: The array of arrays to flatten |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports.flatten = flatten; | ||
| exports.range = range; | ||
| exports.remove = remove; | ||
| /* | ||
| * Copyright 2017, Emanuel Rabina (http://www.ultraq.net.nz/) | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| /** | ||
| * Flattens an array of arrays of infinite depth into a single-dimension array. | ||
| * | ||
| * > This is now natively in JavaScript as the `flat` method on an Array | ||
| * > instance. [Check MDN for which browsers have access to this feature](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat). | ||
| * > If you can't use `flat`, then this method will do the job 🙂 | ||
| * | ||
| * @param {Array<any>} array | ||
| * @return {Array<any>} Flattened array. | ||
| */ | ||
| function flatten(array) { | ||
| return array.reduce((acc, value) => { | ||
| return acc.concat(Array.isArray(value) ? flatten(value) : value); | ||
| }, []); | ||
| } | ||
| /** | ||
| * Creates an array of numbers from the starting value (inclusive) to the end | ||
| * (exclusive), with an optional step (the gap between values). | ||
| * | ||
| * @param {Number} start | ||
| * The value to start at, the first item in the returned array. | ||
| * @param {Number} end | ||
| * The value to end with, the last item in the returned array. | ||
| * @param {Number} [step=1] | ||
| * The increment/gap between values, defaults to 1. | ||
| * @return {number[]} An array encompassing the given range. | ||
| */ | ||
| function range(start, end) { | ||
| let step = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; | ||
| return Array.apply(0, Array(Math.ceil((end - start) / step))).map((empty, index) => index * step + start); | ||
| } | ||
| /** | ||
| * A function to execute on each item in an array, returning truthy | ||
| * if the item passes whatever test is required for the use of this | ||
| * predicate. | ||
| * | ||
| * @template T | ||
| * @callback Predicate<T> | ||
| * @param {T} item | ||
| * @return {boolean} | ||
| */ | ||
| /** | ||
| * Remove and return the first item from `array` that matches the predicate | ||
| * function. | ||
| * | ||
| * @template T | ||
| * @param {T[]} array | ||
| * @param {Predicate<T>} predicate | ||
| * Function to test each item of the array with. If it returns a truthy value | ||
| * for the item, then that item is removed and returned. | ||
| * @return {T | undefined} The matching item, or `undefined` if no match was found. | ||
| */ | ||
| function remove(array, predicate) { | ||
| return array.find((item, index) => { | ||
| if (predicate(item)) { | ||
| array.splice(index, 1); | ||
| return item; | ||
| } | ||
| return false; | ||
| }); | ||
| } | ||
| //# sourceMappingURL=array-utils.cjs.js.map |
| {"version":3,"file":"array-utils.cjs.js","names":["flatten","array","reduce","acc","value","concat","Array","isArray","range","start","end","step","arguments","length","undefined","apply","Math","ceil","map","empty","index","remove","predicate","find","item","splice"],"sources":["array-utils.js"],"sourcesContent":["/* \n * Copyright 2017, Emanuel Rabina (http://www.ultraq.net.nz/)\n * \n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * \n * http://www.apache.org/licenses/LICENSE-2.0\n * \n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Flattens an array of arrays of infinite depth into a single-dimension array.\n *\n * > This is now natively in JavaScript as the `flat` method on an Array\n * > instance. [Check MDN for which browsers have access to this feature](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat).\n * > If you can't use `flat`, then this method will do the job 🙂\n *\n * @param {Array<any>} array\n * @return {Array<any>} Flattened array.\n */\nexport function flatten(array) {\n\treturn array.reduce((acc, value) => {\n\t\treturn acc.concat(Array.isArray(value) ? flatten(value) : value);\n\t}, []);\n}\n\n/**\n * Creates an array of numbers from the starting value (inclusive) to the end\n * (exclusive), with an optional step (the gap between values).\n *\n * @param {Number} start\n * The value to start at, the first item in the returned array.\n * @param {Number} end\n * The value to end with, the last item in the returned array.\n * @param {Number} [step=1]\n * The increment/gap between values, defaults to 1.\n * @return {number[]} An array encompassing the given range.\n */\nexport function range(start, end, step = 1) {\n\treturn Array.apply(0, Array(Math.ceil((end - start) / step))).map((empty, index) => index * step + start);\n}\n\n/**\n * A function to execute on each item in an array, returning truthy\n * if the item passes whatever test is required for the use of this\n * predicate.\n *\n * @template T\n * @callback Predicate<T>\n * @param {T} item\n * @return {boolean}\n */\n\n/**\n * Remove and return the first item from `array` that matches the predicate\n * function.\n *\n * @template T\n * @param {T[]} array\n * @param {Predicate<T>} predicate\n * Function to test each item of the array with. If it returns a truthy value\n * for the item, then that item is removed and returned.\n * @return {T | undefined} The matching item, or `undefined` if no match was found.\n */\nexport function remove(array, predicate) {\n\treturn array.find((item, index) => {\n\t\tif (predicate(item)) {\n\t\t\tarray.splice(index, 1);\n\t\t\treturn item;\n\t\t}\n\t\treturn false;\n\t});\n}\n"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,OAAOA,CAACC,KAAK,EAAE;EAC9B,OAAOA,KAAK,CAACC,MAAM,CAAC,CAACC,GAAG,EAAEC,KAAK,KAAK;IACnC,OAAOD,GAAG,CAACE,MAAM,CAACC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,GAAGJ,OAAO,CAACI,KAAK,CAAC,GAAGA,KAAK,CAAC;EACjE,CAAC,EAAE,EAAE,CAAC;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,KAAKA,CAACC,KAAK,EAAEC,GAAG,EAAY;EAAA,IAAVC,IAAI,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;EACzC,OAAON,KAAK,CAACS,KAAK,CAAC,CAAC,EAAET,KAAK,CAACU,IAAI,CAACC,IAAI,CAAC,CAACP,GAAG,GAAGD,KAAK,IAAIE,IAAI,CAAC,CAAC,CAAC,CAACO,GAAG,CAAC,CAACC,KAAK,EAAEC,KAAK,KAAKA,KAAK,GAAGT,IAAI,GAAGF,KAAK,CAAC;AAC1G;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASY,MAAMA,CAACpB,KAAK,EAAEqB,SAAS,EAAE;EACxC,OAAOrB,KAAK,CAACsB,IAAI,CAAC,CAACC,IAAI,EAAEJ,KAAK,KAAK;IAClC,IAAIE,SAAS,CAACE,IAAI,CAAC,EAAE;MACpBvB,KAAK,CAACwB,MAAM,CAACL,KAAK,EAAE,CAAC,CAAC;MACtB,OAAOI,IAAI;IACZ;IACA,OAAO,KAAK;EACb,CAAC,CAAC;AACH"} |
| /* | ||
| * Copyright 2017, Emanuel Rabina (http://www.ultraq.net.nz/) | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| /** | ||
| * Flattens an array of arrays of infinite depth into a single-dimension array. | ||
| * | ||
| * > This is now natively in JavaScript as the `flat` method on an Array | ||
| * > instance. [Check MDN for which browsers have access to this feature](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat). | ||
| * > If you can't use `flat`, then this method will do the job 🙂 | ||
| * | ||
| * @param {Array<any>} array | ||
| * @return {Array<any>} Flattened array. | ||
| */ | ||
| export function flatten(array) { | ||
| return array.reduce((acc, value) => { | ||
| return acc.concat(Array.isArray(value) ? flatten(value) : value); | ||
| }, []); | ||
| } | ||
| /** | ||
| * Creates an array of numbers from the starting value (inclusive) to the end | ||
| * (exclusive), with an optional step (the gap between values). | ||
| * | ||
| * @param {Number} start | ||
| * The value to start at, the first item in the returned array. | ||
| * @param {Number} end | ||
| * The value to end with, the last item in the returned array. | ||
| * @param {Number} [step=1] | ||
| * The increment/gap between values, defaults to 1. | ||
| * @return {number[]} An array encompassing the given range. | ||
| */ | ||
| export function range(start, end) { | ||
| let step = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; | ||
| return Array.apply(0, Array(Math.ceil((end - start) / step))).map((empty, index) => index * step + start); | ||
| } | ||
| /** | ||
| * A function to execute on each item in an array, returning truthy | ||
| * if the item passes whatever test is required for the use of this | ||
| * predicate. | ||
| * | ||
| * @template T | ||
| * @callback Predicate<T> | ||
| * @param {T} item | ||
| * @return {boolean} | ||
| */ | ||
| /** | ||
| * Remove and return the first item from `array` that matches the predicate | ||
| * function. | ||
| * | ||
| * @template T | ||
| * @param {T[]} array | ||
| * @param {Predicate<T>} predicate | ||
| * Function to test each item of the array with. If it returns a truthy value | ||
| * for the item, then that item is removed and returned. | ||
| * @return {T | undefined} The matching item, or `undefined` if no match was found. | ||
| */ | ||
| export function remove(array, predicate) { | ||
| return array.find((item, index) => { | ||
| if (predicate(item)) { | ||
| array.splice(index, 1); | ||
| return item; | ||
| } | ||
| return false; | ||
| }); | ||
| } | ||
| //# sourceMappingURL=array-utils.es.js.map |
| {"version":3,"file":"array-utils.es.js","names":["flatten","array","reduce","acc","value","concat","Array","isArray","range","start","end","step","arguments","length","undefined","apply","Math","ceil","map","empty","index","remove","predicate","find","item","splice"],"sources":["array-utils.js"],"sourcesContent":["/* \n * Copyright 2017, Emanuel Rabina (http://www.ultraq.net.nz/)\n * \n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * \n * http://www.apache.org/licenses/LICENSE-2.0\n * \n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Flattens an array of arrays of infinite depth into a single-dimension array.\n *\n * > This is now natively in JavaScript as the `flat` method on an Array\n * > instance. [Check MDN for which browsers have access to this feature](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat).\n * > If you can't use `flat`, then this method will do the job 🙂\n *\n * @param {Array<any>} array\n * @return {Array<any>} Flattened array.\n */\nexport function flatten(array) {\n\treturn array.reduce((acc, value) => {\n\t\treturn acc.concat(Array.isArray(value) ? flatten(value) : value);\n\t}, []);\n}\n\n/**\n * Creates an array of numbers from the starting value (inclusive) to the end\n * (exclusive), with an optional step (the gap between values).\n *\n * @param {Number} start\n * The value to start at, the first item in the returned array.\n * @param {Number} end\n * The value to end with, the last item in the returned array.\n * @param {Number} [step=1]\n * The increment/gap between values, defaults to 1.\n * @return {number[]} An array encompassing the given range.\n */\nexport function range(start, end, step = 1) {\n\treturn Array.apply(0, Array(Math.ceil((end - start) / step))).map((empty, index) => index * step + start);\n}\n\n/**\n * A function to execute on each item in an array, returning truthy\n * if the item passes whatever test is required for the use of this\n * predicate.\n *\n * @template T\n * @callback Predicate<T>\n * @param {T} item\n * @return {boolean}\n */\n\n/**\n * Remove and return the first item from `array` that matches the predicate\n * function.\n *\n * @template T\n * @param {T[]} array\n * @param {Predicate<T>} predicate\n * Function to test each item of the array with. If it returns a truthy value\n * for the item, then that item is removed and returned.\n * @return {T | undefined} The matching item, or `undefined` if no match was found.\n */\nexport function remove(array, predicate) {\n\treturn array.find((item, index) => {\n\t\tif (predicate(item)) {\n\t\t\tarray.splice(index, 1);\n\t\t\treturn item;\n\t\t}\n\t\treturn false;\n\t});\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,OAAOA,CAACC,KAAK,EAAE;EAC9B,OAAOA,KAAK,CAACC,MAAM,CAAC,CAACC,GAAG,EAAEC,KAAK,KAAK;IACnC,OAAOD,GAAG,CAACE,MAAM,CAACC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,GAAGJ,OAAO,CAACI,KAAK,CAAC,GAAGA,KAAK,CAAC;EACjE,CAAC,EAAE,EAAE,CAAC;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,KAAKA,CAACC,KAAK,EAAEC,GAAG,EAAY;EAAA,IAAVC,IAAI,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;EACzC,OAAON,KAAK,CAACS,KAAK,CAAC,CAAC,EAAET,KAAK,CAACU,IAAI,CAACC,IAAI,CAAC,CAACP,GAAG,GAAGD,KAAK,IAAIE,IAAI,CAAC,CAAC,CAAC,CAACO,GAAG,CAAC,CAACC,KAAK,EAAEC,KAAK,KAAKA,KAAK,GAAGT,IAAI,GAAGF,KAAK,CAAC;AAC1G;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASY,MAAMA,CAACpB,KAAK,EAAEqB,SAAS,EAAE;EACxC,OAAOrB,KAAK,CAACsB,IAAI,CAAC,CAACC,IAAI,EAAEJ,KAAK,KAAK;IAClC,IAAIE,SAAS,CAACE,IAAI,CAAC,EAAE;MACpBvB,KAAK,CAACwB,MAAM,CAACL,KAAK,EAAE,CAAC,CAAC;MACtB,OAAOI,IAAI;IACZ;IACA,OAAO,KAAK;EACb,CAAC,CAAC;AACH"} |
| /* | ||
| * Copyright 2017, Emanuel Rabina (http://www.ultraq.net.nz/) | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| /* eslint-env jest */ | ||
| import {flatten, range, remove} from './array-utils'; | ||
| /** | ||
| * Tests for the array utilities. | ||
| */ | ||
| describe('array-utils', function() { | ||
| describe('#flatten', function() { | ||
| test('Flattens a nested array', function() { | ||
| let result = flatten([1, [2, [[3], 4], 5]]); | ||
| expect(result).toEqual([1, 2, 3, 4, 5]); | ||
| }); | ||
| }); | ||
| describe('#range', function() { | ||
| test('Returns a range of values from start to finish', function() { | ||
| let result = range(2, 5); | ||
| expect(result).toEqual([2, 3, 4]); | ||
| }); | ||
| test('Returns a range of values incrementing by the specified value', function() { | ||
| let result = range(2, 10, 3); | ||
| expect(result).toEqual([2, 5, 8]); | ||
| }); | ||
| }); | ||
| describe('#remove', function() { | ||
| test('Removes matching item', function() { | ||
| let array = [1, 2, 3]; | ||
| let result = remove(array, item => item === 2); | ||
| expect(array).toEqual([1, 3]); | ||
| expect(result).toBe(2); | ||
| }); | ||
| }); | ||
| }); |
| /* eslint-env node */ | ||
| 'use strict'; // eslint-disable-line | ||
| module.exports = { | ||
| collectCoverage: true, | ||
| coverageReporters: [ | ||
| 'html', | ||
| 'lcov', | ||
| 'text-summary' | ||
| ] | ||
| }; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Yes
NaN22671
-35.43%9
28.57%7
-36.36%210
-38.24%1
Infinity%