recase
Deep re-key Objects and Arrays as either camel case or snake case.
In short:
becomes:
And can be converted back.
Note that leading underscores _
are considered as convention for private / special vars and are ingnored when changing case.
If I ever support CamelCaps
(first letter capital) I might use leading $
for private / special.
Usage
This example works in both the Browser and Node
{ 'use strict'; var Recase = exportsRecase || recase = Recase snake camel _ = exports_ || ; snake = recase; camel = recase; console; console;}'undefined' !== typeof exports && exports || 'return this';
Currently converts between the two most common conventions (that I've seen):
snake_case -> camelCase
and_private_var -> _privateVar
camelCase -> snake_case
and_privateVar -> _private_var
Install
npm install --save recase
bower install --save recase
Notes
Does not support CamelCaps
Use the exceptions map for inconsistent key conversions such as XMLHttpRequest
-> xml_http_request
.