node-json-transform
Advanced tools
Comparing version 1.0.16 to 1.0.17
@@ -79,5 +79,5 @@ // DataTransform | ||
var value = this.getValue(data, map.list); | ||
var normalized = {}; | ||
if(value) { | ||
var normalized = []; | ||
if(!_.isEmpty(value)) { | ||
var list = this.getList(); | ||
@@ -84,0 +84,0 @@ normalized = map.item ? _.map(list, _.bind(this.iterator, this, map.item)) : list; |
{ | ||
"name": "node-json-transform", | ||
"version": "1.0.16", | ||
"version": "1.0.17", | ||
"description": "A node module for transforming and performing operations on JSON.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -343,3 +343,4 @@ # node-data-transform | ||
## Changelog | ||
1.0.16 ES5 compatibility | ||
1.0.17 Ensure transform always returns an array | ||
1.0.16 ES5 compatibility | ||
1.0.15 Add support for a context object that is passed through to the operate.run and each functions. | ||
@@ -346,0 +347,0 @@ 1.0.14 Add support for default values via "defaults" definition. Add support for removing attributes via the "remove" definition. |
@@ -350,2 +350,31 @@ var DataTransform = require('../index.js').DataTransform, | ||
it("should exclude data if not specified", function(){ | ||
var data = { | ||
posts: [ | ||
{name: "peter", unwanted: true}, | ||
{name: "paul", unwanted: true}, | ||
{name: "marry", unwanted:true} | ||
] | ||
}; | ||
var map = { | ||
list: 'posts', | ||
item: { | ||
name: 'name' | ||
} | ||
}; | ||
var dataTransform = DataTransform(data, map); | ||
var result = dataTransform.transform(); | ||
expect(result).toEqual([ | ||
{name: "peter"}, | ||
{name: "paul"}, | ||
{name: "marry"} | ||
]); | ||
}); | ||
}); |
@@ -64,2 +64,9 @@ var DataTransform = require('../index.js').DataTransform, | ||
it("should always return an array", function() { | ||
var dataTransform = DataTransform({}, {}); | ||
expect(_.isArray(dataTransform.transform())).toEqual(true); | ||
}); | ||
}); |
24804
671
385
8