Socket
Socket
Sign inDemoInstall

clang

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clang - npm Package Compare versions

Comparing version 0.2.7 to 0.2.8

30

lib/clang.js

@@ -271,6 +271,4 @@ var _ = require('lodash');

Clang.prototype.transformFields = function(customer, options) {
options = options || {}
options.fieldMap = options.fieldMap || {};
_.merge(options.fieldMap, {
Clang.prototype.transformFields = function(customer, options = {}) {
options.fieldMap = Object.assign({
// default field mappings

@@ -286,21 +284,23 @@ particle: 'prefix',

}
});
}, options.fieldMap || {})
// create a new object with altered keys and values based on the fieldMap configuration
var transformedCustomer = {};
_.forOwn(customer, function(value, key) {
var fieldMapTo = options.fieldMap[key];
let transformedCustomer = {}
Object.keys(customer).forEach((key) => {
let value = customer[key]
let fieldMapTo = options.fieldMap[key]
if (typeof fieldMapTo === 'string') {
// set the value on a new key
transformedCustomer[fieldMapTo] = value;
// set the value on the new key
transformedCustomer[fieldMapTo] = value
}
else if (typeof fieldMapTo === 'object') {
// take the fieldName and values configuration of this fieldMap to transform the key and value
transformedCustomer[fieldMapTo.fieldName] = fieldMapTo.values[value] || value;
transformedCustomer[fieldMapTo.fieldName] = fieldMapTo.values[value] || value
}
else {
// set the value on a the same key
transformedCustomer[key] = value;
// set the value on the same key
transformedCustomer[key] = value
}
});
return transformedCustomer;
})
return transformedCustomer
};

@@ -307,0 +307,0 @@

{
"name": "clang",
"version": "0.2.7",
"version": "0.2.8",
"description": "Node.js api wrapper for Clang's SOAP api",

@@ -5,0 +5,0 @@ "author": "Christiaan Westerbeek <chris@devotis.nl>",

@@ -97,6 +97,6 @@ var should = require('should');

var data = {
a: 1,
email: 'a@b.nl',
gender: 'M',
name: 'me'
a: 1,
email: 'a@b.nl',
gender: 'M',
name: 'me'
}

@@ -117,6 +117,17 @@ var options = {

actual.should.be.deepEqual(expected)
setImmediate(done)
});
it('Transformation creates an new object', function(done) {
var data = {
a: 'a@b.nl'
}
var actual = clang.transformFields(data)
actual.should.be.deepEqual(data)
actual.should.not.be.equal(data)
setImmediate(done)
});
});
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