Comparing version 1.0.5 to 1.0.6
@@ -5,5 +5,10 @@ 'use strict'; | ||
let xcase = require('./'); | ||
let camelCase = require('lodash').camelCase; | ||
let reduce = require('lodash').reduce; | ||
let objectBare = {"payments":[{"id":358,"created_at":"2016-09-10T08:23:00.601Z","currency":"EUR","auto_charged":false,"bill_to":{"city":"Gda","phone":"FF","address":"FF","country":"PL","last_name":"K","first_name":"D","postal_code":"89273","company_name":"ddk"},"value":500,"refunded":false,"user":{"id":2,"email":"rush@test.com.com"},"subscriptions":[]},{"id":351,"created_at":"2016-09-08T05:45:51.274Z","currency":"EUR","auto_charged":true,"bill_to":{"city":"Gda","phone":"FF","address":"FF","country":"PL","last_name":"K","first_name":"D","postal_code":"89273","company_name":"ddk"},"value":1000,"refunded":false,"user":{"id":2,"email":"rush@test.com.com"},"subscriptions":[]},{"id":344,"created_at":"2016-09-08T05:23:22.792Z","currency":"EUR","auto_charged":false,"bill_to":{"city":"Gda","phone":"FF","address":"FF","country":"PL","last_name":"K","first_name":"D","postal_code":"89273","company_name":"ddk"},"value":1200,"refunded":false,"user":{"id":2,"email":"rush@test.com.com"},"subscriptions":[]},{"id":297,"created_at":"2016-09-07T22:52:16.183Z","currency":"EUR","auto_charged":false,"bill_to":{"city":"Gda","phone":"FF","address":"FF","country":"PL","last_name":"K","first_name":"D","postal_code":"89273","company_name":"ddk"},"value":500,"refunded":false,"user":{"id":2,"email":"rush@test.com.com"},"subscriptions":[]},{"id":296,"created_at":"2016-09-07T22:51:50.627Z","currency":"EUR","auto_charged":false,"bill_to":{"city":"Gda","phone":"FF","address":"FF","country":"PL","last_name":"K","first_name":"D","postal_code":"89273","company_name":"ddk"},"value":500,"refunded":false,"user":{"id":2,"email":"rush@test.com.com"},"subscriptions":[]},{"id":201,"created_at":"2016-09-06T22:30:53.784Z","currency":"EUR","auto_charged":false,"bill_to":{"city":"Gda","phone":"FF","address":"FF","country":"PL","last_name":"K","first_name":"D","postal_code":"89273","company_name":"ddk"},"value":500,"refunded":false,"user":{"id":2,"email":"rush@test.com.com"},"subscriptions":[]},{"id":200,"created_at":"2016-09-06T22:30:28.323Z","currency":"EUR","auto_charged":false,"bill_to":{"city":"Gda","phone":"FF","address":"FF","country":"PL","last_name":"K","first_name":"D","postal_code":"89273","company_name":"ddk"},"value":500,"refunded":false,"user":{"id":2,"email":"rush@test.com.com"},"subscriptions":[]},{"id":196,"created_at":"2016-09-06T22:16:46.789Z","currency":"EUR","auto_charged":false,"bill_to":{"city":"Gda","phone":"FF","address":"FF","country":"PL","last_name":"K","first_name":"D","postal_code":"89273","company_name":"ddk"},"value":500,"refunded":false,"user":{"id":2,"email":"rush@test.com.com"},"subscriptions":[]},{"id":160,"created_at":"2016-09-06T22:05:19.009Z","currency":"EUR","auto_charged":false,"bill_to":{"city":"Gda","phone":"FF","address":"FF","country":"PL","last_name":"K","first_name":"D","postal_code":"89273","company_name":"ddk"},"value":500,"refunded":false,"user":{"id":2,"email":"rush@test.com.com"},"subscriptions":[]},{"id":79,"created_at":"2016-09-02T23:12:32.017Z","currency":"EUR","auto_charged":true,"bill_to":{"city":"Gda","phone":"FF","address":"FF","country":"PL","last_name":"K","first_name":"D","postal_code":"89273","company_name":"ddk"},"value":1000,"refunded":false,"user":{"id":2,"email":"rush@test.com.com"},"subscriptions":[]},{"id":76,"created_at":"2016-09-01T22:28:34.224Z","currency":"EUR","auto_charged":true,"bill_to":{"city":"Gda","phone":"FF","address":"FF","country":"PL","last_name":"K","first_name":"D","postal_code":"89273","company_name":"ddk"},"value":1000,"refunded":false,"user":{"id":2,"email":"rush@test.com.com"},"subscriptions":[]},{"id":40,"created_at":"2016-08-20T04:28:45.484Z","currency":"EUR","auto_charged":true,"bill_to":{"city":"Gdansk","state":null,"address":"Encino","country":"PL","last_name":"K","first_name":"D","postal_code":"89273","company_name":"dk"},"value":16000,"refunded":false,"user":{"id":3,"email":"rush@test.com"},"subscriptions":[]},{"id":39,"created_at":"2016-08-20T04:26:41.275Z","currency":"EUR","auto_charged":true,"bill_to":{"city":"Gdansk","state":null,"address":"Encino","country":"PL","last_name":"K","first_name":"D","postal_code":"89273","company_name":"dk"},"value":8000,"refunded":false,"user":{"id":3,"email":"rush@test.com"},"subscriptions":[]},{"id":37,"created_at":"2016-08-20T00:24:13.960Z","currency":"EUR","auto_charged":true,"bill_to":{"city":"Gdansk","state":null,"address":"Encino","country":"PL","last_name":"K","first_name":"D","postal_code":"89273","company_name":"dk"},"value":16000,"refunded":false,"user":{"id":3,"email":"rush@test.com"},"subscriptions":[]},{"id":36,"created_at":"2016-08-19T18:11:44.340Z","currency":"EUR","auto_charged":true,"bill_to":{"city":"Gdansk","state":null,"address":"Encino","country":"PL","last_name":"K","first_name":"D","postal_code":"89273","company_name":"dk"},"value":4000,"refunded":false,"user":{"id":3,"email":"rush@test.com"},"subscriptions":[]},{"id":35,"created_at":"2016-08-19T18:11:08.783Z","currency":"EUR","auto_charged":true,"bill_to":{"city":"Gdansk","state":null,"address":"Encino","country":"PL","last_name":"K","first_name":"D","postal_code":"89273","company_name":"dk"},"value":2000,"refunded":false,"user":{"id":3,"email":"rush@test.com"},"subscriptions":[]},{"id":34,"created_at":"2016-08-18T14:02:46.874Z","currency":"EUR","auto_charged":true,"bill_to":{"city":"Gdansk","state":null,"address":"Encino","country":"PL","last_name":"K","first_name":"D","postal_code":"89273","company_name":"dk"},"value":1000,"refunded":false,"user":{"id":3,"email":"rush@test.com"},"subscriptions":[]},{"id":33,"created_at":"2016-08-13T00:58:40.838Z","currency":"EUR","auto_charged":true,"bill_to":{"city":"Gdansk","state":null,"address":"Encino","country":"PL","last_name":"K","first_name":"D","postal_code":"89273","company_name":"dk"},"value":4000,"refunded":false,"user":{"id":3,"email":"rush@test.com"},"subscriptions":[]},{"id":32,"created_at":"2016-08-13T00:28:41.613Z","currency":"EUR","auto_charged":true,"bill_to":{"city":"Gdansk","state":null,"address":"Encino","country":"PL","last_name":"K","first_name":"D","postal_code":"89273","company_name":"dk"},"value":2000,"refunded":false,"user":{"id":3,"email":"rush@test.com"},"subscriptions":[]},{"id":28,"created_at":"2016-08-13T00:25:05.052Z","currency":"EUR","auto_charged":false,"bill_to":{"city":"Gdansk","state":null,"address":"Encino","country":"PL","last_name":"K","first_name":"D","postal_code":"89273","company_name":"dk"},"value":500,"refunded":false,"user":{"id":3,"email":"rush@test.com"},"subscriptions":[]},{"id":22,"created_at":"2016-07-22T14:43:34.524Z","currency":"EUR","auto_charged":true,"bill_to":{"city":"Gdansk","state":null,"address":"Encino","country":"PL","last_name":"K","first_name":"D","postal_code":"89273","company_name":"dk"},"value":1000,"refunded":false,"user":{"id":3,"email":"rush@test.com"},"subscriptions":[]},{"id":21,"created_at":"2016-07-22T14:43:20.898Z","currency":"EUR","auto_charged":true,"bill_to":{"city":"Gdansk","state":null,"address":"Encino","country":"PL","last_name":"K","first_name":"D","postal_code":"89273","company_name":"dk"},"value":1000,"refunded":false,"user":{"id":3,"email":"rush@test.com"},"subscriptions":[]},{"id":20,"created_at":"2016-07-21T16:33:42.669Z","currency":"EUR","auto_charged":true,"bill_to":{"city":"Gdansk","state":null,"address":"Encino","country":"PL","last_name":"K","first_name":"D","postal_code":"89273","company_name":"dk"},"value":1000,"refunded":false,"user":{"id":3,"email":"rush@test.com"},"subscriptions":[]},{"id":19,"created_at":"2016-07-20T23:30:55.313Z","currency":"EUR","auto_charged":true,"bill_to":{"city":"Gdansk","state":null,"address":"Encino","country":"PL","last_name":"K","first_name":"D","postal_code":"89273","company_name":"dk"},"value":2000,"refunded":false,"user":{"id":3,"email":"rush@test.com"},"subscriptions":[]},{"id":18,"created_at":"2016-07-19T20:18:20.029Z","currency":"EUR","auto_charged":true,"bill_to":{"city":"Gdansk","state":null,"address":"Encino","country":"PL","last_name":"K","first_name":"D","postal_code":"89273","company_name":"dk"},"value":1000,"refunded":false,"user":{"id":3,"email":"rush@test.com"},"subscriptions":[]},{"id":17,"created_at":"2016-07-19T00:32:09.686Z","currency":"USD","auto_charged":true,"bill_to":{"city":"Gdansk","state":null,"address":"Foobar","country":"PL","last_name":"K","first_name":"D","postal_code":"89273","company_name":"DK"},"value":2000,"refunded":false,"user":{"id":2,"email":"rush@test.com.com"},"subscriptions":[]},{"id":14,"created_at":"2016-07-19T00:24:10.509Z","currency":"USD","auto_charged":true,"bill_to":{"city":"Gdansk","state":null,"address":"Foobar","country":"PL","last_name":"K","first_name":"D","postal_code":"89273","company_name":"DK"},"value":2000,"refunded":false,"user":{"id":2,"email":"rush@test.com.com"},"subscriptions":[]},{"id":11,"created_at":"2016-07-19T00:19:10.501Z","currency":"USD","auto_charged":true,"bill_to":{"city":"Gdansk","state":null,"address":"Foobar","country":"PL","last_name":"K","first_name":"D","postal_code":"89273","company_name":"DK"},"value":1000,"refunded":false,"user":{"id":2,"email":"rush@test.com.com"},"subscriptions":[]},{"id":10,"created_at":"2016-07-14T22:40:04.323Z","currency":"USD","auto_charged":true,"bill_to":{"city":"Gdansk","state":null,"address":"Foobar","country":"PL","last_name":"K","first_name":"D","postal_code":"89273","company_name":"DK"},"value":2000,"refunded":false,"user":{"id":2,"email":"rush@test.com.com"},"subscriptions":[]},{"id":9,"created_at":"2016-07-14T22:39:05.630Z","currency":"USD","auto_charged":true,"bill_to":{"city":"Gdansk","state":null,"address":"Foobar","country":"PL","last_name":"K","first_name":"D","postal_code":"89273","company_name":"DK"},"value":2000,"refunded":false,"user":{"id":2,"email":"rush@test.com.com"},"subscriptions":[]},{"id":8,"created_at":"2016-07-14T22:37:18.419Z","currency":"USD","auto_charged":true,"bill_to":{"city":"Gdansk","state":null,"address":"Foobar","country":"PL","last_name":"K","first_name":"D","postal_code":"89273","company_name":"DK"},"value":2000,"refunded":false,"user":{"id":2,"email":"rush@test.com.com"},"subscriptions":[]},{"id":7,"created_at":"2016-07-14T15:04:53.613Z","currency":"USD","auto_charged":true,"bill_to":{"city":"Gdansk","state":null,"address":"Foobar","country":"PL","last_name":"K","first_name":"D","postal_code":"89273","company_name":"DK"},"value":1000,"refunded":false,"user":{"id":2,"email":"rush@test.com.com"},"subscriptions":[]},{"id":6,"created_at":"2016-05-02T17:32:49.329Z","currency":"USD","auto_charged":false,"bill_to":{"city":"Gdansk","state":null,"country":"PL","last_name":"K","first_name":"D","postal_code":"89273"},"value":500,"refunded":false,"user":{"id":1,"email":"admin@test.com"},"subscriptions":[]},{"id":4,"created_at":"2016-05-02T17:31:15.706Z","currency":"USD","auto_charged":false,"bill_to":{"city":"Gdansk","state":null,"country":"PL","last_name":"K","first_name":"D","postal_code":"89273"},"value":500,"refunded":false,"user":{"id":1,"email":"admin@test.com"},"subscriptions":[]},{"id":3,"created_at":"2016-04-06T16:38:31.915Z","currency":"USD","auto_charged":false,"bill_to":{"city":"Gdansk","state":null,"country":"PL","last_name":"K","first_name":"D","postal_code":"89273"},"value":1000,"refunded":false,"user":{"id":1,"email":"admin@test.com"},"subscriptions":[]},{"id":2,"created_at":"2016-02-03T19:53:44.196Z","currency":"usd","auto_charged":false,"bill_to":{"city":"Gdansk","state":null,"country":"PL","last_name":"K","first_name":"D","postal_code":"89273"},"value":500,"refunded":false,"user":{"id":1,"email":"admin@test.com"},"subscriptions":[]},{"id":1,"created_at":"2016-02-03T19:45:58.499Z","currency":"usd","auto_charged":false,"bill_to":{},"value":500,"refunded":false,"user":{"id":1,"email":"admin@test.com"},"subscriptions":[]}]}; | ||
let smallObject = {"id":1,"created_at":"2016-02-03T19:45:58.499Z","currency":"usd","auto_charged":false,"bill_to":{},"value_with_tax":500,"refunded":false}; | ||
let smallObjectCamelized = xcase.camelizeKeys(smallObject); | ||
let object = {array: []}; | ||
@@ -16,2 +21,3 @@ for(let i = 0;i < 10;++i) { | ||
let camelizedObject = xcase.camelizeKeys(object); | ||
let objectPool = []; | ||
@@ -23,2 +29,3 @@ function initPool() { | ||
} | ||
initPool(); // pool for testing in place camelizeKeys | ||
@@ -37,14 +44,72 @@ function onCycle(event) { | ||
initPool(); | ||
function getStringForDecamelize() { | ||
return 'fooBarFooBar'; | ||
} | ||
let camelizedObject = xcase.camelizeKeys(object); | ||
function getStringForCamelize() { | ||
return 'foo_bar_foo'; | ||
} | ||
(new Benchmark.Suite) | ||
.add('xcase#camelize', function() { | ||
xcase.camelize(getStringForCamelize()); | ||
}) | ||
.add('humps#camelize', function() { | ||
humps.camelize(getStringForCamelize()); | ||
}) | ||
.add('lodash#camelCase', function() { | ||
camelCase(getStringForCamelize()); | ||
}) | ||
.on('cycle', onCycle).on('complete', onComplete).run(); | ||
(new Benchmark.Suite) | ||
.add('xcase#decamelize', function() { | ||
xcase.decamelize(getStringForDecamelize()); | ||
}) | ||
.add('humps#decamelize', function() { | ||
humps.decamelize(getStringForDecamelize()); | ||
}) | ||
.add('lodash#snakeCase', function() { | ||
camelCase(getStringForDecamelize()); | ||
}) | ||
.on('cycle', onCycle).on('complete', onComplete).run(); | ||
(new Benchmark.Suite) | ||
.add('xcase#camelizeKeys', function() { | ||
xcase.camelizeKeys(smallObject); | ||
}) | ||
.add('humps#camelizeKeys', function() { | ||
humps.camelizeKeys(smallObject); | ||
}) | ||
.add('lodash#reduce + camelCase', function() { | ||
reduce(smallObject, function (record, val, key) { | ||
record[camelCase(key)] = val; | ||
return record; | ||
}, {}); | ||
}) | ||
.on('cycle', onCycle).on('complete', onComplete).run(); | ||
(new Benchmark.Suite) | ||
.add('xcase#decamelizeKeys', function() { | ||
xcase.decamelizeKeys(smallObjectCamelized); | ||
}) | ||
.add('humps#decamelizeKeys', function() { | ||
humps.decamelizeKeys(smallObjectCamelized); | ||
}) | ||
.add('lodash#reduce + snakeCase', function() { | ||
reduce(smallObject, function (record, val, key) { | ||
record[snakeCase(key)] = val; | ||
return record; | ||
}, {}); | ||
}) | ||
.on('cycle', onCycle).on('complete', onComplete).run(); | ||
(new Benchmark.Suite) | ||
.add('xcase#camelizeKeys (large object)', function() { | ||
xcase.camelizeKeys(objectPool.pop()); | ||
}) | ||
.add('xcase#camelizeKeys {inPlace: true}', function() { | ||
.add('xcase#camelizeKeys {inPlace: true} (large object)', function() { | ||
xcase.camelizeKeys(objectPool.pop(), {inPlace: true}); | ||
}) | ||
.add('humps#camelizeKeys', function() { | ||
.add('humps#camelizeKeys (large object)', function() { | ||
humps.camelizeKeys(objectPool.pop()); | ||
@@ -54,10 +119,9 @@ }) | ||
(new Benchmark.Suite) | ||
.add('xcase#decamelizeKeys', function() { | ||
.add('xcase#decamelizeKeys (large object)', function() { | ||
xcase.decamelizeKeys(camelizedObject); | ||
}) | ||
.add('humps#decamelizeKeys', function() { | ||
.add('humps#decamelizeKeys (large object)', function() { | ||
humps.decamelizeKeys(camelizedObject); | ||
}) | ||
.on('cycle', onCycle).on('complete', onComplete).run(); |
@@ -71,19 +71,17 @@ 'use strict'; | ||
function decamelize(str, opts) { | ||
return algorithms.decamelize(str, opts && opts.separator || ''); | ||
} | ||
function depascalize(str, opts) { | ||
return algorithms.depascalize(str, opts && opts.separator || ''); | ||
} | ||
var iface = { | ||
camelize: algorithms.camelize, | ||
decamelize: function decamelize(str, opts) { | ||
return algorithms.decamelize(str, opts && opts.separator || ''); | ||
}, | ||
return { | ||
camelize: algorithms.camelize, | ||
decamelize: decamelize, | ||
pascalize: algorithms.pascalize, | ||
depascalize: depascalize, | ||
depascalize: function depascalize(str, opts) { | ||
return algorithms.depascalize(str, opts && opts.separator || ''); | ||
}, | ||
camelizeKeys: function camelizeKeys(obj, opts) { | ||
opts = opts || {}; | ||
if (!shouldProcessValue(obj)) return obj; | ||
if (opts.inPlace) return processKeysInPlace(obj, algorithms.camelize, opts); | ||
return processKeys(obj, algorithms.camelize, opts); | ||
if (opts.inPlace) return processKeysInPlace(obj, iface.camelize, opts); | ||
return processKeys(obj, iface.camelize, opts); | ||
}, | ||
@@ -93,4 +91,4 @@ decamelizeKeys: function decamelizeKeys(obj, opts) { | ||
if (!shouldProcessValue(obj)) return obj; | ||
if (opts.inPlace) return processKeysInPlace(obj, decamelize, opts); | ||
return processKeys(obj, decamelize, opts); | ||
if (opts.inPlace) return processKeysInPlace(obj, iface.decamelize, opts); | ||
return processKeys(obj, iface.decamelize, opts); | ||
}, | ||
@@ -100,4 +98,4 @@ pascalizeKeys: function pascalizeKeys(obj, opts) { | ||
if (!shouldProcessValue(obj)) return obj; | ||
if (opts.inPlace) return processKeysInPlace(obj, algorithms.pascalize, opts); | ||
return processKeys(obj, algorithms.pascalize, opts); | ||
if (opts.inPlace) return processKeysInPlace(obj, iface.pascalize, opts); | ||
return processKeys(obj, iface.pascalize, opts); | ||
}, | ||
@@ -107,6 +105,7 @@ depascalizeKeys: function depascalizeKeys(obj, opts) { | ||
if (!shouldProcessValue(obj)) return obj; | ||
if (opts.inPlace) return processKeysInPlace(obj, depascalize, opts); | ||
return processKeys(obj, depascalize, opts); | ||
if (opts.inPlace) return processKeysInPlace(obj, iface.depascalize, opts); | ||
return processKeys(obj, iface.depascalize, opts); | ||
} | ||
}; | ||
return iface; | ||
}; |
34
main.js
@@ -48,19 +48,16 @@ 'use strict'; | ||
function decamelize(str, opts) { | ||
return algorithms.decamelize(str, (opts && opts.separator) || ''); | ||
} | ||
function depascalize(str, opts) { | ||
return algorithms.depascalize(str, (opts && opts.separator) || ''); | ||
} | ||
return { | ||
let iface = { | ||
camelize: algorithms.camelize, | ||
decamelize: decamelize, | ||
decamelize(str, opts) { | ||
return algorithms.decamelize(str, (opts && opts.separator) || ''); | ||
}, | ||
pascalize: algorithms.pascalize, | ||
depascalize: depascalize, | ||
depascalize(str, opts) { | ||
return algorithms.depascalize(str, (opts && opts.separator) || ''); | ||
}, | ||
camelizeKeys(obj, opts) { | ||
opts = opts || {}; | ||
if(!shouldProcessValue(obj)) return obj; | ||
if(opts.inPlace) return processKeysInPlace(obj, algorithms.camelize, opts); | ||
return processKeys(obj, algorithms.camelize, opts); | ||
if(opts.inPlace) return processKeysInPlace(obj, iface.camelize, opts); | ||
return processKeys(obj, iface.camelize, opts); | ||
}, | ||
@@ -70,4 +67,4 @@ decamelizeKeys(obj, opts) { | ||
if(!shouldProcessValue(obj)) return obj; | ||
if(opts.inPlace) return processKeysInPlace(obj, decamelize, opts); | ||
return processKeys(obj, decamelize, opts); | ||
if(opts.inPlace) return processKeysInPlace(obj, iface.decamelize, opts); | ||
return processKeys(obj, iface.decamelize, opts); | ||
}, | ||
@@ -77,4 +74,4 @@ pascalizeKeys(obj, opts) { | ||
if(!shouldProcessValue(obj)) return obj; | ||
if(opts.inPlace) return processKeysInPlace(obj, algorithms.pascalize, opts); | ||
return processKeys(obj, algorithms.pascalize, opts); | ||
if(opts.inPlace) return processKeysInPlace(obj, iface.pascalize, opts); | ||
return processKeys(obj, iface.pascalize, opts); | ||
}, | ||
@@ -84,6 +81,7 @@ depascalizeKeys(obj, opts) { | ||
if(!shouldProcessValue(obj)) return obj; | ||
if(opts.inPlace) return processKeysInPlace(obj, depascalize, opts); | ||
return processKeys(obj, depascalize, opts); | ||
if(opts.inPlace) return processKeysInPlace(obj, iface.depascalize, opts); | ||
return processKeys(obj, iface.depascalize, opts); | ||
} | ||
}; | ||
return iface; | ||
}; |
{ | ||
"name": "xcase", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "Blazingly fast recursive convertion to and from camelCase or PascalCase for Objects and Arrays", | ||
@@ -8,3 +8,3 @@ "main": "index", | ||
"test": "mocha", | ||
"build": "babel index.js main.js -d es5", | ||
"build": "babel index.js main.js -d es5 && browserify -s xcase -r ./es5/index.js -o dist/xcase.js && uglifyjs dist/xcase.js > dist/xcase.min.js", | ||
"prepublish": "npm run build" | ||
@@ -31,5 +31,3 @@ }, | ||
"homepage": "https://github.com/encharm/xcase#readme", | ||
"dependencies": { | ||
"nan": "^2.4.0" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
@@ -39,3 +37,6 @@ "babel-cli": "^6.14.0", | ||
"benchmark": "^2.1.1", | ||
"bower": "^1.7.9", | ||
"browserify": "^13.1.0", | ||
"humps": "^1.1.0", | ||
"lodash": "^4.15.0", | ||
"mocha": "^3.0.2", | ||
@@ -42,0 +43,0 @@ "uglify-js": "^2.7.3" |
# xcase | ||
Blazingly fast recursive conversion to and from camelCase or PascalCase for Objects and Arrays. | ||
Blazingly fast recursive conversion to and from camelCase or PascalCase for objects and arrays and strings. | ||
It supports both Node.js and Browser. Node.js has a slightly more performant native implementation. | ||
It supports both Node.js and Browser. | ||
xcase passes most of https://github.com/domchristie/humps tests, excluding only those with custom regexps and handler functions. So if you use `humps` in Node and need something 4x faster then this is the right place. | ||
xcase passes most of https://github.com/domchristie/humps tests, excluding only those with custom regexps and handler functions. So if you use `humps` and need something much faster than this is the right place. | ||
``` | ||
> node benchmark.js | ||
xcase#camelizeKeys x 667 ops/sec ±1.06% (91 runs sampled) | ||
xcase#camelizeKeys {inPlace: true} x 594 ops/sec ±1.75% (83 runs sampled) | ||
humps#camelizeKeys x 166 ops/sec ±0.24% (84 runs sampled) | ||
xcase#camelize x 5,399,331 ops/sec ±1.36% (90 runs sampled) | ||
humps#camelize x 690,996 ops/sec ±1.48% (87 runs sampled) | ||
lodash#camelCase x 597,486 ops/sec ±0.96% (87 runs sampled) | ||
Fastest is xcase#camelize | ||
xcase#decamelize x 4,662,606 ops/sec ±0.72% (92 runs sampled) | ||
humps#decamelize x 1,293,234 ops/sec ±1.50% (85 runs sampled) | ||
lodash#snakeCase x 503,567 ops/sec ±1.69% (91 runs sampled) | ||
Fastest is xcase#decamelize | ||
xcase#camelizeKeys x 415,509 ops/sec ±1.41% (90 runs sampled) | ||
humps#camelizeKeys x 108,174 ops/sec ±0.89% (89 runs sampled) | ||
lodash#reduce + camelCase x 91,300 ops/sec ±0.59% (93 runs sampled) | ||
Fastest is xcase#camelizeKeys | ||
xcase#decamelizeKeys x 427,660 ops/sec ±1.05% (93 runs sampled) | ||
humps#decamelizeKeys x 161,917 ops/sec ±1.03% (91 runs sampled) | ||
lodash#reduce + snakeCase: | ||
Fastest is xcase#decamelizeKeys | ||
xcase#camelizeKeys (large object) x 518 ops/sec ±1.77% (87 runs sampled) | ||
xcase#camelizeKeys {inPlace: true} (large object) x 447 ops/sec ±1.50% (77 runs sampled) | ||
humps#camelizeKeys (large object) x 134 ops/sec ±2.16% (75 runs sampled) | ||
Fastest is xcase#camelizeKeys (large object) | ||
xcase#decamelizeKeys (large object) x 508 ops/sec ±1.10% (86 runs sampled) | ||
humps#decamelizeKeys (large object) x 135 ops/sec ±19.79% (63 runs sampled) | ||
Fastest is xcase#decamelizeKeys (large object) | ||
``` | ||
@@ -48,3 +68,3 @@ | ||
* `pascalize(object, [opts])` | ||
* `pascalize(string, [opts])` | ||
@@ -51,0 +71,0 @@ change `"foo_bar"`/`"foo bar"`/`"foo-bar"` to `"FooBar"` |
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
59613
0
15
1110
94
9
1
4
- Removednan@^2.4.0
- Removednan@2.22.0(transitive)