pax_global_header00006660000000000000000000000064127671513200014516gustar00rootroot0000000000000052 comment=fa7d9883e8ffb6d98b8d04533f2e0b342c7d35ee camelcase-keys-4.0.0/000077500000000000000000000000001276715132000144055ustar00rootroot00000000000000camelcase-keys-4.0.0/.editorconfig000066400000000000000000000002761276715132000170670ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [{package.json,*.yml}] indent_style = space indent_size = 2 camelcase-keys-4.0.0/.gitattributes000066400000000000000000000000351276715132000172760ustar00rootroot00000000000000* text=auto *.js text eol=lf camelcase-keys-4.0.0/.gitignore000066400000000000000000000000151276715132000163710ustar00rootroot00000000000000node_modules camelcase-keys-4.0.0/.travis.yml000066400000000000000000000000671276715132000165210ustar00rootroot00000000000000sudo: false language: node_js node_js: - '6' - '4' camelcase-keys-4.0.0/index.js000066400000000000000000000006471276715132000160610ustar00rootroot00000000000000'use strict'; const mapObj = require('map-obj'); const camelCase = require('camelcase'); const has = (arr, key) => arr.some(x => typeof x === 'string' ? x === key : x.test(key)); module.exports = (input, opts) => { opts = Object.assign({ exclude: [], deep: false }, opts); return mapObj(input, (key, val) => { key = has(opts.exclude, key) ? key : camelCase(key); return [key, val]; }, {deep: opts.deep}); }; camelcase-keys-4.0.0/license000066400000000000000000000021371276715132000157550ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) Sindre Sorhus (sindresorhus.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. camelcase-keys-4.0.0/package.json000066400000000000000000000016321276715132000166750ustar00rootroot00000000000000{ "name": "camelcase-keys", "version": "4.0.0", "description": "Convert object keys to camelCase", "license": "MIT", "repository": "sindresorhus/camelcase-keys", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "sindresorhus.com" }, "engines": { "node": ">=4" }, "scripts": { "test": "xo && ava" }, "files": [ "index.js" ], "keywords": [ "map", "obj", "object", "key", "keys", "value", "values", "val", "iterate", "camelcase", "camel-case", "camel", "case", "dash", "hyphen", "dot", "underscore", "separator", "string", "text", "convert", "deep", "recurse", "recursive" ], "dependencies": { "camelcase": "^3.0.0", "map-obj": "^2.0.0" }, "devDependencies": { "ava": "*", "xo": "*" }, "xo": { "esnext": true } } camelcase-keys-4.0.0/readme.md000066400000000000000000000022021276715132000161600ustar00rootroot00000000000000# camelcase-keys [![Build Status](https://travis-ci.org/sindresorhus/camelcase-keys.svg?branch=master)](https://travis-ci.org/sindresorhus/camelcase-keys) > Convert object keys to camelCase using [`camelcase`](https://github.com/sindresorhus/camelcase) ## Install ``` $ npm install --save camelcase-keys ``` ## Usage ```js const camelcaseKeys = require('camelcase-keys'); camelcaseKeys({'foo-bar': true}); //=> {fooBar: true} camelcaseKeys({'foo-bar': true, nested: {unicorn_rainbow: true}}, {deep: true}); //=> {fooBar: true, nested: {unicornRainbow: true}} ``` ```js const camelcaseKeys = require('camelcase-keys'); const argv = require('minimist')(process.argv.slice(2)); //=> {_: [], 'foo-bar': true} camelcaseKeys(argv); //=> {_: [], fooBar: true} ``` ## API ### camelcaseKeys(input, [options]) #### input Type: `Object` Object to camelCase. #### options Type: `Object` ##### exclude Type: `string[]` `RegExp[]`
Default: `[]` Exclude keys from being camelCased. ##### deep Type: `boolean`
Default: `false` Recurse nested objects and objects in arrays. ## License MIT © [Sindre Sorhus](https://sindresorhus.com) camelcase-keys-4.0.0/test.js000066400000000000000000000007741276715132000157320ustar00rootroot00000000000000import test from 'ava'; import m from './'; test('main', t => { t.true(m({'foo-bar': true}).fooBar); }); test('exclude option', t => { t.true(m({'--': true}, {exclude: ['--']})['--']); t.deepEqual(m({'foo-bar': true}, {exclude: [/^f/]}), {'foo-bar': true}); }); test('deep option', t => { t.deepEqual( // eslint-disable-next-line camelcase m({foo_bar: true, obj: {one_two: false, arr: [{three_four: true}]}}, {deep: true}), {fooBar: true, obj: {oneTwo: false, arr: [{threeFour: true}]}} ); });