aboutsummaryrefslogtreecommitdiff
path: root/node_modules/es5-ext/math/trunc
diff options
context:
space:
mode:
authorruki <waruqi@gmail.com>2018-11-08 00:38:48 +0800
committerruki <waruqi@gmail.com>2018-11-07 21:53:09 +0800
commit26105034da4fcce7ac883c899d781f016559310d (patch)
treec459a5dc4e3aa0972d9919033ece511ce76dd129 /node_modules/es5-ext/math/trunc
parent2c77f00f1a7ecb6c8192f9c16d3b2001b254a107 (diff)
downloadxmake-docs-26105034da4fcce7ac883c899d781f016559310d.tar.gz
xmake-docs-26105034da4fcce7ac883c899d781f016559310d.zip
switch to vuepress
Diffstat (limited to 'node_modules/es5-ext/math/trunc')
-rw-r--r--node_modules/es5-ext/math/trunc/implement.js8
-rw-r--r--node_modules/es5-ext/math/trunc/index.js5
-rw-r--r--node_modules/es5-ext/math/trunc/is-implemented.js7
-rw-r--r--node_modules/es5-ext/math/trunc/shim.js13
4 files changed, 33 insertions, 0 deletions
diff --git a/node_modules/es5-ext/math/trunc/implement.js b/node_modules/es5-ext/math/trunc/implement.js
new file mode 100644
index 00000000..1ecc124c
--- /dev/null
+++ b/node_modules/es5-ext/math/trunc/implement.js
@@ -0,0 +1,8 @@
+"use strict";
+
+if (!require("./is-implemented")()) {
+ Object.defineProperty(Math, "trunc", { value: require("./shim"),
+ configurable: true,
+enumerable: false,
+writable: true });
+}
diff --git a/node_modules/es5-ext/math/trunc/index.js b/node_modules/es5-ext/math/trunc/index.js
new file mode 100644
index 00000000..94c02691
--- /dev/null
+++ b/node_modules/es5-ext/math/trunc/index.js
@@ -0,0 +1,5 @@
+"use strict";
+
+module.exports = require("./is-implemented")()
+ ? Math.trunc
+ : require("./shim");
diff --git a/node_modules/es5-ext/math/trunc/is-implemented.js b/node_modules/es5-ext/math/trunc/is-implemented.js
new file mode 100644
index 00000000..b1507352
--- /dev/null
+++ b/node_modules/es5-ext/math/trunc/is-implemented.js
@@ -0,0 +1,7 @@
+"use strict";
+
+module.exports = function () {
+ var trunc = Math.trunc;
+ if (typeof trunc !== "function") return false;
+ return (trunc(13.67) === 13) && (trunc(-13.67) === -13);
+};
diff --git a/node_modules/es5-ext/math/trunc/shim.js b/node_modules/es5-ext/math/trunc/shim.js
new file mode 100644
index 00000000..bf6ac8cc
--- /dev/null
+++ b/node_modules/es5-ext/math/trunc/shim.js
@@ -0,0 +1,13 @@
+"use strict";
+
+var floor = Math.floor;
+
+module.exports = function (value) {
+ if (isNaN(value)) return NaN;
+ value = Number(value);
+ if (value === 0) return value;
+ if (value === Infinity) return Infinity;
+ if (value === -Infinity) return -Infinity;
+ if (value > 0) return floor(value);
+ return -floor(-value);
+};