node-json-transform
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -71,2 +71,10 @@ // DataTransform | ||
obj[newkey] = this.getValue(item, oldkey); | ||
} else if( _.isArray(oldkey) ) { | ||
var array = []; | ||
_.each(oldkey, _.bind(function(key){ | ||
array.push(this.getValue(item, key)); | ||
},this)); | ||
obj[newkey] = array; | ||
} else { | ||
@@ -73,0 +81,0 @@ obj[newkey] = ""; |
{ | ||
"name": "node-json-transform", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "A node module for transforming and performing operations on JSON.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -50,3 +50,4 @@ # node-data-transform | ||
item: "list1.0.name", | ||
clearMe: "" | ||
clearMe: "", | ||
fieldGroup: ['title', 'extra'] | ||
}, | ||
@@ -79,3 +80,4 @@ operate: [ | ||
info: "mike", | ||
clearMe: "" | ||
clearMe: "", | ||
fieldGroup: ['title1', { link : "http://goo.cm" }] | ||
}] | ||
@@ -88,2 +90,3 @@ ``` | ||
1.0.4 Added the ability to group fields into arrays | ||
1.0.3 Added the ability to clear and set field by passing an empty string in the map. | ||
@@ -90,0 +93,0 @@ |
@@ -111,2 +111,27 @@ var DataTransform = require('../index.js').DataTransform, | ||
it("should allow you to map arrays", function(){ | ||
// Add a map item to clear out the "clearMe" field. | ||
var newMap = { | ||
list : 'posts', | ||
item: { | ||
fieldGroup: ["title", "description", "blog", "extra"] | ||
} | ||
}; | ||
var dataTransform = DataTransform(data, newMap); | ||
expect(dataTransform.transform()).toEqual([{ | ||
fieldGroup : [ | ||
"title1", | ||
"description1", | ||
"This is a blog.", | ||
{ | ||
link : "http://goo.cm" | ||
} | ||
] | ||
}]); | ||
}); | ||
}); |
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
7697
176
116