Socket
Book a DemoInstallSign in
Socket

camelize

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

camelize - npm Package Compare versions

Comparing version

to
0.2.0

11

index.js

@@ -8,2 +8,3 @@ module.exports = function(obj) {

if (!obj || typeof obj !== 'object') return obj;
if (isDate(obj) || isRegex(obj)) return obj;
if (isArray(obj)) return map(obj, walk);

@@ -19,3 +20,3 @@ return reduce(objectKeys(obj), function (acc, key) {

return str.replace(/[_.-](\w|$)/g, function (_,x) {
return x.toUpperCase()
return x.toUpperCase();
});

@@ -28,2 +29,10 @@ }

var isDate = function (obj) {
return Object.prototype.toString.call(obj) === '[object Date]';
};
var isRegex = function (obj) {
return Object.prototype.toString.call(obj) === '[object RegExp]';
};
var has = Object.prototype.hasOwnProperty;

@@ -30,0 +39,0 @@ var objectKeys = Object.keys || function (obj) {

2

package.json
{
"name": "camelize",
"version": "0.1.2",
"version": "0.2.0",
"description": "recursively transform key strings to camel-case",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -29,2 +29,14 @@ var test = require('tape');

test('date', function (t) {
t.plan(1);
var d = new Date();
t.equal(camelize(d), d);
});
test('regex', function (t) {
t.plan(1);
var r = /1234/;
t.equal(camelize(r), r);
});
test('only camelize strings that are the root value', function (t) {

@@ -31,0 +43,0 @@ t.plan(2);

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.