Comparing version 0.0.11 to 0.1.0
@@ -8,3 +8,2 @@ { | ||
"dependencies": { | ||
"ianstormtaylor/case": "0.1.0" | ||
}, | ||
@@ -11,0 +10,0 @@ "development": { |
0.1.0 / 2014-09-02 | ||
================== | ||
* moved to a standard normalization with only letters, numbers and dots | ||
0.0.11 / 2014-08-30 | ||
@@ -3,0 +8,0 @@ =================== |
40
index.js
var Case = require('case'); | ||
var identity = function(_){ return _; }; | ||
@@ -7,20 +6,2 @@ | ||
/** | ||
* Cases | ||
*/ | ||
var cases = [ | ||
identity, | ||
Case.upper, | ||
Case.lower, | ||
Case.snake, | ||
Case.pascal, | ||
Case.camel, | ||
Case.constant, | ||
Case.title, | ||
Case.capital, | ||
Case.sentence | ||
]; | ||
/** | ||
* Module exports, export | ||
@@ -121,6 +102,3 @@ */ | ||
function find (obj, key) { | ||
for (var i = 0; i < cases.length; i++) { | ||
var cased = cases[i](key); | ||
if (obj.hasOwnProperty(cased)) return obj[cased]; | ||
} | ||
if (obj.hasOwnProperty(key)) return obj[key]; | ||
} | ||
@@ -136,6 +114,3 @@ | ||
function del (obj, key) { | ||
for (var i = 0; i < cases.length; i++) { | ||
var cased = cases[i](key); | ||
if (obj.hasOwnProperty(cased)) delete obj[cased]; | ||
} | ||
if (obj.hasOwnProperty(key)) delete obj[key]; | ||
return obj; | ||
@@ -152,6 +127,3 @@ } | ||
function replace (obj, key, val) { | ||
for (var i = 0; i < cases.length; i++) { | ||
var cased = cases[i](key); | ||
if (obj.hasOwnProperty(cased)) obj[cased] = val; | ||
} | ||
if (obj.hasOwnProperty(key)) obj[key] = val; | ||
return obj; | ||
@@ -163,3 +135,3 @@ } | ||
* | ||
* A.HELLO_WORLD.bar => a.hello_world.bar | ||
* A.HELL(!*&#(!)O_WOR LD.bar => ahelloworldbar | ||
* | ||
@@ -171,5 +143,3 @@ * @param {String} path | ||
function normalize(path) { | ||
return path.split('.').map(function(part){ | ||
return Case.camel(part); | ||
}).join('.'); | ||
return path.replace(/[^a-zA-Z0-9\.]+/g, '').toLowerCase(); | ||
} |
{ | ||
"name": "obj-case", | ||
"version": "0.0.11", | ||
"version": "0.1.0", | ||
"description": "Work with objects of different cased keys", | ||
@@ -21,5 +21,3 @@ "main": "index.js", | ||
"license": "MIT", | ||
"dependencies": { | ||
"case": "ianstormtaylor/case#0.1.1" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
@@ -26,0 +24,0 @@ "mocha": "~1.12.0", |
@@ -87,2 +87,7 @@ | ||
it('should treat camel-cased same as lowercase', function () { | ||
var obj = { 'woodyallen': 10 }; | ||
expect(objCase(obj, 'woodyAllen')).to.eql(10); | ||
}); | ||
it('should find crazy looking paths 3', function () { | ||
@@ -89,0 +94,0 @@ var obj = { 'some-crazy.PROBABLY_POSSIBLE.NestedProperty': 10 }; |
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
GitHub dependency
Supply chain riskContains a dependency which resolves to a GitHub URL. Dependencies fetched from GitHub specifiers are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
0
0
11968
241
- Removedcase@ianstormtaylor/case#0.1.1