snake-keys

3.0.0 • Public • Published

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 = 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

Package Sidebar

Install

npm i snake-keys

Weekly Downloads

7

Version

3.0.0

License

MIT

Unpacked Size

3.96 kB

Total Files

4

Last publish

Collaborators

  • codingdive