Repository: plexis-js/plexis (js)

Issue:
Feature request: `toCamelCase / camelize `
Converts the input text to [camel case](https://en.wikipedia.org/wiki/Camel_case).


**Example usage**

```javascript
import toCamelCase from '@plexis/to-camel-case';

toCamelCase('Cool');
// => 'cool'

toCamelCase('cool mate');
// => 'coolMate'

toCamelCase('Hey how are you today?');
// => 'heyHowAreYouToday'

toCamelCase('PascalCase');
// => 'pascalCase'

toCamelCase('kebab-case');
// => kebabCase

```

**Aliases**

```javascript
import toCamelCase from '@plexis/to-camel-case';
import {toCamelCase, camelize, camelCase} from 'plexis';
```

Pull request:
feat(to-camel-case): init toCamelCase
My attempt at the toCamelCase feature.
Fairly new to PR's on open source so most of my files were created by referencing other projects like toLower or toSucc.
yarn test passed but failed for plexis > index.js, unsure if this is related to my files? Seems to have been issues with toPred.

Fixes #14 

Patch:
diff --git a/packages/plexis/package.json b/packages/plexis/package.json
index 36331e3..7052e99 100644
--- a/packages/plexis/package.json
+++ b/packages/plexis/package.json
@@ -13,12 +13,14 @@
   ],
   "license": "MIT",
   "dependencies": {
+
     "@plexis/compose": "^0.0.15",
     "@plexis/distance": "^0.0.15",
     "@plexis/is-lowercase": "^0.0.15",
     "@plexis/is-string": "^0.0.15",
     "@plexis/is-uppercase": "^0.0.15",
     "@plexis/starts-with": "^0.0.15",
+    "@plexis/to-camel-case": "^0.0.15",
     "@plexis/to-chicago": "^0.0.15",
     "@plexis/to-lower": "^0.0.15",
     "@plexis/to-pred": "^0.0.15",
diff --git a/packages/plexis/src/index.js b/packages/plexis/src/index.js
index 802c19b..fd8044e 100644
--- a/packages/plexis/src/index.js
+++ b/packages/plexis/src/index.js
@@ -1,6 +1,11 @@
 export {default as toPred, default as toPredecessor} from '@plexis/to-pred';
 export {default as toSucc, default as toSuccessor} from '@plexis/to-succ';
 export {default as toTitle, default as titleize} from '@plexis/to-title';
+export {
+  default as toCamelCase,
+  default as camelize,
+  default as camelCase
+} from '@plexis/to-camel-case';
 export {
   default as toLower,
   default as toFirstLower,
diff --git a/packages/toCamelCase/.npmignore b/packages/toCamelCase/.npmignore
new file mode 100644
index 0000000..552cf85
--- /dev/null
+++ b/packages/toCamelCase/.npmignore
@@ -0,0 +1,17 @@
+.DS_Store
+*.test.js
+.prettierrc
+.github
+.template
+.package-template
+.nyc_output
+.circleci
+.commitlintrc.js
+coverage
+coverage.lcov
+docs
+babel.config.js
+test
+CONTRIBUTING.md
+CODE_OF_CONDUCT.md
+LICENCE
\ No newline at end of file
diff --git a/packages/toCamelCase/README.md b/packages/toCamelCase/README.md
new file mode 100644
index 0000000..b585142
--- /dev/null
+++ b/packages/toCamelCase/README.md
@@ -0,0 +1,26 @@
+# `@plexis/toCamelCase`
+
+Converts the input text to camelCase.
+
+**Installation**
+`npm i @plexis/to-camel-case`
+
+**Usage**
+
+```javascript
+import toCamelCase from '@plexis/to-camel-case';
+
+toCamelCase('Cool'); //=> 'cool'
+toCamelCase('cool mate'); // => 'coolMate'
+toCamelCase('Hey how are you today?'); // => 'heyHowAreYouToday'
+toCamelCase('PascalCase'); // => 'pascalCase'
+toCamelCase('kebab-case'); // => kebabCase
+```
+
+**Aliases**
+
+```javascript
+import {toCamelCase} from 'plexis';
+import {camelCase} from 'plexis';
+import {camelize} from 'plexis';
+```
diff --git a/packages/toCamelCase/package.json b/packages/toCamelCase/package.json
new file mode 100644
index 0000000..151b6cb
--- /dev/null
+++ b/packages/toCamelCase/package.json
@@ -0,0 +1,29 @@
+{
+  "name": "@plexis/to-camel-case",
+  "version": "0.0.15",
+  "main": "dist/index.js",
+  "module": "dist/index.esm.js",
+  "jsnext:main": "./src/index.js",
+  "files": [
+    "dist",
+    "src"
+  ],
+  "authors": [
+    "Theodore Vorillas <vorillaz@gmail.com> (https://vorillaz.com)"
+  ],
+  "license": "MIT",
+  "keywords": [
+    "utility",
+    "string",
+    "parse",
+    "format",
+    "validate"
+  ],
+  "repository": {
+    "type": "git",
+    "url": "git+https://github.com/plexis-js/plexis.git"
+  },
+  "publishConfig": {
+    "access": "public"
+  }
+}
diff --git a/packages/toCamelCase/src/index.js b/packages/toCamelCase/src/index.js
new file mode 100644
index 0000000..4225e48
--- /dev/null
+++ b/packages/toCamelCase/src/index.js
@@ -0,0 +1,26 @@
+/**
+ * @description Converts a string to camel case
+ * @param {String} text
+ * @returns {String} camel case text
+ * @example
+ * toCamelCase('Cool'); //=> 'cool'
+ * toCamelCase('cool mate'); // => 'coolMate'
+ * toCamelCase('Hey how are you today?'); // => 'heyHowAreYouToday'
+ * toCamelCase('PascalCase'); // => 'pascalCase'
+ * toCamelCase('kebab-case'); // => kebabCase
+ */
+
+const toCamelCase = string => {
+  const lowerUpper = (letter, index) => {
+    return index === 0 ? letter.toLowerCase() : letter.toUpperCase();
+  };
+  const wordPatt = /^\w|[A-Z]|\b\w/g;
+  const symbolPatt = /[^a-zA-Z0-9]/g;
+  let result = string
+    .trim()
+    .replace(wordPatt, lowerUpper)
+    .replace(symbolPatt, '');
+  return result;
+};
+
+export default toCamelCase;


Test patch:
diff --git a/packages/plexis/test/__snapshots__/index.js.snap b/packages/plexis/test/__snapshots__/index.js.snap
index b101624..c838e8d 100644
--- a/packages/plexis/test/__snapshots__/index.js.snap
+++ b/packages/plexis/test/__snapshots__/index.js.snap
@@ -9,6 +9,9 @@ Array [
   "toSuccessor",
   "toTitle",
   "titleize",
+  "toCamelCase",
+  "camelize",
+  "camelCase",
   "toLower",
   "toFirstLower",
   "decapitalize",
diff --git a/packages/toCamelCase/test/index.js b/packages/toCamelCase/test/index.js
new file mode 100644
index 0000000..dc8f51c
--- /dev/null
+++ b/packages/toCamelCase/test/index.js
@@ -0,0 +1,12 @@
+import toCamelCase from '../src';
+
+it('converts a given string to camel case', () => {
+  expect(toCamelCase('Cool')).toBe('cool');
+  expect(toCamelCase('cool mate')).toBe('coolMate');
+  expect(toCamelCase('Hey how are you today?')).toBe('heyHowAreYouToday');
+  expect(toCamelCase('PascalCase')).toBe('pascalCase');
+  expect(toCamelCase('kebab-case')).toBe('kebabCase');
+  expect(toCamelCase('')).toBe('');
+  expect(toCamelCase('      ')).toBe('');
+  expect(toCamelCase(' kebab-case PascalCase @hello!  ')).toBe('kebabCasePascalCaseHello');
+});