Repository: plexis-js/plexis (js)

Issue:
Feature request: `toLower / toFirstLower / decapitalize`
Converts the first character of the input text to lowercase. If the second parameter is true, the method converts the rest of the subject to lower case.

```javascript
  @param {String} text
  @param {Boolean} isLowercase
```

**Example usage**

```javascript
import toLower from '@plexis/to-lower';
toLower('foo Bar');
// => foo Bar

toLower('FOO Bar');
// => fOO Bar

toLower('fOO Bar', true);
// => foo bar
```

**Aliases**

```javascript
import toLower from '@plexis/to-lower';
import {toLower, toFirstLower, decapitalize } from 'plexis';
```

Pull request description:
feat(to-lower): init toLower package
Hello @vorillaz 
I've write a `toLower` package with tests, but seems like you have some issues even in your master branch with the `toPred`. Please let me know if it's my issues only and maybe some possible ways to fix that.
![photo_2019-10-20 19 21 05](https://user-images.githubusercontent.com/9076513/67162679-f8f0e600-f36e-11e9-958e-330dd2d988f1.jpeg)

Fixes #6

Patch:
diff --git a/docs/pages/api.md b/docs/pages/api.md
index f81eef8..90e36cf 100644
--- a/docs/pages/api.md
+++ b/docs/pages/api.md
@@ -1,5 +1,6 @@
 ## API
 
+- [toLower](/packages/toLower)
 - [toPred](/packages/toPred)
 - [toSucc](/packages/toSucc)
 - [toTitle](/packages/toTitle)
diff --git a/packages/plexis/package.json b/packages/plexis/package.json
index a109d79..6eba35e 100644
--- a/packages/plexis/package.json
+++ b/packages/plexis/package.json
@@ -9,6 +9,7 @@
   ],
   "license": "MIT",
   "dependencies": {
+    "@plexis/to-lower": "^0.0.11",
     "@plexis/to-pred": "^0.0.11",
     "@plexis/to-succ": "^0.0.11",
     "@plexis/to-title": "^0.0.11",
diff --git a/packages/plexis/src/index.js b/packages/plexis/src/index.js
index 8c34061..29ea706 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 toLower,
+  default as toFirstLower,
+  default as decapitalize
+} from '@plexis/to-lower';
 export {
   default as withoutDiacritics,
   default as cleanDiacritics,
diff --git a/packages/toLower/.npmignore b/packages/toLower/.npmignore
new file mode 100644
index 0000000..552cf85
--- /dev/null
+++ b/packages/toLower/.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/toLower/README.md b/packages/toLower/README.md
new file mode 100644
index 0000000..1e55c2d
--- /dev/null
+++ b/packages/toLower/README.md
@@ -0,0 +1,24 @@
+# `@plexis/toLower`
+
+Lowercase the first letter of the given string.
+
+**Installation**
+`npm i @plexis/to-lower`
+
+**Usage**
+
+```javascript
+import toLower from '@plexis/to-lower';
+
+toLower('Foo Bar', false); // returns 'foo Bar'
+toLower('Foo Bar', true); // returns 'foo bar'
+toLower('FOO BAR', false); // returns 'fOO BAR'
+```
+
+**Aliases**
+
+```javascript
+import {toLower} from 'plexis';
+import {toFirstLower} from 'plexis';
+import {decapitalize} from 'plexis';
+```
diff --git a/packages/toLower/package.json b/packages/toLower/package.json
new file mode 100644
index 0000000..810d454
--- /dev/null
+++ b/packages/toLower/package.json
@@ -0,0 +1,25 @@
+{
+  "name": "@plexis/to-lower",
+  "version": "0.0.11",
+  "main": "dist/index.js",
+  "module": "dist/index.esm.js",
+  "jsnext:main": "./src/index.js",
+  "authors": [
+    "4doge https://github.com/4doge"
+  ],
+  "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/toLower/src/index.js b/packages/toLower/src/index.js
new file mode 100644
index 0000000..04cb759
--- /dev/null
+++ b/packages/toLower/src/index.js
@@ -0,0 +1,14 @@
+/**
+ * @description Lowercase the first letter of the given string.
+ * @param {String} text
+ * @param {Boolean} isLowecase
+ * @example
+ * toLower('Foo Bar', false) // returns 'foo Bar'
+ * toLower('Foo Bar', true) // returns 'foo bar'
+ */
+const toLower = (text, isLower) => {
+  const s = isLower ? text.slice(1).toLowerCase() : text.slice(1);
+  return text.charAt(0).toLowerCase() + s;
+};
+
+export default toLower;


Test patch:
diff --git a/packages/plexis/test/__snapshots__/index.js.snap b/packages/plexis/test/__snapshots__/index.js.snap
index bd8142b..fb20c83 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",
+  "toLower",
+  "toFirstLower",
+  "decapitalize",
   "withoutDiacritics",
   "cleanDiacritics",
   "removeDiacritics",
diff --git a/packages/toLower/test/index.js b/packages/toLower/test/index.js
new file mode 100644
index 0000000..06b3342
--- /dev/null
+++ b/packages/toLower/test/index.js
@@ -0,0 +1,17 @@
+import toLower from '../src';
+
+it('lowercase only the first letter in single word', () => {
+  expect(toLower('HeLLo', false)).toBe('heLLo');
+});
+
+it('lowercase only the first letter in multiword sentense', () => {
+  expect(toLower('HeLLo WorLD', false)).toBe('heLLo WorLD');
+});
+
+it('lowercase all single word letters', () => {
+  expect(toLower('HeLLo', true)).toBe('hello');
+});
+
+it('lowercase all multiword sentense letters', () => {
+  expect(toLower('HeLLo WorLD', true)).toBe('hello world');
+});