decamelize-keys
Convert object keys from camelCase to lowercase with a custom separator
Last updated 9 years ago by dsblv .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install decamelize-keys 
SYNC missed versions from official npm registry.

decamelize-keys

Convert object keys from camel case using decamelize

Install

npm install decamelize-keys

Usage

import decamelizeKeys from 'decamelize-keys';

// Convert an object
decamelizeKeys({fooBar: true});
//=> {foo_bar: true}

// Convert an array of objects
decamelizeKeys([{fooBar: true}, {barFoo: false}]);
//=> [{foo_bar: true}, {bar_foo: false}]

API

decamelizeKeys(input, options?)

input

Type: object | object[]

An object or array of objects to decamelize.

options

Type: object

separator

Type: string
Default: '_'

The character or string used to separate words.

import decamelizeKeys from 'decamelize-keys';

decamelizeKeys({fooBar: true});
//=> {foo_bar: true}

decamelizeKeys({fooBar: true}, {separator: '-'});
//=> {'foo-bar': true}
exclude

Type: Array<string | RegExp>
Default: []

Exclude keys from being decamelized.

deep

Type: boolean
Default: false

Recurse nested objects and objects in arrays.

import decamelizeKeys from 'decamelize-keys';

decamelizeKeys({fooBar: true, nested: {unicornRainbow: true}}, {deep: true});
//=> {foo_bar: true, nested: {unicorn_rainbow: true}}

Related

Current Tags

  • 2.0.1                                ...           latest (2 years ago)

5 Versions

  • 2.0.1                                ...           2 years ago
  • 2.0.0                                ...           2 years ago
  • 1.1.1                                ...           2 years ago
  • 1.1.0                                ...           9 years ago
  • 1.0.0                                ...           9 years ago
Maintainers (1)
Downloads
Today 1
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (2)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |