Skip to content

a node.js module for replacing object keys to the style you want

Notifications You must be signed in to change notification settings

eachcan/convert-key

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

convert-key

Converting object key to what you want.

callback

var converter = require('convert-key');

var obj = {
	hello_world: {
		Upper_and_underscore: "a",
		camelCasing: true,
	}
}
convertor.any(obj, function (key) {
	var matches = /([A-Z])/.exec(key);
	for (var occ in matches[1]) {
		key.replace(matches[1][occ], '_' + matches[1][occ].toLowerCase());
	}
	
	return key.replace(/^_+/, '').replace(/_+$/, '');
});

// obj = {hello_world: {upper_and_underscore:"a", canel_casing: true} }

About

a node.js module for replacing object keys to the style you want

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published