restruct-data
Advanced tools
Comparing version 0.2.0 to 0.2.1
{ | ||
"name": "restruct-data", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "ERROR: No README data found!", | ||
@@ -5,0 +5,0 @@ "main": "restruct.js", |
@@ -16,7 +16,8 @@ | ||
} | ||
restruct.flattenTrigger = '.array'; | ||
restruct.prototype.flatten = function (result, parent, key) { | ||
// Go through entire result and flatten dicts that contain the | ||
// '.array' command. If not true just remove command. | ||
var flatten = result['.array']; | ||
delete result['.array']; | ||
// Go through entire result and flatten dicts that contain | ||
// this.flattenTrigger command. If not true just remove command. | ||
var flatten = result[restruct.flattenTrigger]; | ||
delete result[restruct.flattenTrigger]; | ||
if (flatten === true) | ||
@@ -38,3 +39,3 @@ parent[key] = result = Object.keys(result).map(function (k) { | ||
for (var key in struct) { | ||
if (key === '.array') { | ||
if (key === restruct.flattenTrigger) { | ||
result[key] = struct[key]; | ||
@@ -41,0 +42,0 @@ continue; |
13
tests.js
@@ -85,4 +85,17 @@ | ||
} | ||
var data = restruct(result, struct); | ||
console.log(json(data,true)) | ||
restruct.flattenTrigger = '__array__'; | ||
var struct = { | ||
"genders": { | ||
"__array__": true, | ||
"< gender": { | ||
"__array__": true, | ||
0: "= this.age > 25", | ||
1: "{first}" | ||
} | ||
} | ||
} | ||
var data = restruct(result, struct); | ||
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
5351
185
0