[Pkg-javascript-commits] [node-camelcase-keys] 01/04: Import Upstream version 4.0.0
Praveen Arimbrathodiyil
praveen at moszumanska.debian.org
Tue Oct 25 14:43:24 UTC 2016
This is an automated email from the git hooks/post-receive script.
praveen pushed a commit to branch master
in repository node-camelcase-keys.
commit b33b96c14829c48ed702e4d7268e9050ae04a169
Author: Praveen Arimbrathodiyil <praveen at debian.org>
Date: Tue Oct 25 19:10:06 2016 +0530
Import Upstream version 4.0.0
---
.editorconfig | 12 +++++++++++
.gitattributes | 2 ++
.gitignore | 1 +
.travis.yml | 5 +++++
index.js | 17 +++++++++++++++
license | 21 ++++++++++++++++++
package.json | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++
readme.md | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
test.js | 19 +++++++++++++++++
9 files changed, 202 insertions(+)
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..98a761d
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,12 @@
+root = 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
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..391f0a4
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,2 @@
+* text=auto
+*.js text eol=lf
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3c3629e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+node_modules
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..b18bae5
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,5 @@
+sudo: false
+language: node_js
+node_js:
+ - '6'
+ - '4'
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..8dc38ae
--- /dev/null
+++ b/index.js
@@ -0,0 +1,17 @@
+'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});
+};
diff --git a/license b/license
new file mode 100644
index 0000000..654d0bf
--- /dev/null
+++ b/license
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) Sindre Sorhus <sindresorhus at 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/package.json b/package.json
new file mode 100644
index 0000000..785effe
--- /dev/null
+++ b/package.json
@@ -0,0 +1,58 @@
+{
+ "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 at 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
+ }
+}
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..8f8dc65
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,67 @@
+# 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[]`<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)
diff --git a/test.js b/test.js
new file mode 100644
index 0000000..a26aa13
--- /dev/null
+++ b/test.js
@@ -0,0 +1,19 @@
+import 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}]}}
+ );
+});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-camelcase-keys.git
More information about the Pkg-javascript-commits
mailing list