Package Exports
- transform-obj-keys
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (transform-obj-keys) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
transform-obj-keys
Transform object keys easily using whatever transform function like:
camelcase
,decamelize
,uppercamelcase
,to-case
or simple String.prototype.toLowerCase()
Install
$ npm install --save transform-obj-keys
Usage
const transformObjKeys = require('transform-obj-keys');
const camelCase = require('camelcase');
// Convert an object
transformObjKeys({'foo-bar': true}, camelCase);
//=> {fooBar: true}
// Convert an array of objects
transformObjKeys([{'foo-bar': true}, {'bar-foo': false}], camelCase);
//=> [{fooBar: true}, {barFoo: false}]
transformObjKeys({'foo-bar': true, nested: {unicorn_rainbow: true}}, camelCase, {deep: true});
//=> {fooBar: true, nested: {unicornRainbow: true}}
const transformObjKeys = require('transform-obj-keys');
const camelCase = require('camelcase');
const argv = require('minimist')(process.argv.slice(2));
//=> {_: [], 'foo-bar': true}
transformObjKeys(argv, camelCase);
//=> {_: [], fooBar: true}
API
transformObjKeys(input, transformFunc, [options])
input
Type: Object
Object[]
Object or array of objects to transform.
transformFunc
Type: Function
Function to manipulate strings
options
Type: Object
exclude
Type: string[]
RegExp[]
Default: []
Exclude keys from being transformed.
deep
Type: boolean
Default: false
Recurse nested objects and objects in arrays.
License
MIT © Martin Litvaj