Convert object keys to kebab-case using
lodash.kebabcase
, forked from camelcase-keys by Sindre Sorhus.
$ npm install kebabcase-keys
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}}
Type: Object
Object[]
Object or array of objects to kebab-case.
Type: Object
Type: Array<string|RegExp>
Default: []
Exclude keys from being kebab-cased.
Type: boolean
Default: false
Recurse nested objects and objects in arrays.
This is a fork from camelcase-keys by Sindre Sorhus. I just integrated a different case-converter.
MIT © Sindre Sorhus
MIT © Matthias Lohscheidt