Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-json-transform

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-json-transform - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

2

index.js

@@ -15,3 +15,3 @@ // DataTransform

if(key == '') {
if(key == '' || key == undefined) {
return obj;

@@ -18,0 +18,0 @@ }

{
"name": "node-json-transform",
"version": "1.0.4",
"description": "A node module for transforming and performing operations on JSON.",
"main": "index.js",
"scripts": {
"test": "node_modules/jasmine-node/bin/jasmine-node test/"
},
"repository": {
"type": "git",
"url": "https://github.com/bozzltron/node-json-transform"
},
"keywords": [
"json",
"transform",
"node"
],
"author": "Michael Bosworth",
"license": "MIT",
"bugs": {
"url": "https://github.com/bozzltron/node-json-transform/issues"
},
"homepage": "https://github.com/bozzltron/node-json-transform",
"dependencies": {
"underscore": "^1.7.0"
},
"devDependencies": {
"jasmine-node": "^1.14.5",
"underscore": "^1.8.3"
}
"name": "node-json-transform",
"version": "1.0.5",
"description": "A node module for transforming and performing operations on JSON.",
"main": "index.js",
"scripts": {
"test": "node_modules/jasmine-node/bin/jasmine-node test/"
},
"repository": {
"type": "git",
"url": "https://github.com/bozzltron/node-json-transform"
},
"keywords": [
"json",
"transform",
"node"
],
"author": "Michael Bosworth",
"license": "MIT",
"bugs": {
"url": "https://github.com/bozzltron/node-json-transform/issues"
},
"homepage": "https://github.com/bozzltron/node-json-transform",
"dependencies": {
"underscore": "^1.7.0"
},
"devDependencies": {
"jasmine-node": "^1.14.5",
"underscore": "^1.8.3"
}
}

@@ -33,3 +33,3 @@ # node-data-transform

clearMe: "text"
}
}
]

@@ -59,3 +59,3 @@ };

```
You can read this as follows:
You can read this as follows:
- Get the array of objects in "posts".

@@ -83,3 +83,3 @@ - Map the name to title, info to description etc.

fieldGroup: ['title1', { link : "http://goo.cm" }]
}]
}]
```

@@ -91,2 +91,3 @@

1.0.5 Accepted pull request from jaymedavis. You can now pass an array directly and leave 'list' undefined.
1.0.4 Added the ability to group fields into arrays

@@ -120,2 +121,2 @@ 1.0.3 Added the ability to clear and set field by passing an empty string in the map.

IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@@ -5,28 +5,22 @@ var DataTransform = require('../index.js').DataTransform,

var data = {
posts : [
{
title : "title1",
description: "description1",
blog: "This is a blog.",
date: "11/4/2013",
clearMe : "text to remove",
extra : {
link : "http://goo.cm"
},
list1:[
{
name:"mike"
}
],
list2:[
{
item: "thing"
}
]
}
]
posts: [{
title: "title1",
description: "description1",
blog: "This is a blog.",
date: "11/4/2013",
clearMe: "text to remove",
extra: {
link: "http://goo.cm"
},
list1: [{
name: "mike"
}],
list2: [{
item: "thing"
}]
}]
};
var map = {
list : 'posts',
list: 'posts',
item: {

@@ -40,5 +34,6 @@ name: "title",

},
operate: [
{run: "Date.parse", on: "date"}
]
operate: [{
run: "Date.parse",
on: "date"
}]
};

@@ -48,3 +43,3 @@

it("should extract values", function() {
it("should extract values", function() {

@@ -55,10 +50,10 @@ var dataTransform = DataTransform(data, map);

});
});
it("should transform data", function() {
it("should transform data", function() {
var dataTransform = DataTransform(data, map);
var dataTransform = DataTransform(data, map);
expect(dataTransform.transform()).toEqual([{
name : "title1",
name: "title1",
info: "description1",

@@ -71,15 +66,15 @@ text: "This is a blog.",

});
});
it("should allow you to clear out fields", function() {
it("should allow you to clear out fields", function() {
// Add a map item to clear out the "clearMe" field.
var newMap = _.clone(map);
newMap.item = _.clone(map.item);
newMap.item.clearMe = "";
// Add a map item to clear out the "clearMe" field.
var newMap = _.clone(map);
newMap.item = _.clone(map.item);
newMap.item.clearMe = "";
var dataTransform = DataTransform(data, newMap);
var dataTransform = DataTransform(data, newMap);
expect(dataTransform.transform()).toEqual([{
name : "title1",
name: "title1",
info: "description1",

@@ -93,16 +88,15 @@ text: "This is a blog.",

});
});
it("should allow you to set fields", function() {
it("should allow you to set fields", function() {
// Add a map item to clear out the "clearMe" field.
var newMap = _.clone(map);
newMap.item = _.clone(map.item);
newMap.item.fieldThatDoesntExist = "";
// Add a map item to clear out the "clearMe" field.
var newMap = _.clone(map);
newMap.item = _.clone(map.item);
newMap.item.fieldThatDoesntExist = "";
var dataTransform = DataTransform(data, newMap);
var dataTransform = DataTransform(data, newMap);
expect(dataTransform.transform()).toEqual([{
name : "title1",
info: "description1",
name: "title1",
text: "This is a blog.",

@@ -115,9 +109,9 @@ date: 1383544800000,

});
});
it("should allow you to map arrays", function(){
it("should allow you to map arrays", function() {
// Add a map item to clear out the "clearMe" field.
var newMap = {
list : 'posts',
// Add a map item to clear out the "clearMe" field.
var newMap = {
list: 'posts',
item: {

@@ -128,17 +122,56 @@ fieldGroup: ["title", "description", "blog", "extra"]

var dataTransform = DataTransform(data, newMap);
var dataTransform = DataTransform(data, newMap);
expect(dataTransform.transform()).toEqual([{
fieldGroup : [
"title1",
"description1",
"This is a blog.",
{
link : "http://goo.cm"
fieldGroup: [
"title1",
"description1",
"This is a blog.", {
link: "http://goo.cm"
}
]
}]);
}]);
});
});
it("should allow you to pass arrays without specifying a list", function() {
// Add a map item to clear out the "clearMe" field.
var newMap = {
item: {
fieldGroup: ["title", "description", "blog", "extra"]
}
};
var data = [{
title: "title1",
description: "description1",
blog: "This is a blog.",
date: "11/4/2013",
clearMe: "text to remove",
extra: {
link: "http://goo.cm"
},
list1: [{
name: "mike"
}],
list2: [{
item: "thing"
}]
}];
var dataTransform = DataTransform(data, newMap);
expect(dataTransform.transform()).toEqual([{
fieldGroup: [
"title1",
"description1",
"This is a blog.", {
link: "http://goo.cm"
}
]
}]);
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc