aboutsummaryrefslogtreecommitdiff
path: root/node_modules/lodash/toInteger.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/lodash/toInteger.js')
-rw-r--r--node_modules/lodash/toInteger.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/node_modules/lodash/toInteger.js b/node_modules/lodash/toInteger.js
new file mode 100644
index 0000000..c6aadf8
--- /dev/null
+++ b/node_modules/lodash/toInteger.js
@@ -0,0 +1,36 @@
+var toFinite = require('./toFinite');
+
+/**
+ * Converts `value` to an integer.
+ *
+ * **Note:** This method is loosely based on
+ * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to convert.
+ * @returns {number} Returns the converted integer.
+ * @example
+ *
+ * _.toInteger(3.2);
+ * // => 3
+ *
+ * _.toInteger(Number.MIN_VALUE);
+ * // => 0
+ *
+ * _.toInteger(Infinity);
+ * // => 1.7976931348623157e+308
+ *
+ * _.toInteger('3.2');
+ * // => 3
+ */
+function toInteger(value) {
+ var result = toFinite(value),
+ remainder = result % 1;
+
+ return result === result ? (remainder ? result - remainder : result) : 0;
+}
+
+module.exports = toInteger;