tra-analysis/website/functions/node_modules/snakeize
2019-01-06 13:14:45 -06:00
..
example push all website files 2019-01-06 13:14:45 -06:00
test push all website files 2019-01-06 13:14:45 -06:00
.npmignore push all website files 2019-01-06 13:14:45 -06:00
.travis.yml push all website files 2019-01-06 13:14:45 -06:00
component.json push all website files 2019-01-06 13:14:45 -06:00
index.js push all website files 2019-01-06 13:14:45 -06:00
LICENSE push all website files 2019-01-06 13:14:45 -06:00
package.json push all website files 2019-01-06 13:14:45 -06:00
readme.markdown push all website files 2019-01-06 13:14:45 -06:00

snakeize

recursively transform key strings from camel-case to underscore-style. Derives directly from substack's camelize

build status

browser support

example

var snakeize = require('snakeize');
var obj = {
    feeFieFoe: 'fum',
    beepBoop: [
        { 'abcXyz': 'mno' },
        { 'FooBar': 'baz' },
        { 'CheeseID': 'wensleydale' }
    ]
};
var res = snakeize(obj);
console.log(JSON.stringify(res, null, 2));

output:

{
  "fee_fie_foe": "fum",
  "beep_boop": [
    {
      "abc_xyz": "mno"
    },
    {
      "foo_bar": "baz"
    },
    {
      "cheese_id": "wensleydale"
    }
  ]
}

methods

var snakeize = require('snakeize')

snakeize(obj)

Convert the key strings in obj from camel-case to underscore-stlye recursively.

install

With npm do:

npm install snakeize

To use in the browser, use browserify or component:

component install nathan7/snakeize

license

MIT