Repository: char0n/ramda-adjunct
Pull request #912 (2019-05-07 11:33:36)

feat: adding isNotNilOrEmpty
Hey,

This PR  add `isNotNilOrEmpty` 

#70 



Patch:
diff --git a/package-lock.json b/package-lock.json
index 171b2a8adc..e33459e7fb 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1252,14 +1252,14 @@
       }
     },
     "@commitlint/cli": {
-      "version": "7.6.0",
-      "resolved": "https://registry.npmjs.org/@commitlint/cli/-/cli-7.6.0.tgz",
-      "integrity": "sha512-3n4qNS1xOIQcL2uLSo+aF8q79kt8qWFUqtVUrlsKsn4B++htJDav3Y2TPjbNXEZD2tO1kg1jfjNE8LLkrHTxqg==",
+      "version": "7.6.1",
+      "resolved": "https://registry.npmjs.org/@commitlint/cli/-/cli-7.6.1.tgz",
+      "integrity": "sha512-HEJwQ/aK0AOcAwn77ZKbb/GZhlGxBSPhtVp07uoJFVqM12l2Ia2JHA+MTpfHCFdVahKyYGREZgxde6LyKyG8aQ==",
       "dev": true,
       "requires": {
-        "@commitlint/format": "^7.6.0",
+        "@commitlint/format": "^7.6.1",
         "@commitlint/lint": "^7.6.0",
-        "@commitlint/load": "^7.6.0",
+        "@commitlint/load": "^7.6.1",
         "@commitlint/read": "^7.6.0",
         "babel-polyfill": "6.26.0",
         "chalk": "2.3.1",
@@ -1314,9 +1314,9 @@
       }
     },
     "@commitlint/format": {
-      "version": "7.6.0",
-      "resolved": "https://registry.npmjs.org/@commitlint/format/-/format-7.6.0.tgz",
-      "integrity": "sha512-Q/gFHImEfGSwp4bSX1ag6C/6GVuMf7KFh3BZIXk9dcbcQbNvyz/NgvS2p/FdZGp6dk8SghXfCiZHNlwNupgbnA==",
+      "version": "7.6.1",
+      "resolved": "https://registry.npmjs.org/@commitlint/format/-/format-7.6.1.tgz",
+      "integrity": "sha512-Ldzf5N2Sr9RQqvlYwaQn4vz1WOZ7byYinspC/WCrbfcETGy28j7QE4OueZU6nNB9TjwwEorKm13uy7tDWPR7dg==",
       "dev": true,
       "requires": {
         "babel-runtime": "^6.23.0",
@@ -1354,9 +1354,9 @@
       }
     },
     "@commitlint/load": {
-      "version": "7.6.0",
-      "resolved": "https://registry.npmjs.org/@commitlint/load/-/load-7.6.0.tgz",
-      "integrity": "sha512-MNuemmf8ag7hLwypmmvTBLU9W2scTGRB1RfB59MHVG3surLZS/LB5nUgoCHIeAz2KG4W/T4HXJ3G3Yaiw7ML6Q==",
+      "version": "7.6.2",
+      "resolved": "https://registry.npmjs.org/@commitlint/load/-/load-7.6.2.tgz",
+      "integrity": "sha512-I+xk+BkXAG1roXNrPsR1eOd5hEa+oLc6HLYnHAT/HLGKKB3E01IGg3O5SGlg7lpf1yiAaYI+wAnNTr3f3sIbWQ==",
       "dev": true,
       "requires": {
         "@commitlint/execute-rule": "^7.6.0",
@@ -1981,11 +1981,12 @@
       }
     },
     "assert": {
-      "version": "1.4.1",
-      "resolved": "https://registry.npmjs.org/assert/-/assert-1.4.1.tgz",
-      "integrity": "sha1-mZEtWRg2tab1s0XA8H7vwI/GXZE=",
+      "version": "1.5.0",
+      "resolved": "https://registry.npmjs.org/assert/-/assert-1.5.0.tgz",
+      "integrity": "sha512-EDsgawzwoun2CZkCgtxJbv392v4nbk9XDD06zI+kQYoBM/3RBWLlEyJARDOmhAAosBjWACEkKL6S+lIZtcAubA==",
       "dev": true,
       "requires": {
+        "object-assign": "^4.1.1",
         "util": "0.10.3"
       },
       "dependencies": {
@@ -1997,7 +1998,7 @@
         },
         "util": {
           "version": "0.10.3",
-          "resolved": "http://registry.npmjs.org/util/-/util-0.10.3.tgz",
+          "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz",
           "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=",
           "dev": true,
           "requires": {
@@ -2522,7 +2523,7 @@
     },
     "browserify-aes": {
       "version": "1.2.0",
-      "resolved": "http://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz",
+      "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz",
       "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==",
       "dev": true,
       "requires": {
@@ -2559,7 +2560,7 @@
     },
     "browserify-rsa": {
       "version": "4.0.1",
-      "resolved": "http://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz",
+      "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz",
       "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=",
       "dev": true,
       "requires": {
@@ -2604,7 +2605,7 @@
     },
     "buffer": {
       "version": "4.9.1",
-      "resolved": "http://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz",
+      "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz",
       "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=",
       "dev": true,
       "requires": {
@@ -3395,7 +3396,7 @@
         },
         "minimist": {
           "version": "1.2.0",
-          "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
+          "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
           "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
           "dev": true
         },
@@ -3609,7 +3610,7 @@
     },
     "create-hash": {
       "version": "1.2.0",
-      "resolved": "http://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz",
+      "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz",
       "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==",
       "dev": true,
       "requires": {
@@ -3622,7 +3623,7 @@
     },
     "create-hmac": {
       "version": "1.1.7",
-      "resolved": "http://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz",
+      "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz",
       "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==",
       "dev": true,
       "requires": {
@@ -3908,7 +3909,7 @@
     },
     "diffie-hellman": {
       "version": "5.0.3",
-      "resolved": "http://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz",
+      "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz",
       "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==",
       "dev": true,
       "requires": {
@@ -6045,7 +6046,7 @@
         },
         "minimist": {
           "version": "1.2.0",
-          "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
+          "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
           "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
           "dev": true
         },
@@ -6256,7 +6257,7 @@
         },
         "minimist": {
           "version": "1.2.0",
-          "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
+          "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
           "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
           "dev": true
         }
@@ -7709,7 +7710,7 @@
       "dependencies": {
         "minimist": {
           "version": "1.2.0",
-          "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
+          "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
           "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
           "dev": true
         }
@@ -9541,7 +9542,7 @@
     },
     "path-browserify": {
       "version": "0.0.0",
-      "resolved": "http://registry.npmjs.org/path-browserify/-/path-browserify-0.0.0.tgz",
+      "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.0.tgz",
       "integrity": "sha1-oLhwcpquIUAFt9UDLsLLuw+0RRo=",
       "dev": true
     },
@@ -10435,7 +10436,7 @@
     },
     "sha.js": {
       "version": "2.4.11",
-      "resolved": "http://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz",
+      "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz",
       "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==",
       "dev": true,
       "requires": {
@@ -11134,16 +11135,6 @@
           "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
           "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
           "dev": true
-        },
-        "source-map-support": {
-          "version": "0.5.12",
-          "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.12.tgz",
-          "integrity": "sha512-4h2Pbvyy15EE02G+JOZpUCmqWJuqrs+sEkzewTm++BPi7Hvn/HwcqLAcNxYAyI0x13CpPPn+kMjl+hplXMHITQ==",
-          "dev": true,
-          "requires": {
-            "buffer-from": "^1.0.0",
-            "source-map": "^0.6.0"
-          }
         }
       }
     },
@@ -11471,7 +11462,7 @@
     },
     "tty-browserify": {
       "version": "0.0.0",
-      "resolved": "http://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz",
+      "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz",
       "integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=",
       "dev": true
     },
@@ -11931,7 +11922,7 @@
     },
     "vm-browserify": {
       "version": "0.0.4",
-      "resolved": "http://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz",
+      "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz",
       "integrity": "sha1-XX6kW7755Kb/ZflUOOCofDV9WnM=",
       "dev": true,
       "requires": {
@@ -11950,9 +11941,9 @@
       }
     },
     "webpack": {
-      "version": "4.30.0",
-      "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.30.0.tgz",
-      "integrity": "sha512-4hgvO2YbAFUhyTdlR4FNyt2+YaYBYHavyzjCMbZzgglo02rlKi/pcsEzwCuCpsn1ryzIl1cq/u8ArIKu8JBYMg==",
+      "version": "4.31.0",
+      "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.31.0.tgz",
+      "integrity": "sha512-n6RVO3X0LbbipoE62akME9K/JI7qYrwwufs20VvgNNpqUoH4860KkaxJTbGq5bgkVZF9FqyyTG/0WPLH3PVNJA==",
       "dev": true,
       "requires": {
         "@webassemblyjs/ast": "1.8.5",
diff --git a/package.json b/package.json
index 4d24d8378e..8957f195b9 100644
--- a/package.json
+++ b/package.json
@@ -139,7 +139,7 @@
     "@babel/polyfill": "7.4.4",
     "@babel/preset-env": "7.4.4",
     "@babel/register": "7.4.4",
-    "@commitlint/cli": "7.6.0",
+    "@commitlint/cli": "7.6.1",
     "@commitlint/config-conventional": "7.3.1",
     "@commitlint/config-conventional": "7.6.0",
     "babel-loader": "8.0.5",
@@ -181,7 +181,7 @@
     "typescript": "=3.2.2",
     "typescript-definition-tester": "0.0.6",
     "uglifyjs-webpack-plugin": "2.1.2",
-    "webpack": "4.30.0",
+    "webpack": "4.31.0",
     "webpack-cli": "3.3.2"
   },
   "browserslist": "> 0.25%, ie 10, ie 11, not op_mini all",
diff --git a/src/index.d.ts b/src/index.d.ts
index d2d7f78759..582d356c0b 100644
--- a/src/index.d.ts
+++ b/src/index.d.ts
@@ -61,6 +61,11 @@ declare namespace RamdaAdjunct {
          */
         isNilOrEmpty(val: any): boolean;
 
+        /**
+         * Returns `true` if the given value is not its type's empty value, nor `null` nor `undefined`.
+         */
+        isNotNilOrEmpty(val: any): boolean;
+
         /**
          * Checks if input value is complement of `Array`.
          */
diff --git a/src/index.js b/src/index.js
index 5885d13236..c51f48584d 100644
--- a/src/index.js
+++ b/src/index.js
@@ -48,6 +48,7 @@ export { default as isNumber } from './isNumber';
 export { default as isNotNumber } from './isNotNumber';
 export { default as isPositive } from './isPositive';
 export { default as isNegative } from './isNegative';
+export { default as isNotNilOrEmpty } from './isNotNilOrEmpty';
 export { default as isNonPositive } from './isNonPositive';
 export { default as isNonNegative } from './isNonNegative';
 export { default as isNaN } from './isNaN';
diff --git a/src/isNotNilOrEmpty.js b/src/isNotNilOrEmpty.js
new file mode 100644
index 0000000000..eb8c69b626
--- /dev/null
+++ b/src/isNotNilOrEmpty.js
@@ -0,0 +1,28 @@
+import { complement } from 'ramda';
+
+import isNilOrEmpty from './isNilOrEmpty';
+
+/**
+ * Returns `true` if the given value is its type's empty value, `null` or `undefined`.
+ *
+ * @func isNotNilOrEmpty
+ * @memberOf RA
+ * @since {@link https://char0n.github.io/ramda-adjunct/2.18.0|v2.18.0}
+ * @category Type
+ * @sig * -> Boolean
+ * @param {*} val The value to test
+ * @return {boolean}
+ * @see {@link RA.isNilOrEmpty|isNilOrEmpty}
+ * @example
+ *
+ * RA.isNotNilOrEmpty([1, 2, 3]); //=> true
+ * RA.isNotNilOrEmpty([]); //=> false
+ * RA.isNotNilOrEmpty(''); //=> false
+ * RA.isNotNilOrEmpty(null); //=> false
+ * RA.isNotNilOrEmpty(undefined): //=> false
+ * RA.isNotNilOrEmpty({}); //=> false
+ * RA.isNotNilOrEmpty({length: 0}); //=> true
+ */
+const isNotNilOrEmpty = complement(isNilOrEmpty);
+
+export default isNotNilOrEmpty;


Test patch:
diff --git a/test/isNotNilOrEmpty.js b/test/isNotNilOrEmpty.js
new file mode 100644
index 0000000000..2736d6b402
--- /dev/null
+++ b/test/isNotNilOrEmpty.js
@@ -0,0 +1,102 @@
+import { assert } from 'chai';
+import * as R from 'ramda';
+
+import * as RA from '../src';
+
+describe('isNotNilOrEmpty', function() {
+  it('should test value for `null` or `undefined`', function() {
+    assert.isFalse(RA.isNotNilOrEmpty(void 0));
+    assert.isFalse(RA.isNotNilOrEmpty(null));
+    assert.isFalse(RA.isNotNilOrEmpty([]));
+    assert.isFalse(RA.isNotNilOrEmpty({}));
+    assert.isTrue(RA.isNotNilOrEmpty(0));
+    assert.isFalse(RA.isNotNilOrEmpty(''));
+  });
+
+  context('given null', function() {
+    specify('should return false', function() {
+      assert.isFalse(RA.isNotNilOrEmpty(null));
+    });
+  });
+
+  context('given undefined', function() {
+    specify('should return false', function() {
+      assert.isFalse(RA.isNotNilOrEmpty(undefined));
+    });
+  });
+
+  context('given empty string', function() {
+    specify('should return false', function() {
+      assert.isFalse(RA.isNotNilOrEmpty(''));
+    });
+  });
+
+  context('given string with space character', function() {
+    specify('should return true', function() {
+      assert.isTrue(RA.isNotNilOrEmpty(' '));
+    });
+  });
+
+  context('given empty array', function() {
+    specify('should return false', function() {
+      assert.isFalse(RA.isNotNilOrEmpty([]));
+    });
+
+    context('with another empty array inside it', function() {
+      specify('should return true', function() {
+        assert.isTrue(RA.isNotNilOrEmpty([[]]));
+      });
+    });
+  });
+
+  context('given empty object literal', function() {
+    specify('should return false', function() {
+      assert.isFalse(RA.isNotNilOrEmpty({}));
+    });
+  });
+
+  context('given empty object', function() {
+    context('and the empty object was created with Object.create', function() {
+      specify('should return false', function() {
+        assert.isFalse(RA.isNotNilOrEmpty(Object.create({})));
+        assert.isFalse(RA.isNotNilOrEmpty(Object.create(null)));
+      });
+    });
+  });
+
+  context('given arguments object', function() {
+    context('and the arguments object is empty', function() {
+      specify('should return false', function() {
+        assert.isFalse(
+          RA.isNotNilOrEmpty(
+            (function() {
+              return arguments;
+            })()
+          )
+        );
+      });
+    });
+
+    context('and the arguments object has one or more property', function() {
+      assert.isTrue(
+        RA.isNotNilOrEmpty(
+          (function() {
+            return arguments;
+          })(0)
+        )
+      );
+    });
+  });
+
+  it('should return true for every other value', function() {
+    assert.isTrue(RA.isNotNilOrEmpty(0));
+    assert.isTrue(RA.isNotNilOrEmpty(NaN));
+    assert.isTrue(RA.isNotNilOrEmpty(['']));
+  });
+
+  it('should support placeholder to specify "gaps"', function() {
+    const isNotNilOrEmpty = RA.isNotNilOrEmpty(R.__);
+
+    assert.isFalse(isNotNilOrEmpty({}));
+  });
+});