@cdxoo/flat
Advanced tools
Comparing version 0.0.9 to 0.0.10
{ | ||
"name": "@cdxoo/flat", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"description": "does not flatten cats", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -8,2 +8,4 @@ 'use strict'; | ||
maxDepth = 0, | ||
traverseArrays = false, | ||
initializeArrays = false, | ||
} = options; | ||
@@ -15,2 +17,3 @@ | ||
var { isLeaf, path, value, parentNode } = context; | ||
var key = path.join(delimiter); | ||
if (maxDepth) { | ||
@@ -21,8 +24,11 @@ if (path.length <= maxDepth) { | ||
} | ||
out[path.join(delimiter)] = value; | ||
out[key] = value; | ||
} | ||
} | ||
else { | ||
if (traverseArrays && initializeArrays && Array.isArray(value)) { | ||
out[key] = []; | ||
} | ||
if (isLeaf) { | ||
out[path.join(delimiter)] = value; | ||
out[key] = value; | ||
} | ||
@@ -29,0 +35,0 @@ } |
@@ -94,5 +94,7 @@ 'use strict'; | ||
var out = flatten({ foo: ['a', 'b', 'c'] }, { | ||
traverseArrays: true | ||
traverseArrays: true, | ||
initializeArrays: true, | ||
}); | ||
expect(out).to.eql({ | ||
'foo': [], | ||
'foo.0': 'a', | ||
@@ -99,0 +101,0 @@ 'foo.1': 'b', |
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
12121
315