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.15 to 1.0.16

45

index.js

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

if(typeof(obj) == "undefined") {
if(typeof obj === 'undefined') {
return;

@@ -24,7 +24,8 @@ }

var value = obj || data,
key = key || map.list,
keys = null;
if(key == "") {
value = "";
var value = obj || data;
var keys = null;
key = key || map.list;
if(key == '') {
value = '';
} else {

@@ -48,3 +49,3 @@ keys = key.split('.');

if(typeof(obj) == "undefined") {
if(typeof obj === "undefined") {
return;

@@ -57,10 +58,10 @@ }

if(key == "") {
if(key == '') {
return;
}
keys = key.split('.');
var keys = key.split('.');
var target = obj;
for(var i = 0; i < keys.length; i++ ) {
if(i == keys.length-1){
if(i === keys.length - 1) {
target[keys[i]] = newValue;

@@ -81,8 +82,8 @@ return;

var value = this.getValue(data, map.list),
normalized = {};
var value = this.getValue(data, map.list);
var normalized = {};
if(value) {
var list = this.getList();
var normalized = map.item ? _.map(list, _.bind(this.iterator, this, map.item)) : list;
normalized = map.item ? _.map(list, _.bind(this.iterator, this, map.item)) : list;
normalized = _.bind(this.operate, this, normalized)(context);

@@ -105,3 +106,3 @@ normalized = this.each(normalized, context);

remove: function(item){
_.each(map.remove, (key)=>{
_.each(map.remove, function (key) {
delete item[key];

@@ -123,3 +124,3 @@ });

}
this.setValue(item,method.on,fn(this.getValue(item,method.on), context))
this.setValue(item,method.on,fn(this.getValue(item,method.on), context));
return item;

@@ -135,3 +136,5 @@ },this));

if( map.each ) {
_.each(data, (value, index, collection) => map.each(value, index, collection, context));
_.each(data, function (value, index, collection) {
return map.each(value, index, collection, context);
});
}

@@ -146,13 +149,13 @@ return data;

//to support simple arrays with recursion
if(typeof(map) == "string") {
if(typeof map === 'string') {
return this.getValue(item, map);
}
_.each(map, _.bind(function(oldkey, newkey) {
if(typeof(oldkey) == "string" && oldkey.length > 0) {
if(typeof oldkey === 'string' && oldkey.length > 0) {
obj[newkey] = this.getValue(item, oldkey, newkey);
} else if( _.isArray(oldkey) ) {
array = _.map(oldkey, _.bind(function(item,map) {return this.iterator(map,item)}, this , item));//need to swap arguments for bind
var array = _.map(oldkey, _.bind(function(item,map) {return this.iterator(map,item)}, this , item));//need to swap arguments for bind
obj[newkey] = array;
} else if(typeof oldkey == 'object'){
var bound = _.bind(this.iterator, this, oldkey,item)
} else if(typeof oldkey === 'object'){
var bound = _.bind(this.iterator, this, oldkey,item);
obj[newkey] = bound();

@@ -159,0 +162,0 @@ }

{
"name": "node-json-transform",
"version": "1.0.15",
"version": "1.0.16",
"description": "A node module for transforming and performing operations on JSON.",

@@ -25,3 +25,3 @@ "main": "index.js",

"dependencies": {
"lodash": "^4.16.4"
"lodash": "^4.17.4"
},

@@ -28,0 +28,0 @@ "devDependencies": {

@@ -343,13 +343,14 @@ # node-data-transform

## Changelog
1.0.15 Add support for a context object that is passed through to the operate.run and each functions.
1.0.14 Add support for default values via "defaults" definition. Add support for removing attributes via the "remove" definition.
1.0.13 Update code examples.
1.0.12 Fixed readme formatting.
1.0.11 Adding support for next object and nested array references.
1.0.10 Make each compatible with other options.
1.0.9 Updated the changelog.
1.0.8 Added each functionality to the map.
1.0.7 Updated Readme for multiple operations.
1.0.6 Accepted pull request form ooskapenaar. You can now use custom functions as operators.
1.0.5 Accepted pull request from jaymedavis. You can now pass an array directly and leave 'list' undefined.
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.
1.0.14 Add support for default values via "defaults" definition. Add support for removing attributes via the "remove" definition.
1.0.13 Update code examples.
1.0.12 Fixed readme formatting.
1.0.11 Adding support for next object and nested array references.
1.0.10 Make each compatible with other options.
1.0.9 Updated the changelog.
1.0.8 Added each functionality to the map.
1.0.7 Updated Readme for multiple operations.
1.0.6 Accepted pull request form ooskapenaar. You can now use custom functions as operators.
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

@@ -356,0 +357,0 @@ 1.0.3 Added the ability to clear and set field by passing an empty string in the map.

var DataTransform = require('../index.js').DataTransform,
_ = require("underscore");
_ = require("lodash");

@@ -4,0 +4,0 @@ var map = {

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