Repository: plexis-js/plexis
Pull request #64 (2019-10-23 20:01:58)

feat(is-empty): added is-empty
resolves: #19 


vorillaz: Thanks for the contribution :)
vorillaz: @eElec I accidentally closed this issue, can you please rebase your branch and we are ready to go.
Apologies for the inconvenience.
vorillaz: Hey @eElec you have missed placing your method in the `docs/api`
codecov[bot]: # [Codecov](https://codecov.io/gh/plexis-js/plexis/pull/64?src=pr&el=h1) Report
> Merging [#64](https://codecov.io/gh/plexis-js/plexis/pull/64?src=pr&el=desc) into [master](https://codecov.io/gh/plexis-js/plexis/commit/078ebe0f587b9f9a2b0314c1f42da216550ff264?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `100%`.


[![Impacted file tree graph](https://codecov.io/gh/plexis-js/plexis/pull/64/graphs/tree.svg?width=650&token=DdDVC9ByG1&height=150&src=pr)](https://codecov.io/gh/plexis-js/plexis/pull/64?src=pr&el=tree)

```diff
@@          Coverage Diff          @@
##           master    #64   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          33     34    +1     
  Lines         161    162    +1     
=====================================
+ Hits          161    162    +1
```


| [Impacted Files](https://codecov.io/gh/plexis-js/plexis/pull/64?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [packages/isAlphaNumeric/src/index.js](https://codecov.io/gh/plexis-js/plexis/pull/64/diff?src=pr&el=tree#diff-cGFja2FnZXMvaXNBbHBoYU51bWVyaWMvc3JjL2luZGV4Lmpz) | `100% <100%> (ø)` | :arrow_up: |
| [packages/isEmpty/src/index.js](https://codecov.io/gh/plexis-js/plexis/pull/64/diff?src=pr&el=tree#diff-cGFja2FnZXMvaXNFbXB0eS9zcmMvaW5kZXguanM=) | `100% <100%> (ø)` | |

eElec: @vorillaz Added it. Probably deleted it while merging at some point.

Patch:
diff --git a/docs/pages/api.md b/docs/pages/api.md
index 44d1275..79ac1fb 100644
--- a/docs/pages/api.md
+++ b/docs/pages/api.md
@@ -10,6 +10,7 @@
 - [insert](/packages/insert)
 - [isAlpha](/packages/isAlpha)
 - [isAlphaNumeric](/packages/isAlphaNumeric)
+- [isEmpty](/packages/isEmpty)
 - [isLowerCase](/packages/isLowerCase)
 - [isNumeric](/packages/isNumeric)
 - [includes](/packages/includes)
diff --git a/packages/isAlphaNumeric/src/index.js b/packages/isAlphaNumeric/src/index.js
index 1954ba4..3d4f5e8 100644
--- a/packages/isAlphaNumeric/src/index.js
+++ b/packages/isAlphaNumeric/src/index.js
@@ -9,6 +9,6 @@
  * isAlphaNumeric('bar!') // returns false
  * isAlphaNumeric('') // returns false
  */
-const isAlphaNumeric = text => typeof text === 'string' ? /^[A-Za-z0-9]+$/.test(text) : false;
+const isAlphaNumeric = text => (typeof text === 'string' ? /^[A-Za-z0-9]+$/.test(text) : false);
 
 export default isAlphaNumeric;
diff --git a/packages/isEmpty/README.md b/packages/isEmpty/README.md
new file mode 100644
index 0000000..24050d0
--- /dev/null
+++ b/packages/isEmpty/README.md
@@ -0,0 +1,24 @@
+# `@plexis/is-empty`
+
+Checks whether the input text is empty.
+
+**Installation**
+`npm i @plexis/to-lower`
+
+**Usage**
+
+```javascript
+import isEmpty from '@plexis/isEmpty';
+
+isEmpty(''); // returns true
+isEmpty('   '); // returns true
+isEmpty(' b  '); // returns false
+isEmpty('Hello'); //returns false
+```
+
+**Aliases**
+
+```javascript
+import isEmpty from '@plexis/is-empty';
+import {isEmpty} from 'plexis';
+```
diff --git a/packages/isEmpty/package.json b/packages/isEmpty/package.json
new file mode 100644
index 0000000..622b4fb
--- /dev/null
+++ b/packages/isEmpty/package.json
@@ -0,0 +1,28 @@
+{
+  "name": "@plexis/is-empty",
+  "version": "0.0.22",
+  "description": "Checks whether the input text is empty.",
+  "main": "dist/index.js",
+  "module": "dist/index.esm.js",
+  "jsnext:main": "./src/index.js",
+  "author": "eElec <adrishaditya@gmail.com>",
+  "files": [
+    "dist",
+    "src"
+  ],
+  "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/isEmpty/src/index.js b/packages/isEmpty/src/index.js
new file mode 100644
index 0000000..911c29e
--- /dev/null
+++ b/packages/isEmpty/src/index.js
@@ -0,0 +1,11 @@
+/**
+ * @description Checks whether the input text is empty
+ * @param {String} text
+ * @example
+ * isEmpty('') // returns true
+ * isEmpty('   ') // returns true
+ * isEmpty(' b  ') // returns false
+ */
+const isEmpty = text => /^\s*$/.test(text);
+
+export default isEmpty;
diff --git a/packages/plexis/package.json b/packages/plexis/package.json
index d0b0a0e..63baea8 100644
--- a/packages/plexis/package.json
+++ b/packages/plexis/package.json
@@ -47,7 +47,8 @@
     "@plexis/when": "^0.0.22",
     "@plexis/without-diacritics": "^0.0.22",
     "@plexis/without-html": "^0.0.22",
-    "@plexis/without-indent": "^0.0.22"
+    "@plexis/without-indent": "^0.0.22",
+    "@plexis/is-empty": "^0.0.22"
   },
   "keywords": [
     "utility",
diff --git a/packages/plexis/src/index.js b/packages/plexis/src/index.js
index 173a84c..2b9b287 100644
--- a/packages/plexis/src/index.js
+++ b/packages/plexis/src/index.js
@@ -68,5 +68,6 @@ export {
   default as isAlphaDigit
 } from '@plexis/is-alphanumeric';
 export {default as withoutHTML, default as removeHTML} from '@plexis/without-html';
+export {default as isEmpty} from '@plexis/is-empty';
 export {default as tail, default as rest, default as last, default as pop} from '@plexis/tail';
 export {default as toSwap, default as swap} from '@plexis/to-swap';


Test patch:
diff --git a/packages/includes/test/includes.test.js b/packages/includes/test/includes.test.js
index 27b24cd..f073fe3 100644
--- a/packages/includes/test/includes.test.js
+++ b/packages/includes/test/includes.test.js
@@ -30,7 +30,7 @@ describe('@plexis/isNumeric', () => {
   it('Second parameter as substring of first parameter, but substring has different casing', () => {
     expect(includes('Foo', 'Oo')).toBe(false);
   });
-  
+
   it('Second parameter as non string value', () => {
     expect(includes('Foo', false)).toBe(false);
   });
diff --git a/packages/isEmpty/test/index.js b/packages/isEmpty/test/index.js
new file mode 100644
index 0000000..2ffd493
--- /dev/null
+++ b/packages/isEmpty/test/index.js
@@ -0,0 +1,17 @@
+import isEmpty from '../src/';
+
+it('check empty string', () => {
+  expect(isEmpty('')).toBe(true);
+});
+
+it('check string with spaces', () => {
+  expect(isEmpty('  ')).toBe(true);
+});
+
+it('check string ith spaces and character', () => {
+  expect(isEmpty(' b  ')).toBe(false);
+});
+
+it('check string with characters', () => {
+  expect(isEmpty('Hello')).toBe(false);
+});
diff --git a/packages/plexis/test/__snapshots__/index.js.snap b/packages/plexis/test/__snapshots__/index.js.snap
index 64ed23f..35bec8d 100644
--- a/packages/plexis/test/__snapshots__/index.js.snap
+++ b/packages/plexis/test/__snapshots__/index.js.snap
@@ -71,6 +71,7 @@ Array [
   "isAlphaDigit",
   "withoutHTML",
   "removeHTML",
+  "isEmpty",
   "tail",
   "rest",
   "last",