diff -Nru node-camelcase-keys-4.0.0/bench/bench.js node-camelcase-keys-6.2.2/bench/bench.js --- node-camelcase-keys-4.0.0/bench/bench.js 1970-01-01 00:00:00.000000000 +0000 +++ node-camelcase-keys-6.2.2/bench/bench.js 2020-04-03 03:50:04.000000000 +0000 @@ -0,0 +1,17 @@ +/* globals bench suite set */ +'use strict'; +const camelcaseKeysNpm = require('camelcase-keys'); +const fixture = require('./fixture'); +const camelcaseKeys = require('..'); + +suite('camelcaseKeys', () => { + set('mintime', 1000); + + bench('npm', () => { + camelcaseKeysNpm(fixture, {deep: true}); + }); + + bench('master', () => { + camelcaseKeys(fixture, {deep: true}); + }); +}); diff -Nru node-camelcase-keys-4.0.0/bench/fixture.json node-camelcase-keys-6.2.2/bench/fixture.json --- node-camelcase-keys-4.0.0/bench/fixture.json 1970-01-01 00:00:00.000000000 +0000 +++ node-camelcase-keys-6.2.2/bench/fixture.json 2020-04-03 03:50:04.000000000 +0000 @@ -0,0 +1,45 @@ +{ + "_id": "58ca523329b7997ab7b741a2", + "index": 0, + "guid": "e58a19f6-5dc3-45a6-bf57-2db5d32171d6", + "is_active": false, + "balance": "$3,245.09", + "picture": "http://placehold.it/32x32", + "age": 21, + "eye_color": "blue", + "name": "Murphy Rivers", + "gender": "male", + "company": "OVOLO", + "email": "murphyrivers@ovolo.com", + "phone": "+1 (840) 432-3958", + "address": "950 Wortman Avenue, Axis, New Jersey, 9085", + "about": "Qui nulla proident voluptate ut qui laborum est qui aute pariatur consequat reprehenderit. Esse nulla aute sunt esse exercitation ipsum consequat consequat anim ipsum tempor non ex excepteur. Dolor sit id incididunt cillum veniam sint veniam et aliqua velit aute qui magna esse. Qui id minim mollit est magna sunt esse eiusmod. Amet cillum irure est fugiat. Ipsum consectetur Lorem excepteur laboris.", + "registered": "2016-04-11T11:47:47 -04:00", + "latitude": -79.956954, + "longitude": 21.129594, + "tags": [ + "et", + "occaecat", + "aliqua", + "ex", + "Lorem", + "excepteur", + "do" + ], + "friends": [ + { + "id": 0, + "name": "Penelope Castro" + }, + { + "id": 1, + "name": "Henderson Cannon" + }, + { + "id": 2, + "name": "Alicia Howard" + } + ], + "greeting": "Hello, Murphy Rivers! You have 8 unread messages.", + "favorite_fruit": "banana" +} diff -Nru node-camelcase-keys-4.0.0/bench/package.json node-camelcase-keys-6.2.2/bench/package.json --- node-camelcase-keys-4.0.0/bench/package.json 1970-01-01 00:00:00.000000000 +0000 +++ node-camelcase-keys-6.2.2/bench/package.json 2020-04-03 03:50:04.000000000 +0000 @@ -0,0 +1,5 @@ +{ + "devDependencies": { + "camelcase-keys": "*" + } +} diff -Nru node-camelcase-keys-4.0.0/debian/changelog node-camelcase-keys-6.2.2/debian/changelog --- node-camelcase-keys-4.0.0/debian/changelog 2016-10-25 14:35:39.000000000 +0000 +++ node-camelcase-keys-6.2.2/debian/changelog 2020-04-27 20:10:21.000000000 +0000 @@ -1,3 +1,19 @@ +node-camelcase-keys (6.2.2-1) unstable; urgency=medium + + * Team upload + * Declare compliance with policy 4.5.0 + * Bump debhelper compatibility level to 12 + * Update VCS fields to salsa + * Use pkg-js-tools auto test & install + * New upstream version 6.2.2 + * Add "Rules-Requires-Root: no" + * Change section to javascript + * Add debian/gbp.conf + * Add upstream/metadata + * Enable upstream test using tape instead of ava + + -- Xavier Guimard Mon, 27 Apr 2020 22:10:21 +0200 + node-camelcase-keys (4.0.0-1) unstable; urgency=low * Initial release (Closes: #826371) diff -Nru node-camelcase-keys-4.0.0/debian/compat node-camelcase-keys-6.2.2/debian/compat --- node-camelcase-keys-4.0.0/debian/compat 2016-10-25 14:35:39.000000000 +0000 +++ node-camelcase-keys-6.2.2/debian/compat 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -9 diff -Nru node-camelcase-keys-4.0.0/debian/control node-camelcase-keys-6.2.2/debian/control --- node-camelcase-keys-4.0.0/debian/control 2016-10-25 14:35:39.000000000 +0000 +++ node-camelcase-keys-6.2.2/debian/control 2020-04-27 20:08:59.000000000 +0000 @@ -1,24 +1,27 @@ Source: node-camelcase-keys -Section: web +Section: javascript Priority: optional Maintainer: Debian Javascript Maintainers Uploaders: Pirate Praveen -Build-Depends: - debhelper (>= 9) - , dh-buildinfo - , nodejs -Standards-Version: 3.9.8 -Homepage: https://github.com/sindresorhus/camelcase-keys#readme -Vcs-Git: https://anonscm.debian.org/git/pkg-javascript/node-camelcase-keys.git -Vcs-Browser: https://anonscm.debian.org/cgit/pkg-javascript/node-camelcase-keys.git +Build-Depends: debhelper-compat (= 12) + , node-camelcase + , node-map-obj + , node-quick-lru + , node-tape + , pkg-js-tools (>= 0.9.20~) +Standards-Version: 4.5.0 +Vcs-Browser: https://salsa.debian.org/js-team/node-camelcase-keys +Vcs-Git: https://salsa.debian.org/js-team/node-camelcase-keys.git +Homepage: https://github.com/sindresorhus/camelcase-keys +Testsuite: autopkgtest-pkg-nodejs +Rules-Requires-Root: no Package: node-camelcase-keys Architecture: all -Depends: - ${misc:Depends} +Depends: ${misc:Depends} + , node-camelcase + , node-map-obj + , node-quick-lru , nodejs - , node-map-obj (>= 2.0.0~) - , node-camelcase (>= 3.0.0~) Description: convert object keys to camelCase - . Node.js is an event-based server-side JavaScript engine. diff -Nru node-camelcase-keys-4.0.0/debian/copyright node-camelcase-keys-6.2.2/debian/copyright --- node-camelcase-keys-4.0.0/debian/copyright 2016-10-25 14:35:39.000000000 +0000 +++ node-camelcase-keys-6.2.2/debian/copyright 2020-02-19 05:37:27.000000000 +0000 @@ -1,4 +1,4 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: camelcase-keys Upstream-Contact: https://github.com/sindresorhus/camelcase-keys/issues Source: https://github.com/sindresorhus/camelcase-keys#readme @@ -31,4 +31,3 @@ 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. - diff -Nru node-camelcase-keys-4.0.0/debian/gbp.conf node-camelcase-keys-6.2.2/debian/gbp.conf --- node-camelcase-keys-4.0.0/debian/gbp.conf 1970-01-01 00:00:00.000000000 +0000 +++ node-camelcase-keys-6.2.2/debian/gbp.conf 2020-04-27 20:00:10.000000000 +0000 @@ -0,0 +1,5 @@ +[DEFAULT] +pristine-tar = True + +[import-orig] +filter = [ '.gitignore', '.travis.yml', '.git*' ] diff -Nru node-camelcase-keys-4.0.0/debian/install node-camelcase-keys-6.2.2/debian/install --- node-camelcase-keys-4.0.0/debian/install 2016-10-25 14:35:39.000000000 +0000 +++ node-camelcase-keys-6.2.2/debian/install 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -package.json usr/lib/nodejs/camelcase-keys/ -index.js usr/lib/nodejs/camelcase-keys/ diff -Nru node-camelcase-keys-4.0.0/debian/nodejs/extlinks node-camelcase-keys-6.2.2/debian/nodejs/extlinks --- node-camelcase-keys-4.0.0/debian/nodejs/extlinks 1970-01-01 00:00:00.000000000 +0000 +++ node-camelcase-keys-6.2.2/debian/nodejs/extlinks 2020-04-27 20:06:53.000000000 +0000 @@ -0,0 +1 @@ +camelcase diff -Nru node-camelcase-keys-4.0.0/debian/patches/series node-camelcase-keys-6.2.2/debian/patches/series --- node-camelcase-keys-4.0.0/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 +++ node-camelcase-keys-6.2.2/debian/patches/series 2020-04-27 20:07:39.000000000 +0000 @@ -0,0 +1 @@ +switch-test-from-ava-to-tape.diff diff -Nru node-camelcase-keys-4.0.0/debian/patches/switch-test-from-ava-to-tape.diff node-camelcase-keys-6.2.2/debian/patches/switch-test-from-ava-to-tape.diff --- node-camelcase-keys-4.0.0/debian/patches/switch-test-from-ava-to-tape.diff 1970-01-01 00:00:00.000000000 +0000 +++ node-camelcase-keys-6.2.2/debian/patches/switch-test-from-ava-to-tape.diff 2020-04-27 20:08:04.000000000 +0000 @@ -0,0 +1,92 @@ +Description: replace ava by tape in tests +Author: Xavier Guimard +Forwarded: not-needed +Last-Update: 2020-04-27 + +--- a/test.js ++++ b/test.js +@@ -1,13 +1,15 @@ +-import test from 'ava'; +-import camelcaseKeys from '.'; ++const test = require('tape'); ++const camelcaseKeys = require('.'); + + test('main', t => { + t.true(camelcaseKeys({'foo-bar': true}).fooBar); ++ t.end(); + }); + + test('exclude option', t => { + t.true(camelcaseKeys({'--': true}, {exclude: ['--']})['--']); + t.deepEqual(camelcaseKeys({'foo-bar': true}, {exclude: [/^f/]}), {'foo-bar': true}); ++ t.end(); + }); + + test('deep option', t => { +@@ -16,6 +18,7 @@ + camelcaseKeys({foo_bar: true, obj: {one_two: false, arr: [{three_four: true}]}}, {deep: true}), + {fooBar: true, obj: {oneTwo: false, arr: [{threeFour: true}]}} + ); ++ t.end(); + }); + + test('stopPaths option', t => { +@@ -45,10 +48,12 @@ + // eslint-disable-next-line camelcase + {aB: 1, aC: {cD: 1, cE: {e_f: 1}}} + ); ++ t.end(); + }); + + test('pascalCase option only', t => { + t.true(camelcaseKeys({'new-foo-bar': true}, {pascalCase: true}).NewFooBar); ++ t.end(); + }); + + test('pascalCase and deep options', t => { +@@ -57,6 +62,7 @@ + camelcaseKeys({p_foo_bar: true, p_obj: {p_two: false, p_arr: [{p_three_four: true}]}}, {deep: true, pascalCase: true}), + {PFooBar: true, PObj: {PTwo: false, PArr: [{PThreeFour: true}]}} + ); ++ t.end(); + }); + + test('handles nested arrays', t => { +@@ -65,6 +71,7 @@ + camelcaseKeys({q_w_e: [['a', 'b']]}, {deep: true}), + {qWE: [['a', 'b']]} + ); ++ t.end(); + }); + + test('accepts an array of objects', t => { +@@ -73,6 +80,7 @@ + camelcaseKeys([{foo_bar: true}, {bar_foo: false}, {'bar-foo': 'false'}]), + [{fooBar: true}, {barFoo: false}, {barFoo: 'false'}] + ); ++ t.end(); + }); + + test('different pascalCase option values', t => { +@@ -89,6 +97,7 @@ + camelcaseKeys({'p-foo-bar': true, 'p-obj': {'p-two': false, 'p-arr': [{'p-three-four': true}]}}, {deep: true}), + {pFooBar: true, pObj: {pTwo: false, pArr: [{pThreeFour: true}]}} + ); ++ t.end(); + }); + + test('handle array of non-objects', t => { +@@ -97,6 +106,7 @@ + camelcaseKeys(input), + input + ); ++ t.end(); + }); + + test('handle array of non-objects with `deep` option', t => { +@@ -105,4 +115,5 @@ + camelcaseKeys(input, {deep: true}), + input + ); ++ t.end(); + }); diff -Nru node-camelcase-keys-4.0.0/debian/rules node-camelcase-keys-6.2.2/debian/rules --- node-camelcase-keys-4.0.0/debian/rules 2016-10-25 14:35:39.000000000 +0000 +++ node-camelcase-keys-6.2.2/debian/rules 2020-04-27 19:54:58.000000000 +0000 @@ -5,11 +5,4 @@ #export DH_VERBOSE=1 %: - dh $@ - -#override_dh_auto_build: - -#override_dh_auto_test: - - - + dh $@ --with nodejs diff -Nru node-camelcase-keys-4.0.0/debian/tests/control node-camelcase-keys-6.2.2/debian/tests/control --- node-camelcase-keys-4.0.0/debian/tests/control 2016-10-25 14:35:39.000000000 +0000 +++ node-camelcase-keys-6.2.2/debian/tests/control 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -Tests: require -Depends: node-camelcase-keys diff -Nru node-camelcase-keys-4.0.0/debian/tests/pkg-js/test node-camelcase-keys-6.2.2/debian/tests/pkg-js/test --- node-camelcase-keys-4.0.0/debian/tests/pkg-js/test 1970-01-01 00:00:00.000000000 +0000 +++ node-camelcase-keys-6.2.2/debian/tests/pkg-js/test 2020-04-27 20:08:46.000000000 +0000 @@ -0,0 +1 @@ +tape test.js diff -Nru node-camelcase-keys-4.0.0/debian/tests/require node-camelcase-keys-6.2.2/debian/tests/require --- node-camelcase-keys-4.0.0/debian/tests/require 2016-10-25 14:35:39.000000000 +0000 +++ node-camelcase-keys-6.2.2/debian/tests/require 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -#!/bin/sh -set -e -nodejs -e "require('camelcase-keys');" diff -Nru node-camelcase-keys-4.0.0/debian/upstream/metadata node-camelcase-keys-6.2.2/debian/upstream/metadata --- node-camelcase-keys-4.0.0/debian/upstream/metadata 1970-01-01 00:00:00.000000000 +0000 +++ node-camelcase-keys-6.2.2/debian/upstream/metadata 2020-04-27 20:00:10.000000000 +0000 @@ -0,0 +1,7 @@ +--- +Archive: GitHub +Bug-Database: https://github.com/sindresorhus/camelcase-keys/issues +Bug-Submit: https://github.com/sindresorhus/camelcase-keys/issues/new +Changelog: https://github.com/sindresorhus/camelcase-keys/tags +Repository: https://github.com/sindresorhus/camelcase-keys.git +Repository-Browse: https://github.com/sindresorhus/camelcase-keys diff -Nru node-camelcase-keys-4.0.0/.editorconfig node-camelcase-keys-6.2.2/.editorconfig --- node-camelcase-keys-4.0.0/.editorconfig 2016-09-17 05:21:20.000000000 +0000 +++ node-camelcase-keys-6.2.2/.editorconfig 2020-04-03 03:50:04.000000000 +0000 @@ -7,6 +7,6 @@ trim_trailing_whitespace = true insert_final_newline = true -[{package.json,*.yml}] +[*.yml] indent_style = space indent_size = 2 diff -Nru node-camelcase-keys-4.0.0/.gitattributes node-camelcase-keys-6.2.2/.gitattributes --- node-camelcase-keys-4.0.0/.gitattributes 2016-09-17 05:21:20.000000000 +0000 +++ node-camelcase-keys-6.2.2/.gitattributes 2020-04-03 03:50:04.000000000 +0000 @@ -1,2 +1 @@ -* text=auto -*.js text eol=lf +* text=auto eol=lf diff -Nru node-camelcase-keys-4.0.0/.github/funding.yml node-camelcase-keys-6.2.2/.github/funding.yml --- node-camelcase-keys-4.0.0/.github/funding.yml 1970-01-01 00:00:00.000000000 +0000 +++ node-camelcase-keys-6.2.2/.github/funding.yml 2020-04-03 03:50:04.000000000 +0000 @@ -0,0 +1,4 @@ +github: sindresorhus +open_collective: sindresorhus +tidelift: npm/camelcase-keys +custom: https://sindresorhus.com/donate diff -Nru node-camelcase-keys-4.0.0/.github/security.md node-camelcase-keys-6.2.2/.github/security.md --- node-camelcase-keys-4.0.0/.github/security.md 1970-01-01 00:00:00.000000000 +0000 +++ node-camelcase-keys-6.2.2/.github/security.md 2020-04-03 03:50:04.000000000 +0000 @@ -0,0 +1,3 @@ +# Security Policy + +To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure. diff -Nru node-camelcase-keys-4.0.0/.gitignore node-camelcase-keys-6.2.2/.gitignore --- node-camelcase-keys-4.0.0/.gitignore 2016-09-17 05:21:20.000000000 +0000 +++ node-camelcase-keys-6.2.2/.gitignore 2020-04-03 03:50:04.000000000 +0000 @@ -1 +1,2 @@ node_modules +yarn.lock diff -Nru node-camelcase-keys-4.0.0/index.d.ts node-camelcase-keys-6.2.2/index.d.ts --- node-camelcase-keys-4.0.0/index.d.ts 1970-01-01 00:00:00.000000000 +0000 +++ node-camelcase-keys-6.2.2/index.d.ts 2020-04-03 03:50:04.000000000 +0000 @@ -0,0 +1,103 @@ +declare namespace camelcaseKeys { + interface Options { + /** + Recurse nested objects and objects in arrays. + + @default false + */ + readonly deep?: boolean; + + /** + Exclude keys from being camel-cased. + + @default [] + */ + readonly exclude?: ReadonlyArray; + + /** + Exclude children at the given object paths in dot-notation from being camel-cased. For example, with an object like `{a: {b: '🦄'}}`, the object path to reach the unicorn is `'a.b'`. + + @default [] + + @example + ``` + camelcaseKeys({ + a_b: 1, + a_c: { + c_d: 1, + c_e: { + e_f: 1 + } + } + }, { + deep: true, + stopPaths: [ + 'a_c.c_e' + ] + }), + // { + // aB: 1, + // aC: { + // cD: 1, + // cE: { + // e_f: 1 + // } + // } + // } + ``` + */ + readonly stopPaths?: ReadonlyArray; + + /** + Uppercase the first character as in `bye-bye` → `ByeBye`. + + @default false + */ + readonly pascalCase?: boolean; + } +} + +/** +Convert object keys to camel case using [`camelcase`](https://github.com/sindresorhus/camelcase). + +@param input - Object or array of objects to camel-case. + +@example +``` +import camelcaseKeys = require('camelcase-keys'); + +// Convert an object +camelcaseKeys({'foo-bar': true}); +//=> {fooBar: true} + +// Convert an array of objects +camelcaseKeys([{'foo-bar': true}, {'bar-foo': false}]); +//=> [{fooBar: true}, {barFoo: false}] + +camelcaseKeys({'foo-bar': true, nested: {unicorn_rainbow: true}}, {deep: true}); +//=> {fooBar: true, nested: {unicornRainbow: true}} + +// Convert object keys to pascal case +camelcaseKeys({'foo-bar': true, nested: {unicorn_rainbow: true}}, {deep: true, pascalCase: true}); +//=> {FooBar: true, Nested: {UnicornRainbow: true}} + +import minimist = require('minimist'); + +const argv = minimist(process.argv.slice(2)); +//=> {_: [], 'foo-bar': true} + +camelcaseKeys(argv); +//=> {_: [], fooBar: true} +``` +*/ +declare function camelcaseKeys>( + input: T, + options?: camelcaseKeys.Options, +): T; + +declare function camelcaseKeys( + input: T, + options?: camelcaseKeys.Options, +): T; + +export = camelcaseKeys; diff -Nru node-camelcase-keys-4.0.0/index.js node-camelcase-keys-6.2.2/index.js --- node-camelcase-keys-4.0.0/index.js 2016-09-17 05:21:20.000000000 +0000 +++ node-camelcase-keys-6.2.2/index.js 2020-04-03 03:50:04.000000000 +0000 @@ -1,17 +1,77 @@ 'use strict'; const mapObj = require('map-obj'); const camelCase = require('camelcase'); +const QuickLru = require('quick-lru'); -const has = (arr, key) => arr.some(x => typeof x === 'string' ? x === key : x.test(key)); +const has = (array, key) => array.some(x => { + if (typeof x === 'string') { + return x === 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}); + x.lastIndex = 0; + return x.test(key); +}); + +const cache = new QuickLru({maxSize: 100000}); + +// Reproduces behavior from `map-obj` +const isObject = value => + typeof value === 'object' && + value !== null && + !(value instanceof RegExp) && + !(value instanceof Error) && + !(value instanceof Date); + +const camelCaseConvert = (input, options) => { + if (!isObject(input)) { + return input; + } + + options = { + deep: false, + pascalCase: false, + ...options + }; + + const {exclude, pascalCase, stopPaths, deep} = options; + + const stopPathsSet = new Set(stopPaths); + + const makeMapper = parentPath => (key, value) => { + if (deep && isObject(value)) { + const path = parentPath === undefined ? key : `${parentPath}.${key}`; + + if (!stopPathsSet.has(path)) { + value = mapObj(value, makeMapper(path)); + } + } + + if (!(exclude && has(exclude, key))) { + const cacheKey = pascalCase ? `${key}_` : key; + + if (cache.has(cacheKey)) { + key = cache.get(cacheKey); + } else { + const ret = camelCase(key, {pascalCase}); + + if (key.length < 100) { // Prevent abuse + cache.set(cacheKey, ret); + } + + key = ret; + } + } + + return [key, value]; + }; + + return mapObj(input, makeMapper(undefined)); +}; + +module.exports = (input, options) => { + if (Array.isArray(input)) { + return Object.keys(input).map(key => camelCaseConvert(input[key], options)); + } + + return camelCaseConvert(input, options); }; diff -Nru node-camelcase-keys-4.0.0/index.test-d.ts node-camelcase-keys-6.2.2/index.test-d.ts --- node-camelcase-keys-4.0.0/index.test-d.ts 1970-01-01 00:00:00.000000000 +0000 +++ node-camelcase-keys-6.2.2/index.test-d.ts 2020-04-03 03:50:04.000000000 +0000 @@ -0,0 +1,56 @@ +import {expectType} from 'tsd'; +import camelcaseKeys = require('.'); + +const fooBarObject = {'foo-bar': true}; +const camelFooBarObject = camelcaseKeys(fooBarObject); +expectType(camelFooBarObject); + +const fooBarArray = [{'foo-bar': true}]; +const camelFooBarArray = camelcaseKeys(fooBarArray); +expectType(camelFooBarArray); + +expectType>(camelcaseKeys([{'foo-bar': true}])); + +expectType(camelcaseKeys(['name 1', 'name 2'])); + +expectType(camelcaseKeys(['name 1', 'name 2'], {deep: true})); + +expectType<{[key in 'foo-bar']: true}>(camelcaseKeys({'foo-bar': true})); + +expectType<{[key in 'foo-bar']: true}>( + camelcaseKeys({'foo-bar': true}, {deep: true}), +); + +expectType<{[key in 'foo-bar']: true}>( + camelcaseKeys({'foo-bar': true}, {deep: true, pascalCase: true}), +); + +expectType<{[key in 'foo-bar']: true}>( + camelcaseKeys({'foo-bar': true}, {exclude: ['foo', /bar/]}), +); + +expectType<{[key in 'foo-bar']: true}>( + camelcaseKeys({'foo-bar': true}, {stopPaths: ['foo']}), +); + +interface SomeObject { + someProperty: string; +} + +const someObj: SomeObject = { + someProperty: 'hello' +}; + +expectType(camelcaseKeys(someObj)); +expectType(camelcaseKeys([someObj])); + +type SomeTypeAlias = { + someProperty: string; +} + +const objectWithTypeAlias = { + someProperty: 'this should also work' +}; + +expectType(camelcaseKeys(objectWithTypeAlias)); +expectType(camelcaseKeys([objectWithTypeAlias])); diff -Nru node-camelcase-keys-4.0.0/license node-camelcase-keys-6.2.2/license --- node-camelcase-keys-4.0.0/license 2016-09-17 05:21:20.000000000 +0000 +++ node-camelcase-keys-6.2.2/license 2020-04-03 03:50:04.000000000 +0000 @@ -1,21 +1,9 @@ -The MIT License (MIT) +MIT License 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: +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 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. +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. diff -Nru node-camelcase-keys-4.0.0/.npmrc node-camelcase-keys-6.2.2/.npmrc --- node-camelcase-keys-4.0.0/.npmrc 1970-01-01 00:00:00.000000000 +0000 +++ node-camelcase-keys-6.2.2/.npmrc 2020-04-03 03:50:04.000000000 +0000 @@ -0,0 +1 @@ +package-lock=false diff -Nru node-camelcase-keys-4.0.0/package.json node-camelcase-keys-6.2.2/package.json --- node-camelcase-keys-4.0.0/package.json 2016-09-17 05:21:20.000000000 +0000 +++ node-camelcase-keys-6.2.2/package.json 2020-04-03 03:50:04.000000000 +0000 @@ -1,58 +1,73 @@ { - "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 - } + "name": "camelcase-keys", + "version": "6.2.2", + "description": "Convert object keys to camel case", + "license": "MIT", + "repository": "sindresorhus/camelcase-keys", + "funding": "https://github.com/sponsors/sindresorhus", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "engines": { + "node": ">=8" + }, + "scripts": { + "test": "xo && ava && tsd", + "bench": "matcha bench/bench.js" + }, + "files": [ + "index.js", + "index.d.ts" + ], + "keywords": [ + "map", + "obj", + "object", + "key", + "keys", + "value", + "values", + "val", + "iterate", + "camelcase", + "camel-case", + "camel", + "case", + "dash", + "hyphen", + "dot", + "underscore", + "separator", + "string", + "text", + "convert", + "pascalcase", + "pascal-case", + "deep", + "recurse", + "recursive" + ], + "dependencies": { + "camelcase": "^5.3.1", + "map-obj": "^4.0.0", + "quick-lru": "^4.0.1" + }, + "devDependencies": { + "ava": "^2.1.0", + "matcha": "^0.7.0", + "tsd": "^0.11.0", + "xo": "^0.25.3" + }, + "xo": { + "overrides": [ + { + "files": "bench/bench.js", + "rules": { + "import/no-unresolved": "off" + } + } + ] + } } diff -Nru node-camelcase-keys-4.0.0/readme.md node-camelcase-keys-6.2.2/readme.md --- node-camelcase-keys-4.0.0/readme.md 2016-09-17 05:21:20.000000000 +0000 +++ node-camelcase-keys-6.2.2/readme.md 2020-04-03 03:50:04.000000000 +0000 @@ -1,25 +1,35 @@ # 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) - +> Convert object keys to camel case using [`camelcase`](https://github.com/sindresorhus/camelcase) ## Install ``` -$ npm install --save camelcase-keys +$ npm install camelcase-keys ``` - ## Usage ```js const camelcaseKeys = require('camelcase-keys'); +// Convert an object camelcaseKeys({'foo-bar': true}); //=> {fooBar: true} +// Convert an array of objects +camelcaseKeys([{'foo-bar': true}, {'bar-foo': false}]); +//=> [{fooBar: true}, {barFoo: false}] + camelcaseKeys({'foo-bar': true, nested: {unicorn_rainbow: true}}, {deep: true}); //=> {fooBar: true, nested: {unicornRainbow: true}} + +camelcaseKeys({a_b: 1, a_c: {c_d: 1, c_e: {e_f: 1}}}, {deep: true, stopPaths: ['a_c.c_e']}), +//=> {aB: 1, aC: {cD: 1, cE: {e_f: 1}}} + +// Convert object keys to pascal case +camelcaseKeys({'foo-bar': true, nested: {unicorn_rainbow: true}}, {deep: true, pascalCase: true}); +//=> {FooBar: true, Nested: {UnicornRainbow: true}} ``` ```js @@ -32,36 +42,84 @@ //=> {_: [], fooBar: true} ``` - ## API -### camelcaseKeys(input, [options]) +### camelcaseKeys(input, options?) #### input -Type: `Object` +Type: `object | object[]` -Object to camelCase. +An object or array of objects to camel-case. #### options -Type: `Object` +Type: `object` ##### exclude -Type: `string[]` `RegExp[]`
+Type: `Array`\ +Default: `[]` + +Exclude keys from being camel-cased. + +##### stopPaths + +Type: `string[]`\ Default: `[]` -Exclude keys from being camelCased. +Exclude children at the given object paths in dot-notation from being camel-cased. For example, with an object like `{a: {b: '🦄'}}`, the object path to reach the unicorn is `'a.b'`. + +```js +camelcaseKeys({ + a_b: 1, + a_c: { + c_d: 1, + c_e: { + e_f: 1 + } + } +}, { + deep: true, + stopPaths: [ + 'a_c.c_e' + ] +}), +/* +{ + aB: 1, + aC: { + cD: 1, + cE: { + e_f: 1 + } + } +} +*/ +``` ##### deep -Type: `boolean`
+Type: `boolean`\ Default: `false` Recurse nested objects and objects in arrays. +##### pascalCase + +Type: `boolean`\ +Default: `false` + +Uppercase the first character as in `bye-bye` → `ByeBye`. + +## camelcase-keys for enterprise + +Available as part of the Tidelift Subscription. + +The maintainers of camelcase-keys and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-camelcase-keys?utm_source=npm-camelcase-keys&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) + +## Related -## License +- [snakecase-keys](https://github.com/bendrucker/snakecase-keys) +- [kebabcase-keys](https://github.com/mattiloh/kebabcase-keys) -MIT © [Sindre Sorhus](https://sindresorhus.com) diff -Nru node-camelcase-keys-4.0.0/test.js node-camelcase-keys-6.2.2/test.js --- node-camelcase-keys-4.0.0/test.js 2016-09-17 05:21:20.000000000 +0000 +++ node-camelcase-keys-6.2.2/test.js 2020-04-03 03:50:04.000000000 +0000 @@ -1,19 +1,108 @@ import test from 'ava'; -import m from './'; +import camelcaseKeys from '.'; test('main', t => { - t.true(m({'foo-bar': true}).fooBar); + t.true(camelcaseKeys({'foo-bar': true}).fooBar); }); test('exclude option', t => { - t.true(m({'--': true}, {exclude: ['--']})['--']); - t.deepEqual(m({'foo-bar': true}, {exclude: [/^f/]}), {'foo-bar': true}); + t.true(camelcaseKeys({'--': true}, {exclude: ['--']})['--']); + t.deepEqual(camelcaseKeys({'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}), + camelcaseKeys({foo_bar: true, obj: {one_two: false, arr: [{three_four: true}]}}, {deep: true}), {fooBar: true, obj: {oneTwo: false, arr: [{threeFour: true}]}} ); }); + +test('stopPaths option', t => { + t.deepEqual( + // eslint-disable-next-line camelcase + camelcaseKeys({foo_bar: true, obj: {one_two: false, arr: [{three_four: true}]}}, {deep: true, stopPaths: ['obj']}), + // eslint-disable-next-line camelcase + {fooBar: true, obj: {one_two: false, arr: [{three_four: true}]}} + ); + + t.deepEqual( + // eslint-disable-next-line camelcase + camelcaseKeys({foo_bar: true, obj: {one_two: false, arr: [{three_four: true}]}}, {deep: true, stopPaths: ['obj.arr']}), + // eslint-disable-next-line camelcase + {fooBar: true, obj: {oneTwo: false, arr: [{three_four: true}]}} + ); + + t.deepEqual( + // eslint-disable-next-line camelcase + camelcaseKeys({q_w_e: [[{foo_bar: 1}, {one_two: 2}, {foo_bar: 3, one_two: 4}]]}, {deep: true, stopPaths: ['q_w_e.foo_bar']}), + {qWE: [[{fooBar: 1}, {oneTwo: 2}, {fooBar: 3, oneTwo: 4}]]} + ); + + t.deepEqual( + // eslint-disable-next-line camelcase + camelcaseKeys({a_b: 1, a_c: {c_d: 1, c_e: {e_f: 1}}}, {deep: true, stopPaths: ['a_c.c_e']}), + // eslint-disable-next-line camelcase + {aB: 1, aC: {cD: 1, cE: {e_f: 1}}} + ); +}); + +test('pascalCase option only', t => { + t.true(camelcaseKeys({'new-foo-bar': true}, {pascalCase: true}).NewFooBar); +}); + +test('pascalCase and deep options', t => { + t.deepEqual( + // eslint-disable-next-line camelcase + camelcaseKeys({p_foo_bar: true, p_obj: {p_two: false, p_arr: [{p_three_four: true}]}}, {deep: true, pascalCase: true}), + {PFooBar: true, PObj: {PTwo: false, PArr: [{PThreeFour: true}]}} + ); +}); + +test('handles nested arrays', t => { + t.deepEqual( + // eslint-disable-next-line camelcase + camelcaseKeys({q_w_e: [['a', 'b']]}, {deep: true}), + {qWE: [['a', 'b']]} + ); +}); + +test('accepts an array of objects', t => { + t.deepEqual( + // eslint-disable-next-line camelcase + camelcaseKeys([{foo_bar: true}, {bar_foo: false}, {'bar-foo': 'false'}]), + [{fooBar: true}, {barFoo: false}, {barFoo: 'false'}] + ); +}); + +test('different pascalCase option values', t => { + // eslint-disable-next-line camelcase + t.true(camelcaseKeys({foo_bar_UPPERCASE: true}).fooBarUppercase); + // eslint-disable-next-line camelcase + t.true(camelcaseKeys({foo_bar_UPPERCASE: true}, {pascalCase: true}).FooBarUppercase); + + t.deepEqual( + camelcaseKeys({'p-foo-bar': true, 'p-obj': {'p-two': false, 'p-arr': [{'p-three-four': true}]}}, {deep: true, pascalCase: true}), + {PFooBar: true, PObj: {PTwo: false, PArr: [{PThreeFour: true}]}} + ); + t.deepEqual( + camelcaseKeys({'p-foo-bar': true, 'p-obj': {'p-two': false, 'p-arr': [{'p-three-four': true}]}}, {deep: true}), + {pFooBar: true, pObj: {pTwo: false, pArr: [{pThreeFour: true}]}} + ); +}); + +test('handle array of non-objects', t => { + const input = ['name 1', 'name 2']; + t.deepEqual( + camelcaseKeys(input), + input + ); +}); + +test('handle array of non-objects with `deep` option', t => { + const input = ['name 1', 'name 2']; + t.deepEqual( + camelcaseKeys(input, {deep: true}), + input + ); +}); diff -Nru node-camelcase-keys-4.0.0/.travis.yml node-camelcase-keys-6.2.2/.travis.yml --- node-camelcase-keys-4.0.0/.travis.yml 2016-09-17 05:21:20.000000000 +0000 +++ node-camelcase-keys-6.2.2/.travis.yml 2020-04-03 03:50:04.000000000 +0000 @@ -1,5 +1,5 @@ -sudo: false language: node_js node_js: - - '6' - - '4' + - '12' + - '10' + - '8'