array-tree-filter
Advanced tools
Comparing version 3.0.0 to 3.0.1
50
index.js
@@ -1,16 +0,34 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const arrayTreeFilter = (data, filterFn, { childrenKeyName = "children" } = {}) => { | ||
const result = []; | ||
let children = data; | ||
for (let level = 0; children.length > 0; level++) { | ||
const foundItem = children.find(item => filterFn(item, level)); | ||
if (!foundItem) { | ||
break; | ||
} | ||
result.push(foundItem); | ||
children = foundItem[childrenKeyName] || []; | ||
} | ||
return result; | ||
}; | ||
exports.default = arrayTreeFilter; | ||
(function (factory) { | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
factory(); | ||
})((function () { 'use strict'; | ||
(function (factory) { | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
factory(); | ||
})((function () { | ||
(function (factory) { | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
factory(); | ||
})((function () { | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const arrayTreeFilter = (data, filterFn, { childrenKeyName = "children" } = {}) => { | ||
const result = []; | ||
let children = data; | ||
for (let level = 0; children.length > 0; level++) { | ||
const foundItem = children.find(item => filterFn(item, level)); | ||
if (!foundItem) { | ||
break; | ||
} | ||
result.push(foundItem); | ||
children = foundItem[childrenKeyName] || []; | ||
} | ||
return result; | ||
}; | ||
exports.default = arrayTreeFilter; | ||
})); | ||
})); | ||
})); |
{ | ||
"name": "array-tree-filter", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "filter in array tree", | ||
@@ -8,5 +8,6 @@ "main": "index.js", | ||
"scripts": { | ||
"test": "vitest --coverage", | ||
"prepublishOnly": "npm run tsc", | ||
"tsc": "tsc" | ||
"test": "npm run tsc && npm run build && vitest --coverage", | ||
"prepublishOnly": "npm run build", | ||
"tsc": "tsc --noEmit", | ||
"build": "rollup index.js --output.format umd --name 'arrayTreeFilter' --output.file index.js" | ||
}, | ||
@@ -33,2 +34,3 @@ "files": [ | ||
"@vitest/coverage-v8": "^2.1.3", | ||
"rollup": "^4.24.0", | ||
"typescript": "^5.6.3", | ||
@@ -35,0 +37,0 @@ "vitest": "^2.1.3" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4326
34
4