Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

obj-case

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

obj-case - npm Package Compare versions

Comparing version 0.0.11 to 0.1.0

1

component.json

@@ -8,3 +8,2 @@ {

"dependencies": {
"ianstormtaylor/case": "0.1.0"
},

@@ -11,0 +10,0 @@ "development": {

5

History.md
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 @@ ===================

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 };

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