array-tree-filter
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -8,20 +8,19 @@ (function (global, factory) { | ||
function arrayTreeFilter(data, filterFn, options) { | ||
options = options || {}; | ||
options.childrenKeyName = options.childrenKeyName || 'children'; | ||
var children = data || []; | ||
var result = []; | ||
var level = 0; | ||
var foundItem; | ||
do { | ||
var foundItem = children.filter(function(item) { | ||
return filterFn(item, level); | ||
})[0]; | ||
if (!foundItem) { | ||
break; | ||
} | ||
result.push(foundItem); | ||
children = foundItem[options.childrenKeyName] || []; | ||
level += 1; | ||
} while(children.length > 0); | ||
return result; | ||
options = options || {}; | ||
options.childrenKeyName = options.childrenKeyName || "children"; | ||
var children = data || []; | ||
var result = []; | ||
var level = 0; | ||
do { | ||
var foundItem = children.filter(function (item) { | ||
return filterFn(item, level); | ||
})[0]; | ||
if (!foundItem) { | ||
break; | ||
} | ||
result.push(foundItem); | ||
children = foundItem[options.childrenKeyName] || []; | ||
level += 1; | ||
} while (children.length > 0); | ||
return result; | ||
} | ||
@@ -28,0 +27,0 @@ |
{ | ||
"name": "array-tree-filter", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "filter in array tree", | ||
@@ -9,7 +9,6 @@ "main": "lib/index.js", | ||
"pub": "npm run build && npm publish", | ||
"build": "rollup index.js --output.format umd --name 'arrayTreeFilter' --output.file lib/index.js" | ||
"tsc": "tsc", | ||
"build": "npm run tsc && rollup index.js --output.format umd --name 'arrayTreeFilter' --output.file lib/index.js" | ||
}, | ||
"files": [ | ||
"lib" | ||
], | ||
"files": ["lib", "index.d.ts"], | ||
"repository": { | ||
@@ -19,7 +18,3 @@ "type": "git", | ||
}, | ||
"keywords": [ | ||
"array", | ||
"tree", | ||
"filter" | ||
], | ||
"keywords": ["array", "tree", "filter"], | ||
"author": "afc163 <afc163@gmail.com>", | ||
@@ -33,4 +28,5 @@ "license": "MIT", | ||
"rollup": "^0.52.1", | ||
"tape": "^4.3.0" | ||
"tape": "^4.3.0", | ||
"typescript": "^2.7.1" | ||
} | ||
} |
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
2951
4
30
3