kebabcase-keys
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/kebabcase-keys package

1.0.0 • Public • Published

kebabcase-keys Build Status

Convert object keys to kebab-case using lodash.kebabcase, forked from camelcase-keys by Sindre Sorhus.

Install

$ npm install kebabcase-keys

Usage

const kebabcaseKeys = require('kebabcase-keys');
 
// Convert an object
kebabcaseKeys({foo_bar: true});
//=> {'foo-bar': true}
 
// Convert an array of objects
kebabcaseKeys([{fooBar: true}, {bar_foo: false}]);
//=> [{'foo-bar': true}, {'bar-foo': false}]
 
kebabcaseKeys({foo_bar: true, nested: {unicorn_rainbow: true}}, {deep: true});
//=> {'foo-bar': true, nested: {'unicorn-rainbow': true}}

API

kebabcaseKeys(input, [options])

input

Type: Object Object[]

Object or array of objects to kebab-case.

options

Type: Object

exclude

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

Exclude keys from being kebab-cased.

deep

Type: boolean
Default: false

Recurse nested objects and objects in arrays.

Related

Credits

This is a fork from camelcase-keys by Sindre Sorhus. I just integrated a different case-converter.

License

MIT © Sindre Sorhus MIT © Matthias Lohscheidt

Package Sidebar

Install

npm i kebabcase-keys

Weekly Downloads

1,191

Version

1.0.0

License

MIT

Unpacked Size

4.66 kB

Total Files

4

Last publish

Collaborators

  • mattiloh