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-keys
Usage
const snakeCaseKeys = ; ;//=> {foo_bar: 'baz'} ;//=> {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