Comparing version 1.0.0 to 1.0.1
'use strict'; | ||
let xcase = require('./build/Release/xcase'); | ||
function shouldProcessValue(value) { | ||
return value && typeof value == 'object' && | ||
!(value instanceof Date) && !(value instanceof Function); | ||
} | ||
function processKeys(obj, fun, opts) { | ||
@@ -18,3 +23,3 @@ let obj2; | ||
key = fun(key, opts); | ||
if(value && typeof value == 'object') { | ||
if(shouldProcessValue(value)) { | ||
obj2[key] = processKeys(value, fun, opts); | ||
@@ -35,3 +40,3 @@ } else { | ||
} | ||
if(value && typeof value == 'object') { | ||
if(shouldProcessValue(value)) { | ||
obj[newKey] = processKeys(value, fun, opts); | ||
@@ -38,0 +43,0 @@ } else { |
{ | ||
"name": "xcase", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Blazingly fast recursive convertion to and from camelCase or PascalCase for Objects and Arrays", | ||
@@ -5,0 +5,0 @@ "main": "index", |
28
test.js
@@ -6,20 +6,2 @@ 'use strict'; | ||
function camelizeKeys(obj) { | ||
let obj2 = obj instanceof Array ? [] : {}; | ||
let keys = Object.keys(obj); | ||
for(var key of keys) { | ||
let value = obj[key]; | ||
key = xcase.camelize(key); | ||
if(value && typeof value == 'object') { | ||
obj2[key] = camelizeKeys(value); | ||
} else { | ||
obj2[key] = value; | ||
} | ||
} | ||
return obj2; | ||
} | ||
humps.camelizeKeys = camelizeKeys; | ||
describe('passes humps tests', function() { | ||
@@ -280,1 +262,11 @@ 'use strict'; | ||
}); | ||
describe('passes own tests', function() { | ||
it('leaves Date/Function untouched', function() { | ||
let date = new Date(); | ||
let obj = humps.decamelizeKeys({ | ||
fooBar: date | ||
}); | ||
assert.equal(obj.foo_bar, date); | ||
}); | ||
}); |
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
35307
10
393