aboutsummaryrefslogtreecommitdiff
path: root/node_modules/es5-ext/array/#/fill
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-08-14 05:01:11 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-08-14 05:02:09 +0200
commit363723fc84f7b8477592e0105aeb331ec9a017af (patch)
tree29f92724f34131bac64d6a318dd7e30612e631c7 /node_modules/es5-ext/array/#/fill
parent5634e77ad96bfe1818f6b6ee70b7379652e5487f (diff)
node_modules
Diffstat (limited to 'node_modules/es5-ext/array/#/fill')
-rw-r--r--node_modules/es5-ext/array/#/fill/implement.js8
-rw-r--r--node_modules/es5-ext/array/#/fill/index.js4
-rw-r--r--node_modules/es5-ext/array/#/fill/is-implemented.js7
-rw-r--r--node_modules/es5-ext/array/#/fill/shim.js25
4 files changed, 44 insertions, 0 deletions
diff --git a/node_modules/es5-ext/array/#/fill/implement.js b/node_modules/es5-ext/array/#/fill/implement.js
new file mode 100644
index 000000000..9de58b75f
--- /dev/null
+++ b/node_modules/es5-ext/array/#/fill/implement.js
@@ -0,0 +1,8 @@
+"use strict";
+
+if (!require("./is-implemented")()) {
+ Object.defineProperty(Array.prototype, "fill", { value: require("./shim"),
+ configurable: true,
+enumerable: false,
+writable: true });
+}
diff --git a/node_modules/es5-ext/array/#/fill/index.js b/node_modules/es5-ext/array/#/fill/index.js
new file mode 100644
index 000000000..a8272475d
--- /dev/null
+++ b/node_modules/es5-ext/array/#/fill/index.js
@@ -0,0 +1,4 @@
+"use strict";
+
+module.exports = require("./is-implemented")()
+ ? Array.prototype.fill : require("./shim");
diff --git a/node_modules/es5-ext/array/#/fill/is-implemented.js b/node_modules/es5-ext/array/#/fill/is-implemented.js
new file mode 100644
index 000000000..5d6d02e1a
--- /dev/null
+++ b/node_modules/es5-ext/array/#/fill/is-implemented.js
@@ -0,0 +1,7 @@
+"use strict";
+
+module.exports = function () {
+ var arr = [1, 2, 3, 4, 5, 6];
+ if (typeof arr.fill !== "function") return false;
+ return String(arr.fill(-1, -3)) === "1,2,3,-1,-1,-1";
+};
diff --git a/node_modules/es5-ext/array/#/fill/shim.js b/node_modules/es5-ext/array/#/fill/shim.js
new file mode 100644
index 000000000..0040bf81a
--- /dev/null
+++ b/node_modules/es5-ext/array/#/fill/shim.js
@@ -0,0 +1,25 @@
+// Taken from: https://github.com/paulmillr/es6-shim/
+
+"use strict";
+
+var toInteger = require("../../../number/to-integer")
+ , toPosInt = require("../../../number/to-pos-integer")
+ , validValue = require("../../../object/valid-value")
+ , max = Math.max
+ , min = Math.min;
+
+module.exports = function (value /*, start, end*/) {
+ var arr = validValue(this)
+ , start = arguments[1]
+ , end = arguments[2]
+ , length = toPosInt(arr.length)
+ , relativeStart
+ , i;
+
+ start = start === undefined ? 0 : toInteger(start);
+ end = end === undefined ? length : toInteger(end);
+
+ relativeStart = start < 0 ? max(length + start, 0) : min(start, length);
+ for (i = relativeStart; i < length && i < end; ++i) arr[i] = value;
+ return arr;
+};