+17
-21
@@ -1,27 +0,23 @@ | ||
| var shallowProperty = key => obj => obj == null ? void 0 : obj[key]; | ||
| const shallowProperty = key => obj => obj == null ? undefined : obj[key]; | ||
| var getLength = shallowProperty('length'); | ||
| const getLength = shallowProperty('length'); | ||
| var isArrayLike = (collection) => { | ||
| const isArrayLike = collection => { | ||
| const length = getLength(collection); | ||
| return typeof length == 'number' && length >= 0 && length <= Number.MAX_SAFE_INTEGER; | ||
| return typeof length === 'number' && length >= 0 && length <= Number.MAX_SAFE_INTEGER; | ||
| }; | ||
| var isArguments = obj => toString.call(obj) === '[object Arguments]'; | ||
| const isArguments = obj => Object.prototype.toString.call(obj) === '[object Arguments]'; | ||
| var isObject = obj => { | ||
| const isObject = obj => { | ||
| const type = typeof obj; | ||
| return type === 'function' || type === 'object' && !!obj; | ||
| return type === 'function' || (type === 'object' && !!obj); | ||
| }; | ||
| var getKeys = (obj) => { | ||
| if (!isObject(obj)) return []; | ||
| const getKeys = obj => isObject(obj) ? Object.keys(obj) : []; | ||
| return Object.keys(obj); | ||
| }; | ||
| var optimizeCb = (func, context, argCount) => { | ||
| if (context === void 0) return func; | ||
| const optimizeCb = (func, context, argCount) => { | ||
| if (context === undefined) return func; | ||
| switch (argCount == null ? 3 : argCount) { | ||
@@ -31,9 +27,9 @@ case 1: return value => func.call(context, value); | ||
| case 3: return (value, index, collection) => func.call(context, value, index, collection); | ||
| case 4: return (accumulator, value, index, collection) => func.call(context, accumulator, value, index, collection); | ||
| case 4: return (accumulator, value, index, collection) => | ||
| func.call(context, accumulator, value, index, collection); | ||
| default: return (...args) => func.apply(context, args); | ||
| } | ||
| return (...args) => func.apply(context, args); | ||
| }; | ||
| var forEach = (obj, iteratee, context) => { | ||
| const forEach = (obj, iteratee, context) => { | ||
| iteratee = optimizeCb(iteratee, context); | ||
@@ -58,2 +54,4 @@ if (isArrayLike(obj)) { | ||
| const flatten = (input, shallow, strict, output = []) => { | ||
| if (input == null) return []; | ||
| let idx = output.length; | ||
@@ -80,4 +78,2 @@ | ||
| var flatten_1 = (array, shallow) => flatten(array, shallow, false); | ||
| module.exports = flatten_1; | ||
| module.exports = (array, shallow) => flatten(array, shallow, false); |
+14
-12
| { | ||
| "name": "flat-util", | ||
| "version": "1.1.9", | ||
| "version": "1.1.10", | ||
| "description": "Flatten a nested array.", | ||
| "type": "module", | ||
| "main": "index.js", | ||
@@ -11,3 +12,3 @@ "scripts": { | ||
| "lint:fix": "eslint . --fix --max-warnings 0", | ||
| "test": "npm run build && karma start --single-run --browsers ChromeHeadless karma.conf.js" | ||
| "test": "npm run build && node test-runner.mjs" | ||
| }, | ||
@@ -38,14 +39,15 @@ "files": [ | ||
| "devDependencies": { | ||
| "@rollup/plugin-commonjs": "^21.0.2", | ||
| "@rollup/plugin-node-resolve": "^13.1.3", | ||
| "@eslint/js": "^9.19.0", | ||
| "@rollup/plugin-commonjs": "^28.0.2", | ||
| "@rollup/plugin-node-resolve": "^16.0.0", | ||
| "babel-eslint": "^10.1.0", | ||
| "chai": "^4.3.6", | ||
| "eslint": "^8.11.0", | ||
| "karma": "^6.3.17", | ||
| "karma-chai": "^0.1.0", | ||
| "karma-chrome-launcher": "^3.1.1", | ||
| "karma-mocha": "^2.0.1", | ||
| "mocha": "^9.2.2", | ||
| "rollup": "^2.70.1" | ||
| "chai": "^5.1.2", | ||
| "chalk": "^5.4.1", | ||
| "eslint": "^9.19.0", | ||
| "globals": "^15.14.0", | ||
| "http-server": "^14.1.1", | ||
| "mocha": "^11.1.0", | ||
| "puppeteer": "^24.1.1", | ||
| "rollup": "^4.32.1" | ||
| } | ||
| } |
+1
-1
@@ -24,3 +24,3 @@ # flat-util  | ||
| ``` | ||
| <script src="https://unpkg.com/flat-util@1.1.5/umd/index.js" /> | ||
| <script src="https://unpkg.com/flat-util@1.1.9/umd/index.js" /> | ||
| ``` | ||
@@ -27,0 +27,0 @@ |
+61
-58
@@ -7,85 +7,88 @@ (function (global, factory) { | ||
| var shallowProperty = key => obj => obj == null ? void 0 : obj[key]; | ||
| function getDefaultExportFromCjs (x) { | ||
| return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; | ||
| } | ||
| var getLength = shallowProperty('length'); | ||
| var flatUtil; | ||
| var hasRequiredFlatUtil; | ||
| var isArrayLike = (collection) => { | ||
| const length = getLength(collection); | ||
| function requireFlatUtil () { | ||
| if (hasRequiredFlatUtil) return flatUtil; | ||
| hasRequiredFlatUtil = 1; | ||
| const shallowProperty = key => obj => obj == null ? undefined : obj[key]; | ||
| return typeof length == 'number' && length >= 0 && length <= Number.MAX_SAFE_INTEGER; | ||
| }; | ||
| const getLength = shallowProperty('length'); | ||
| var isArguments = obj => toString.call(obj) === '[object Arguments]'; | ||
| const isArrayLike = collection => { | ||
| const length = getLength(collection); | ||
| var isObject = obj => { | ||
| const type = typeof obj; | ||
| return typeof length === 'number' && length >= 0 && length <= Number.MAX_SAFE_INTEGER; | ||
| }; | ||
| return type === 'function' || type === 'object' && !!obj; | ||
| }; | ||
| const isArguments = obj => Object.prototype.toString.call(obj) === '[object Arguments]'; | ||
| var getKeys = (obj) => { | ||
| if (!isObject(obj)) return []; | ||
| const isObject = obj => { | ||
| const type = typeof obj; | ||
| return Object.keys(obj); | ||
| }; | ||
| return type === 'function' || (type === 'object' && !!obj); | ||
| }; | ||
| var optimizeCb = (func, context, argCount) => { | ||
| if (context === void 0) return func; | ||
| switch (argCount == null ? 3 : argCount) { | ||
| case 1: return value => func.call(context, value); | ||
| // The 2-argument case is omitted because we’re not using it. | ||
| case 3: return (value, index, collection) => func.call(context, value, index, collection); | ||
| case 4: return (accumulator, value, index, collection) => func.call(context, accumulator, value, index, collection); | ||
| } | ||
| const getKeys = obj => isObject(obj) ? Object.keys(obj) : []; | ||
| return (...args) => func.apply(context, args); | ||
| }; | ||
| const optimizeCb = (func, context, argCount) => { | ||
| return func; | ||
| }; | ||
| var forEach = (obj, iteratee, context) => { | ||
| iteratee = optimizeCb(iteratee, context); | ||
| if (isArrayLike(obj)) { | ||
| let i = 0; | ||
| const forEach = (obj, iteratee, context) => { | ||
| iteratee = optimizeCb(iteratee); | ||
| if (isArrayLike(obj)) { | ||
| let i = 0; | ||
| for (const item of obj) { | ||
| iteratee(item, i++, obj); | ||
| } | ||
| } else { | ||
| const keys = getKeys(obj); | ||
| for (const item of obj) { | ||
| iteratee(item, i++, obj); | ||
| } | ||
| } else { | ||
| const keys = getKeys(obj); | ||
| for (const key of keys) { | ||
| iteratee(obj[key], key, obj); | ||
| for (const key of keys) { | ||
| iteratee(obj[key], key, obj); | ||
| } | ||
| } | ||
| } | ||
| return obj; | ||
| }; | ||
| return obj; | ||
| }; | ||
| const flatten = (input, shallow, strict, output = []) => { | ||
| let idx = output.length; | ||
| const flatten = (input, shallow, strict, output = []) => { | ||
| if (input == null) return []; | ||
| forEach(input, value => { | ||
| if (isArrayLike(value) && (Array.isArray(value) || isArguments(value))) { | ||
| if (shallow) { | ||
| let j = 0; | ||
| const len = value.length; | ||
| let idx = output.length; | ||
| while (j < len) output[idx++] = value[j++]; | ||
| forEach(input, value => { | ||
| if (isArrayLike(value) && (Array.isArray(value) || isArguments(value))) { | ||
| if (shallow) { | ||
| let j = 0; | ||
| const len = value.length; | ||
| while (j < len) output[idx++] = value[j++]; | ||
| } else { | ||
| flatten(value, shallow, strict, output); | ||
| idx = output.length; | ||
| } | ||
| } else { | ||
| flatten(value, shallow, strict, output); | ||
| idx = output.length; | ||
| output[idx++] = value; | ||
| } | ||
| } else if (!strict) { | ||
| output[idx++] = value; | ||
| } | ||
| }); | ||
| }); | ||
| return output; | ||
| }; | ||
| return output; | ||
| }; | ||
| var flatten_1 = (array, shallow) => flatten(array, shallow, false); | ||
| flatUtil = (array, shallow) => flatten(array, shallow, false); | ||
| return flatUtil; | ||
| } | ||
| var flatUtil = flatten_1; | ||
| var flatUtilExports = requireFlatUtil(); | ||
| var index = /*@__PURE__*/getDefaultExportFromCjs(flatUtilExports); | ||
| return flatUtil; | ||
| return index; | ||
| })); |
8161
0.2%Yes
NaN12
9.09%