snake-keys
v3.0.0
Published
Convert an object's keys to snake case
Downloads
382
Readme
snake-keys
Improved fork of snakecase-keys
that supports the whole word format viz turns userID into user_id instead of
user_i_d and the UPPER_CASE constant format, turning FOO_BAR into foo_bar
instead of foo__bar.
Convert an object's keys to snake case
Install
$ npm install snake-keys
$ yarn add snake-keysUsage
const snakeCaseKeys = require("snake-keys");
snakeCaseKeys({ fooBar: "baz" });
//=> {foo_bar: 'baz'}
snakeCaseKeys({ "foo-bar": true, nested: { fooBaz: "bar" } });
//=> {foo_bar: true, nested: {foo_baz: 'bar'}}API
snakeCaseKeys(obj, options) -> object
obj
Required
Type: object
An object to transform into snake case (keys only).
options
Optional
Type: object
deep
Type: boolean
Default: true
Enables snake-casing of keys in nested objects.
Related
License
MIT
