aboutsummaryrefslogtreecommitdiff
path: root/node_modules/camelcase-keys
diff options
context:
space:
mode:
authorruki <waruqi@gmail.com>2018-11-08 00:38:48 +0800
committerruki <waruqi@gmail.com>2018-11-07 21:53:09 +0800
commit26105034da4fcce7ac883c899d781f016559310d (patch)
treec459a5dc4e3aa0972d9919033ece511ce76dd129 /node_modules/camelcase-keys
parent2c77f00f1a7ecb6c8192f9c16d3b2001b254a107 (diff)
downloadxmake-docs-26105034da4fcce7ac883c899d781f016559310d.tar.gz
xmake-docs-26105034da4fcce7ac883c899d781f016559310d.zip
switch to vuepress
Diffstat (limited to 'node_modules/camelcase-keys')
-rw-r--r--node_modules/camelcase-keys/index.js41
-rw-r--r--node_modules/camelcase-keys/license21
-rw-r--r--node_modules/camelcase-keys/node_modules/map-obj/index.js45
-rw-r--r--node_modules/camelcase-keys/node_modules/map-obj/license21
-rw-r--r--node_modules/camelcase-keys/node_modules/map-obj/package.json45
-rw-r--r--node_modules/camelcase-keys/node_modules/map-obj/readme.md65
-rw-r--r--node_modules/camelcase-keys/package.json68
-rw-r--r--node_modules/camelcase-keys/readme.md72
8 files changed, 378 insertions, 0 deletions
diff --git a/node_modules/camelcase-keys/index.js b/node_modules/camelcase-keys/index.js
new file mode 100644
index 00000000..c2f4aefd
--- /dev/null
+++ b/node_modules/camelcase-keys/index.js
@@ -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);
+};
+
diff --git a/node_modules/camelcase-keys/license b/node_modules/camelcase-keys/license
new file mode 100644
index 00000000..654d0bfe
--- /dev/null
+++ b/node_modules/camelcase-keys/license
@@ -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.
diff --git a/node_modules/camelcase-keys/node_modules/map-obj/index.js b/node_modules/camelcase-keys/node_modules/map-obj/index.js
new file mode 100644
index 00000000..2a19cde4
--- /dev/null
+++ b/node_modules/camelcase-keys/node_modules/map-obj/index.js
@@ -0,0 +1,45 @@
+'use strict';
+
+// customized for this use-case
+const isObject = x =>
+ typeof x === 'object' &&
+ x !== null &&
+ !(x instanceof RegExp) &&
+ !(x instanceof Error) &&
+ !(x instanceof Date);
+
+module.exports = function mapObj(obj, fn, opts, seen) {
+ opts = Object.assign({
+ deep: false,
+ target: {}
+ }, opts);
+
+ seen = seen || new WeakMap();
+
+ if (seen.has(obj)) {
+ return seen.get(obj);
+ }
+
+ seen.set(obj, opts.target);
+
+ const target = opts.target;
+ delete opts.target;
+
+ for (const key of Object.keys(obj)) {
+ const val = obj[key];
+ const res = fn(key, val, obj);
+ let newVal = res[1];
+
+ if (opts.deep && isObject(newVal)) {
+ if (Array.isArray(newVal)) {
+ newVal = newVal.map(x => isObject(x) ? mapObj(x, fn, opts, seen) : x);
+ } else {
+ newVal = mapObj(newVal, fn, opts, seen);
+ }
+ }
+
+ target[res[0]] = newVal;
+ }
+
+ return target;
+};
diff --git a/node_modules/camelcase-keys/node_modules/map-obj/license b/node_modules/camelcase-keys/node_modules/map-obj/license
new file mode 100644
index 00000000..654d0bfe
--- /dev/null
+++ b/node_modules/camelcase-keys/node_modules/map-obj/license
@@ -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.
diff --git a/node_modules/camelcase-keys/node_modules/map-obj/package.json b/node_modules/camelcase-keys/node_modules/map-obj/package.json
new file mode 100644
index 00000000..4c8e9da7
--- /dev/null
+++ b/node_modules/camelcase-keys/node_modules/map-obj/package.json
@@ -0,0 +1,45 @@
+{
+ "name": "map-obj",
+ "version": "2.0.0",
+ "description": "Map object keys and values into a new object",
+ "license": "MIT",
+ "repository": "sindresorhus/map-obj",
+ "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",
+ "iterator",
+ "rename",
+ "modify",
+ "deep",
+ "recurse",
+ "recursive"
+ ],
+ "devDependencies": {
+ "ava": "*",
+ "xo": "*"
+ },
+ "xo": {
+ "esnext": true
+ }
+}
diff --git a/node_modules/camelcase-keys/node_modules/map-obj/readme.md b/node_modules/camelcase-keys/node_modules/map-obj/readme.md
new file mode 100644
index 00000000..d6ed05c1
--- /dev/null
+++ b/node_modules/camelcase-keys/node_modules/map-obj/readme.md
@@ -0,0 +1,65 @@
+# map-obj [![Build Status](https://travis-ci.org/sindresorhus/map-obj.svg?branch=master)](https://travis-ci.org/sindresorhus/map-obj)
+
+> Map object keys and values into a new object
+
+
+## Install
+
+```
+$ npm install --save map-obj
+```
+
+
+## Usage
+
+```js
+const mapObj = require('map-obj');
+
+const newObject = mapObj({foo: 'bar'}, (key, value) => [value, key]);
+//=> {bar: 'foo'}
+```
+
+
+## API
+
+### mapObj(source, mapper, [options])
+
+#### source
+
+Type: `Object`
+
+Source object to copy properties from.
+
+#### mapper
+
+Type: `Function`
+
+Mapping function.
+
+- It has signature `mapper(sourceKey, sourceValue, source)`.
+- It must return a two item array: `[targetKey, targetValue]`.
+
+#### deep
+
+Type: `boolean`<br>
+Default: `false`
+
+Recurse nested objects and objects in arrays.
+
+#### target
+
+Type: `Object`<br>
+Default: `{}`
+
+Target object to map properties on to.
+
+
+## Related
+
+- [filter-obj](https://github.com/sindresorhus/filter-obj) - Filter object keys and values into a new object
+- [object-assign](https://github.com/sindresorhus/object-assign) - Copy enumerable own properties from one or more source objects to a target object
+
+
+## License
+
+MIT © [Sindre Sorhus](https://sindresorhus.com)
diff --git a/node_modules/camelcase-keys/package.json b/node_modules/camelcase-keys/package.json
new file mode 100644
index 00000000..cb672231
--- /dev/null
+++ b/node_modules/camelcase-keys/package.json
@@ -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"
+ }
+ }
+ ]
+ }
+}
diff --git a/node_modules/camelcase-keys/readme.md b/node_modules/camelcase-keys/readme.md
new file mode 100644
index 00000000..1d7adc0c
--- /dev/null
+++ b/node_modules/camelcase-keys/readme.md
@@ -0,0 +1,72 @@
+# 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');
+
+// 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)