1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-11-10 08:10:18 +00:00
musix-oss/node_modules/snakeize
2020-03-03 22:30:50 +02:00
..
example Modules 2020-03-03 22:30:50 +02:00
test Modules 2020-03-03 22:30:50 +02:00
.npmignore Modules 2020-03-03 22:30:50 +02:00
.travis.yml Modules 2020-03-03 22:30:50 +02:00
component.json Modules 2020-03-03 22:30:50 +02:00
index.js Modules 2020-03-03 22:30:50 +02:00
LICENSE Modules 2020-03-03 22:30:50 +02:00
package.json Modules 2020-03-03 22:30:50 +02:00
readme.markdown Modules 2020-03-03 22:30:50 +02: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