Repository: char0n/ramda-adjunct
Pull request #1539 (2020-07-27 05:02:11)

chore(deps-dev): bump dtslint from 3.6.13 to 3.6.14
Bumps [dtslint](https://github.com/Microsoft/dtslint) from 3.6.13 to 3.6.14.
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a href="https://github.com/Microsoft/dtslint/commits">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://api.dependabot.com/badges/compatibility_score?dependency-name=dtslint&package-manager=npm_and_yarn&previous-version=3.6.13&new-version=3.6.14)](https://dependabot.com/compatibility-score/?dependency-name=dtslint&package-manager=npm_and_yarn&previous-version=3.6.13&new-version=3.6.14)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme

Additionally, you can set the following in the `.dependabot/config.yml` file in this repo:
- Update frequency
- Out-of-range updates (receive only lockfile updates, if desired)
- Security updates (receive only security updates, if desired)



</details>


Patch:
diff --git a/package-lock.json b/package-lock.json
index 3b2ba97f33..b27033712b 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -4162,9 +4162,9 @@
       "dev": true
     },
     "@types/node": {
-      "version": "12.12.52",
-      "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.52.tgz",
-      "integrity": "sha512-oNJSI5bzuAH4f4I5JatPf4jytM6vQPWMw8JDOH68mNMyOmSqBkctHBfsyaBU3Su+dhYd8E+tDtPJWUXsyO5Msg==",
+      "version": "12.12.53",
+      "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.53.tgz",
+      "integrity": "sha512-51MYTDTyCziHb70wtGNFRwB4l+5JNvdqzFSkbDvpbftEgVUBEE+T5f7pROhWMp/fxp07oNIEQZd5bbfAH22ohQ==",
       "dev": true
     },
     "@types/normalize-package-data": {
@@ -7829,9 +7829,9 @@
       }
     },
     "dtslint": {
-      "version": "3.6.13",
-      "resolved": "https://registry.npmjs.org/dtslint/-/dtslint-3.6.13.tgz",
-      "integrity": "sha512-CoK4eRmO3cnQlLRP32jlfENAfHo8HzKKBmP8TKehq4jv9ms6Pft5+TdWvbnvUP8gqkm/ZIy8xRTRiC+f1SZ47w==",
+      "version": "3.6.14",
+      "resolved": "https://registry.npmjs.org/dtslint/-/dtslint-3.6.14.tgz",
+      "integrity": "sha512-L3W8tX6zLp4GzSSozNvuYBIyTJ7HWSRpyrRPWXFboZm35lG6J1/oKdeQ0nO+FhJPzYKniDL5bdSMOilHS/j02Q==",
       "dev": true,
       "requires": {
         "@definitelytyped/header-parser": "=0.0.41",
diff --git a/package.json b/package.json
index 41661bdc0e..d2dbc21451 100644
--- a/package.json
+++ b/package.json
@@ -154,7 +154,7 @@
     "codecov": "3.7.2",
     "conventional-changelog-cli": "2.0.34",
     "docdash": "git+https://github.com/char0n/docdash.git#534b44382138a55dd8d93642c979e51e46471185",
-    "dtslint": "=3.6.13",
+    "dtslint": "=3.6.14",
     "eslint": "7.5.0",
     "eslint-config-airbnb-base": "14.2.0",
     "eslint-config-prettier": "6.11.0",
diff --git a/src/index.js b/src/index.js
index 2b6d5edabc..ef18890add 100644
--- a/src/index.js
+++ b/src/index.js
@@ -206,6 +206,8 @@ export { default as sign } from './sign';
 export { default as subtractNum } from './subtractNum';
 export { default as toInteger32 } from './toInteger32';
 export { default as toInt32 } from './toInteger32'; // alias of toInteger32
+export { default as toUinteger32 } from './toUinteger32';
+export { default as toUint32 } from './toUinteger32'; // alias of to toUinteger32
 // String
 export { default as replaceAll } from './replaceAll';
 export { default as escapeRegExp } from './escapeRegExp';
diff --git a/src/toUinteger32.js b/src/toUinteger32.js
new file mode 100644
index 0000000000..d99b671b4d
--- /dev/null
+++ b/src/toUinteger32.js
@@ -0,0 +1,26 @@
+import { curryN } from 'ramda';
+
+/**
+ * Converts double-precision 64-bit binary format IEEE 754 to unsigned 32 bit integer number.
+ *
+ * @func toUinteger32
+ * @aliases toUint32
+ * @memberOf RA
+ * @since {@link https://char0n.github.io/ramda-adjunct/2.28.0|v2.28.0}
+ * @category Math
+ * @sig Number -> Number
+ * @param {number} val Value to be converted.
+ * @return {number}
+ * @see {@link RA.toInteger32|toInteger32}, {@link http://speakingjs.com/es5/ch11.html#integers_via_bitwise_operators}
+ * @example
+ *
+ * RA.toUinteger32(1.5); //=> 1
+ * RA.toInteger32(2 ** 35); // => 0
+ * RA.toInteger32(2 ** 31); // => 2147483648
+ * RA.toInteger32(2 ** 30); // => 1073741824
+ */
+
+// eslint-disable-next-line no-bitwise
+const toUinteger32 = curryN(1, (val) => val >>> 0);
+
+export default toUinteger32;
diff --git a/types/index.d.ts b/types/index.d.ts
index 98a49f1da4..6060e4ab59 100644
--- a/types/index.d.ts
+++ b/types/index.d.ts
@@ -1398,6 +1398,12 @@ declare namespace RamdaAdjunct {
          */
         toInteger32(n: number): number;
         toInt32(n: number): number; // alias
+
+        /**
+         * Converts double-precision 64-bit binary format IEEE 754 to unsigned 32 bit integer number.
+         */
+        toUinteger32(val: number): number;
+        toUint32(val: number): number; // alias
     }
 }
 


Test patch:
diff --git a/test/toUinteger32.js b/test/toUinteger32.js
new file mode 100644
index 0000000000..363e41e768
--- /dev/null
+++ b/test/toUinteger32.js
@@ -0,0 +1,86 @@
+import { assert } from 'chai';
+import * as R from 'ramda';
+
+import * as RA from '../src';
+
+describe('toUinteger32', function () {
+  context('given a floating point number', function () {
+    specify('should drop fraction', function () {
+      assert.strictEqual(RA.toUinteger32(123.456), 123);
+      assert.strictEqual(RA.toUinteger32(0.123456), 0);
+
+      assert.strictEqual(RA.toUint32(123.456), 123);
+      assert.strictEqual(RA.toUint32(0.12345), 0);
+    });
+
+    specify('should return an unsigned (non-negative) integer', function () {
+      assert.isAtLeast(RA.toUinteger32(-1.23456), 0);
+
+      assert.isAtLeast(RA.toUint32(-1.23456), 0);
+    });
+  });
+
+  context('given an integer', function () {
+    specify('should return the same value', function () {
+      assert.strictEqual(RA.toUinteger32(123), 123);
+      assert.strictEqual(RA.toUinteger32(0), 0);
+
+      assert.strictEqual(RA.toUint32(123), 123);
+      assert.strictEqual(RA.toUint32(0), 0);
+    });
+  });
+
+  context('given a non `number` type value', function () {
+    specify('should return an unsigned (non-negative) integer', function () {
+      assert.strictEqual(RA.toUinteger32(true), 1);
+      assert.strictEqual(RA.toUinteger32([1, 2, 3]), 0);
+      assert.strictEqual(RA.toUinteger32(Array.prototype.slice), 0);
+      assert.strictEqual(RA.toUinteger32({}), 0);
+      assert.strictEqual(RA.toUinteger32(/x/), 0);
+      assert.strictEqual(RA.toUinteger32(null), 0);
+      assert.strictEqual(RA.toUinteger32(NaN), 0);
+
+      assert.strictEqual(RA.toUint32(true), 1);
+      assert.strictEqual(RA.toUint32([1, 2, 3]), 0);
+      assert.strictEqual(RA.toUint32(Array.prototype.slice), 0);
+      assert.strictEqual(RA.toUint32({}), 0);
+      assert.strictEqual(RA.toUint32(/x/), 0);
+      assert.strictEqual(RA.toUint32(null), 0);
+      assert.strictEqual(RA.toUint32(NaN), 0);
+    });
+  });
+
+  context('given min or max floating point number', function () {
+    specify('should return 0', function () {
+      assert.strictEqual(RA.toUinteger32(Number.MIN_VALUE), 0);
+      assert.strictEqual(RA.toUinteger32(Number.MAX_VALUE), 0);
+
+      assert.strictEqual(RA.toUint32(Number.MIN_VALUE), 0);
+      assert.strictEqual(RA.toUint32(Number.MAX_VALUE), 0);
+    });
+  });
+
+  context('given infinity', function () {
+    specify('should return 0', function () {
+      assert.strictEqual(RA.toUinteger32(Infinity), 0);
+      assert.strictEqual(RA.toUinteger32(Number.POSITIVE_INFINITY), 0);
+      assert.strictEqual(RA.toUinteger32(Number.NEGATIVE_INFINITY), 0);
+
+      assert.strictEqual(RA.toUint32(Infinity), 0);
+      assert.strictEqual(RA.toUint32(Number.POSITIVE_INFINITY), 0);
+      assert.strictEqual(RA.toUint32(Number.NEGATIVE_INFINITY), 0);
+    });
+  });
+
+  it('should support placeholder to specify "gaps"', function () {
+    const toUinteger32 = RA.toUinteger32(R.__);
+
+    assert.strictEqual(toUinteger32(Infinity), 0);
+  });
+});
+
+describe('toUint32', function () {
+  it('should be an alias for toUinteger32', function () {
+    assert.strictEqual(RA.toUint32, RA.toUinteger32);
+  });
+});
diff --git a/types/test/toUinteger32.ts b/types/test/toUinteger32.ts
new file mode 100644
index 0000000000..9440bced34
--- /dev/null
+++ b/types/test/toUinteger32.ts
@@ -0,0 +1,26 @@
+import * as RA from 'ramda-adjunct';
+
+RA.toUinteger32(1); // $ExpectType number
+RA.toUinteger32(-1); // $ExpectType number
+RA.toUinteger32(Infinity); // $ExpectType number
+RA.toUinteger32(+Infinity); // $ExpectType number
+RA.toUinteger32(-Infinity); // $ExpectType number
+RA.toUinteger32(Number.MAX_VALUE); // $ExpectType number
+RA.toUinteger32(Number.MIN_VALUE); // $ExpectType number
+RA.toUinteger32(NaN); // $ExpectType number
+
+RA.toUint32(1); // $ExpectType number
+RA.toUint32(Infinity); // $ExpectType number
+RA.toUint32(+Infinity); // $ExpectType number
+RA.toUint32(-Infinity); // $ExpectType number
+RA.toUint32(Number.MAX_VALUE); // $ExpectType number
+RA.toUint32(Number.MIN_VALUE); // $ExpectType number
+RA.toUint32(NaN); // $ExpectType number
+
+RA.toUinteger32({}); // $ExpectError
+RA.toUinteger32([]); // $ExpectError
+RA.toUinteger32('a'); // $ExpectError
+
+RA.toUint32({}); // $ExpectError
+RA.toUint32([]); // $ExpectError
+RA.toUint32('a'); // $ExpectError