Initial commit
This commit is contained in:
41
node/TestCli/node_modules/camelcase-keys/index.js
generated
vendored
Normal file
41
node/TestCli/node_modules/camelcase-keys/index.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
'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 cache = new QuickLru({maxSize: 100000});
|
||||
|
||||
const camelCaseConvert = (input, opts) => {
|
||||
opts = Object.assign({
|
||||
deep: false
|
||||
}, opts);
|
||||
|
||||
const exclude = opts.exclude;
|
||||
|
||||
return mapObj(input, (key, val) => {
|
||||
if (!(exclude && has(exclude, key))) {
|
||||
if (cache.has(key)) {
|
||||
key = cache.get(key);
|
||||
} else {
|
||||
const ret = camelCase(key);
|
||||
|
||||
if (key.length < 100) { // Prevent abuse
|
||||
cache.set(key, ret);
|
||||
}
|
||||
|
||||
key = ret;
|
||||
}
|
||||
}
|
||||
|
||||
return [key, val];
|
||||
}, {deep: opts.deep});
|
||||
};
|
||||
|
||||
module.exports = (input, opts) => {
|
||||
if (Array.isArray(input)) {
|
||||
return Object.keys(input).map(key => camelCaseConvert(input[key], opts));
|
||||
}
|
||||
return camelCaseConvert(input, opts);
|
||||
};
|
||||
|
||||
21
node/TestCli/node_modules/camelcase-keys/license
generated
vendored
Normal file
21
node/TestCli/node_modules/camelcase-keys/license
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (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.
|
||||
68
node/TestCli/node_modules/camelcase-keys/package.json
generated
vendored
Normal file
68
node/TestCli/node_modules/camelcase-keys/package.json
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"name": "camelcase-keys",
|
||||
"version": "4.2.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",
|
||||
"bench": "matcha bench/bench.js"
|
||||
},
|
||||
"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": "^4.1.0",
|
||||
"map-obj": "^2.0.0",
|
||||
"quick-lru": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"matcha": "^0.7.0",
|
||||
"xo": "*"
|
||||
},
|
||||
"xo": {
|
||||
"overrides": [
|
||||
{
|
||||
"files": "bench/bench.js",
|
||||
"rules": {
|
||||
"import/no-unresolved": "off"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
72
node/TestCli/node_modules/camelcase-keys/readme.md
generated
vendored
Normal file
72
node/TestCli/node_modules/camelcase-keys/readme.md
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
# camelcase-keys [](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');
|
||||
|
||||
// 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}}
|
||||
```
|
||||
|
||||
```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[]`
|
||||
|
||||
Object or array of objects to camelCase.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `Object`
|
||||
|
||||
##### exclude
|
||||
|
||||
Type: `string[]` `RegExp[]`<br>
|
||||
Default: `[]`
|
||||
|
||||
Exclude keys from being camelCased.
|
||||
|
||||
##### deep
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
Recurse nested objects and objects in arrays.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
Reference in New Issue
Block a user