restruct-data
Advanced tools
Comparing version 0.2.10 to 0.3.0
{ | ||
"name": "restruct-data", | ||
"version": "0.2.10", | ||
"version": "0.3.0", | ||
"description": "ERROR: No README data found!", | ||
@@ -5,0 +5,0 @@ "main": "restruct.js", |
@@ -62,5 +62,15 @@ | ||
var spot = result; | ||
var k = fill(key, data); | ||
if (k === undefined || k === null) | ||
continue; | ||
else if (Array.isArray(k)) { | ||
for (var i=0; i < k.length-1; i++) { | ||
var tk = k[i]; | ||
if (result[tk] === undefined) | ||
result[tk] = {}; | ||
result = result[tk]; | ||
} | ||
var k = k[i]; | ||
} | ||
@@ -105,2 +115,6 @@ if (result[k] === undefined) { | ||
delete result[k]; | ||
// If result was relocated by a dynamic key, spot will put it | ||
// back in the original location. | ||
result = spot; | ||
} | ||
@@ -107,0 +121,0 @@ |
33
tests.js
@@ -169,1 +169,34 @@ | ||
console.log(json(data,true)) | ||
var result = [{ | ||
order: "1", | ||
title: "Introduction", | ||
text: "Welcome to the intro!", | ||
}, { | ||
order: "1.1", | ||
title: "sub section", | ||
text: "...text", | ||
}, { | ||
order: "1.1.1", | ||
title: "sub sub section", | ||
text: "......text", | ||
}, { | ||
order: "2", | ||
title: "section", | ||
text: "text", | ||
}, { | ||
order: "2.1", | ||
title: "sub section", | ||
text: "...text", | ||
}]; | ||
var data = restruct(result, { | ||
"children": { | ||
"= this.order.split('.')": { | ||
"title": true, | ||
"text": true | ||
}, | ||
"titles": [ "< title" ] | ||
} | ||
}); | ||
console.log(json(data,true)) |
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
8248
322