mirror of
https://github.com/hanzoai/es5-ext.git
synced 2026-09-24 16:58:43 +00:00
refactor: update to new lint rules
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
if (!require('./is-implemented')()) {
|
||||
Object.defineProperty(Array.prototype, require('es6-symbol').iterator, { value: require('./shim'),
|
||||
configurable: true, enumerable: false, writable: true });
|
||||
if (!require("./is-implemented")()) {
|
||||
Object.defineProperty(Array.prototype, require("es6-symbol").iterator, { value: require("./shim"),
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true });
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = require('./is-implemented')()
|
||||
? Array.prototype[require('es6-symbol').iterator] : require('./shim');
|
||||
module.exports = require("./is-implemented")()
|
||||
? Array.prototype[require("es6-symbol").iterator] : require("./shim");
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var iteratorSymbol = require('es6-symbol').iterator;
|
||||
var iteratorSymbol = require("es6-symbol").iterator;
|
||||
|
||||
module.exports = function () {
|
||||
var arr = ['foo', 1], iterator, result;
|
||||
if (typeof arr[iteratorSymbol] !== 'function') return false;
|
||||
var arr = ["foo", 1], iterator, result;
|
||||
if (typeof arr[iteratorSymbol] !== "function") return false;
|
||||
iterator = arr[iteratorSymbol]();
|
||||
if (!iterator) return false;
|
||||
if (typeof iterator.next !== 'function') return false;
|
||||
if (typeof iterator.next !== "function") return false;
|
||||
result = iterator.next();
|
||||
if (!result) return false;
|
||||
if (result.value !== 'foo') return false;
|
||||
if (result.value !== "foo") return false;
|
||||
if (result.done !== false) return false;
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = require('../values/shim');
|
||||
module.exports = require("../values/shim");
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Used internally to sort array of lists by length
|
||||
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var toPosInt = require('../../number/to-pos-integer');
|
||||
var toPosInt = require("../../number/to-pos-integer");
|
||||
|
||||
module.exports = function (a, b) {
|
||||
return toPosInt(a.length) - toPosInt(b.length);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var toPosInt = require('../../number/to-pos-integer')
|
||||
, callable = require('../../object/valid-callable')
|
||||
, value = require('../../object/valid-value')
|
||||
var toPosInt = require("../../number/to-pos-integer")
|
||||
, callable = require("../../object/valid-callable")
|
||||
, value = require("../../object/valid-value")
|
||||
|
||||
, floor = Math.floor;
|
||||
|
||||
|
||||
+2
-2
@@ -2,9 +2,9 @@
|
||||
// http://closure-library.googlecode.com/svn/docs/
|
||||
// closure_goog_array_array.js.html#goog.array.clear
|
||||
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var value = require('../../object/valid-value');
|
||||
var value = require("../../object/valid-value");
|
||||
|
||||
module.exports = function () {
|
||||
value(this).length = 0;
|
||||
|
||||
+4
-2
@@ -1,9 +1,11 @@
|
||||
// Inspired by: http://documentcloud.github.com/underscore/#compact
|
||||
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var filter = Array.prototype.filter;
|
||||
|
||||
module.exports = function () {
|
||||
return filter.call(this, function (val) { return val != null; });
|
||||
return filter.call(this, function (val) {
|
||||
return val != null;
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
if (!require('./is-implemented')()) {
|
||||
Object.defineProperty(Array.prototype, 'concat', { value: require('./shim'),
|
||||
configurable: true, enumerable: false, writable: true });
|
||||
if (!require("./is-implemented")()) {
|
||||
Object.defineProperty(Array.prototype, "concat", { value: require("./shim"),
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true });
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = require('./is-implemented')() ?
|
||||
Array.prototype.concat : require('./shim');
|
||||
module.exports = require("./is-implemented")()
|
||||
? Array.prototype.concat : require("./shim");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var SubArray = require('../../_sub-array-dummy-safe');
|
||||
var SubArray = require("../../_sub-array-dummy-safe");
|
||||
|
||||
module.exports = function () {
|
||||
return (new SubArray()).concat('foo') instanceof SubArray;
|
||||
return (new SubArray()).concat("foo") instanceof SubArray;
|
||||
};
|
||||
|
||||
+11
-7
@@ -1,9 +1,9 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var isPlainArray = require('../../is-plain-array')
|
||||
, toPosInt = require('../../../number/to-pos-integer')
|
||||
, isObject = require('../../../object/is-object')
|
||||
, isConcatSpreadable = require('es6-symbol').isConcatSpreadable
|
||||
var isPlainArray = require("../../is-plain-array")
|
||||
, toPosInt = require("../../../number/to-pos-integer")
|
||||
, isObject = require("../../../object/is-object")
|
||||
, isConcatSpreadable = require("es6-symbol").isConcatSpreadable
|
||||
|
||||
, isArray = Array.isArray, concat = Array.prototype.concat
|
||||
, forEach = Array.prototype.forEach
|
||||
@@ -26,7 +26,9 @@ module.exports = function (item/*, …items*/) {
|
||||
}
|
||||
result = new this.constructor();
|
||||
if (isSpreadable(this)) {
|
||||
forEach.call(this, function (val, i) { result[i] = val; });
|
||||
forEach.call(this, function (val, i) {
|
||||
result[i] = val;
|
||||
});
|
||||
} else {
|
||||
result[0] = this;
|
||||
}
|
||||
@@ -35,7 +37,9 @@ module.exports = function (item/*, …items*/) {
|
||||
if (isSpreadable(arg)) {
|
||||
base = result.length;
|
||||
result.length += toPosInt(arg.length);
|
||||
forEach.call(arg, function (val, i) { result[base + i] = val; });
|
||||
forEach.call(arg, function (val, i) {
|
||||
result[base + i] = val;
|
||||
});
|
||||
return;
|
||||
}
|
||||
result.push(arg);
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var indexOf = require('./e-index-of');
|
||||
var indexOf = require("./e-index-of");
|
||||
|
||||
module.exports = function (searchElement/*, position*/) {
|
||||
return indexOf.call(this, searchElement, arguments[1]) > -1;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
if (!require('./is-implemented')()) {
|
||||
Object.defineProperty(Array.prototype, 'copyWithin',
|
||||
{ value: require('./shim'), configurable: true, enumerable: false,
|
||||
if (!require("./is-implemented")()) {
|
||||
Object.defineProperty(Array.prototype, "copyWithin",
|
||||
{ value: require("./shim"),
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true });
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = require('./is-implemented')() ?
|
||||
Array.prototype.copyWithin : require('./shim');
|
||||
module.exports = require("./is-implemented")()
|
||||
? Array.prototype.copyWithin : require("./shim");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = function () {
|
||||
var arr = [1, 2, 3, 4, 5];
|
||||
if (typeof arr.copyWithin !== 'function') return false;
|
||||
return String(arr.copyWithin(1, 3)) === '1,4,5,4,5';
|
||||
if (typeof arr.copyWithin !== "function") return false;
|
||||
return String(arr.copyWithin(1, 3)) === "1,4,5,4,5";
|
||||
};
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// Taken from: https://github.com/paulmillr/es6-shim/
|
||||
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var toInteger = require('../../../number/to-integer')
|
||||
, toPosInt = require('../../../number/to-pos-integer')
|
||||
, validValue = require('../../../object/valid-value')
|
||||
var toInteger = require("../../../number/to-integer")
|
||||
, toPosInt = require("../../../number/to-pos-integer")
|
||||
, validValue = require("../../../object/valid-value")
|
||||
|
||||
, hasOwnProperty = Object.prototype.hasOwnProperty
|
||||
, max = Math.max, min = Math.min;
|
||||
@@ -15,7 +15,7 @@ module.exports = function (target, start/*, end*/) {
|
||||
|
||||
target = toInteger(target);
|
||||
start = toInteger(start);
|
||||
end = (end === undefined) ? l : toInteger(end);
|
||||
end = end === undefined ? l : toInteger(end);
|
||||
|
||||
to = target < 0 ? max(l + target, 0) : min(target, l);
|
||||
from = start < 0 ? max(l + start, 0) : min(start, l);
|
||||
|
||||
+4
-4
@@ -1,12 +1,12 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var value = require('../../object/valid-value')
|
||||
, contains = require('./contains')
|
||||
var value = require("../../object/valid-value")
|
||||
, contains = require("./contains")
|
||||
|
||||
, filter = Array.prototype.filter;
|
||||
|
||||
module.exports = function (other) {
|
||||
(value(this) && value(other));
|
||||
value(this) && value(other);
|
||||
return filter.call(this, function (item) {
|
||||
return !contains.call(other, item);
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var toPosInt = require('../../number/to-pos-integer')
|
||||
, value = require('../../object/valid-value')
|
||||
var toPosInt = require("../../number/to-pos-integer")
|
||||
, value = require("../../object/valid-value")
|
||||
|
||||
, indexOf = Array.prototype.indexOf
|
||||
, hasOwnProperty = Object.prototype.hasOwnProperty
|
||||
@@ -9,7 +9,7 @@ var toPosInt = require('../../number/to-pos-integer')
|
||||
|
||||
module.exports = function (searchElement/*, fromIndex*/) {
|
||||
var i, l, fromIndex, val;
|
||||
if (searchElement === searchElement) { //jslint: ignore
|
||||
if (searchElement === searchElement) { // Jslint: ignore
|
||||
return indexOf.apply(this, arguments);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ module.exports = function (searchElement/*, fromIndex*/) {
|
||||
for (i = fromIndex; i < l; ++i) {
|
||||
if (hasOwnProperty.call(this, i)) {
|
||||
val = this[i];
|
||||
if (val !== val) return i; //jslint: ignore
|
||||
if (val !== val) return i; // Jslint: ignore
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var toPosInt = require('../../number/to-pos-integer')
|
||||
, value = require('../../object/valid-value')
|
||||
var toPosInt = require("../../number/to-pos-integer")
|
||||
, value = require("../../object/valid-value")
|
||||
|
||||
, lastIndexOf = Array.prototype.lastIndexOf
|
||||
, hasOwnProperty = Object.prototype.hasOwnProperty
|
||||
@@ -9,20 +9,20 @@ var toPosInt = require('../../number/to-pos-integer')
|
||||
|
||||
module.exports = function (searchElement/*, fromIndex*/) {
|
||||
var i, fromIndex, val;
|
||||
if (searchElement === searchElement) { //jslint: ignore
|
||||
if (searchElement === searchElement) { // Jslint: ignore
|
||||
return lastIndexOf.apply(this, arguments);
|
||||
}
|
||||
|
||||
value(this);
|
||||
fromIndex = arguments[1];
|
||||
if (isNaN(fromIndex)) fromIndex = (toPosInt(this.length) - 1);
|
||||
if (isNaN(fromIndex)) fromIndex = toPosInt(this.length) - 1;
|
||||
else if (fromIndex >= 0) fromIndex = floor(fromIndex);
|
||||
else fromIndex = toPosInt(this.length) - floor(abs(fromIndex));
|
||||
|
||||
for (i = fromIndex; i >= 0; --i) {
|
||||
if (hasOwnProperty.call(this, i)) {
|
||||
val = this[i];
|
||||
if (val !== val) return i; //jslint: ignore
|
||||
if (val !== val) return i; // Jslint: ignore
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
if (!require('./is-implemented')()) {
|
||||
Object.defineProperty(Array.prototype, 'entries', { value: require('./shim'),
|
||||
configurable: true, enumerable: false, writable: true });
|
||||
if (!require("./is-implemented")()) {
|
||||
Object.defineProperty(Array.prototype, "entries", { value: require("./shim"),
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true });
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = require('./is-implemented')() ?
|
||||
Array.prototype.entries : require('./shim');
|
||||
module.exports = require("./is-implemented")()
|
||||
? Array.prototype.entries : require("./shim");
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = function () {
|
||||
var arr = [1, 'foo'], iterator, result;
|
||||
if (typeof arr.entries !== 'function') return false;
|
||||
var arr = [1, "foo"], iterator, result;
|
||||
if (typeof arr.entries !== "function") return false;
|
||||
iterator = arr.entries();
|
||||
if (!iterator) return false;
|
||||
if (typeof iterator.next !== 'function') return false;
|
||||
if (typeof iterator.next !== "function") return false;
|
||||
result = iterator.next();
|
||||
if (!result || !result.value) return false;
|
||||
if (result.value[0] !== 0) return false;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var ArrayIterator = require('es6-iterator/array');
|
||||
module.exports = function () { return new ArrayIterator(this, 'key+value'); };
|
||||
var ArrayIterator = require("es6-iterator/array");
|
||||
module.exports = function () {
|
||||
return new ArrayIterator(this, "key+value");
|
||||
};
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var value = require('../../object/valid-value')
|
||||
, aFrom = require('../from')
|
||||
, toArray = require('../to-array')
|
||||
, contains = require('./contains')
|
||||
, byLength = require('./_compare-by-length')
|
||||
var value = require("../../object/valid-value")
|
||||
, aFrom = require("../from")
|
||||
, toArray = require("../to-array")
|
||||
, contains = require("./contains")
|
||||
, byLength = require("./_compare-by-length")
|
||||
|
||||
, filter = Array.prototype.filter, push = Array.prototype.push;
|
||||
|
||||
module.exports = function (/*…lists*/) {
|
||||
module.exports = function (/* …lists*/) {
|
||||
var lists, seen, result;
|
||||
if (!arguments.length) return aFrom(this);
|
||||
push.apply(lists = [this], arguments);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
if (!require('./is-implemented')()) {
|
||||
Object.defineProperty(Array.prototype, 'fill', { value: require('./shim'),
|
||||
configurable: true, enumerable: false, writable: true });
|
||||
if (!require("./is-implemented")()) {
|
||||
Object.defineProperty(Array.prototype, "fill", { value: require("./shim"),
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true });
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = require('./is-implemented')() ?
|
||||
Array.prototype.fill : require('./shim');
|
||||
module.exports = require("./is-implemented")()
|
||||
? Array.prototype.fill : require("./shim");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
"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';
|
||||
if (typeof arr.fill !== "function") return false;
|
||||
return String(arr.fill(-1, -3)) === "1,2,3,-1,-1,-1";
|
||||
};
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// Taken from: https://github.com/paulmillr/es6-shim/
|
||||
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var toInteger = require('../../../number/to-integer')
|
||||
, toPosInt = require('../../../number/to-pos-integer')
|
||||
, validValue = require('../../../object/valid-value')
|
||||
var toInteger = require("../../../number/to-integer")
|
||||
, toPosInt = require("../../../number/to-pos-integer")
|
||||
, validValue = require("../../../object/valid-value")
|
||||
|
||||
, max = Math.max, min = Math.min;
|
||||
|
||||
@@ -12,8 +12,8 @@ module.exports = function (value/*, start, end*/) {
|
||||
var o = validValue(this), start = arguments[1], end = arguments[2]
|
||||
, l = toPosInt(o.length), relativeStart, i;
|
||||
|
||||
start = (start === undefined) ? 0 : toInteger(start);
|
||||
end = (end === undefined) ? l : toInteger(end);
|
||||
start = start === undefined ? 0 : toInteger(start);
|
||||
end = end === undefined ? l : toInteger(end);
|
||||
|
||||
relativeStart = start < 0 ? max(l + start, 0) : min(start, l);
|
||||
for (i = relativeStart; i < l && i < end; ++i) o[i] = value;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
if (!require('./is-implemented')()) {
|
||||
Object.defineProperty(Array.prototype, 'filter', { value: require('./shim'),
|
||||
configurable: true, enumerable: false, writable: true });
|
||||
if (!require("./is-implemented")()) {
|
||||
Object.defineProperty(Array.prototype, "filter", { value: require("./shim"),
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true });
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = require('./is-implemented')() ?
|
||||
Array.prototype.filter : require('./shim');
|
||||
module.exports = require("./is-implemented")()
|
||||
? Array.prototype.filter : require("./shim");
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var SubArray = require('../../_sub-array-dummy-safe')
|
||||
var SubArray = require("../../_sub-array-dummy-safe")
|
||||
|
||||
, pass = function () { return true; };
|
||||
, pass = function () {
|
||||
return true;
|
||||
};
|
||||
|
||||
module.exports = function () {
|
||||
return (new SubArray()).filter(pass) instanceof SubArray;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var isPlainArray = require('../../is-plain-array')
|
||||
, callable = require('../../../object/valid-callable')
|
||||
var isPlainArray = require("../../is-plain-array")
|
||||
, callable = require("../../../object/valid-callable")
|
||||
|
||||
, isArray = Array.isArray, filter = Array.prototype.filter
|
||||
, forEach = Array.prototype.forEach, call = Function.prototype.call;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
if (!require('./is-implemented')()) {
|
||||
Object.defineProperty(Array.prototype, 'findIndex',
|
||||
{ value: require('./shim'),
|
||||
configurable: true, enumerable: false, writable: true });
|
||||
if (!require("./is-implemented")()) {
|
||||
Object.defineProperty(Array.prototype, "findIndex",
|
||||
{ value: require("./shim"),
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true });
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = require('./is-implemented')() ?
|
||||
Array.prototype.findIndex : require('./shim');
|
||||
module.exports = require("./is-implemented")()
|
||||
? Array.prototype.findIndex : require("./shim");
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var fn = function (x) { return x > 3; };
|
||||
var fn = function (x) {
|
||||
return x > 3;
|
||||
};
|
||||
|
||||
module.exports = function () {
|
||||
var arr = [1, 2, 3, 4, 5, 6];
|
||||
if (typeof arr.findIndex !== 'function') return false;
|
||||
if (typeof arr.findIndex !== "function") return false;
|
||||
return arr.findIndex(fn) === 3;
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var callable = require('../../../object/valid-callable')
|
||||
, value = require('../../../object/valid-value')
|
||||
var callable = require("../../../object/valid-callable")
|
||||
, value = require("../../../object/valid-value")
|
||||
|
||||
, some = Array.prototype.some, apply = Function.prototype.apply;
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
if (!require('./is-implemented')()) {
|
||||
Object.defineProperty(Array.prototype, 'find', { value: require('./shim'),
|
||||
configurable: true, enumerable: false, writable: true });
|
||||
if (!require("./is-implemented")()) {
|
||||
Object.defineProperty(Array.prototype, "find", { value: require("./shim"),
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true });
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = require('./is-implemented')() ?
|
||||
Array.prototype.find : require('./shim');
|
||||
module.exports = require("./is-implemented")()
|
||||
? Array.prototype.find : require("./shim");
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var fn = function (x) { return x > 3; };
|
||||
var fn = function (x) {
|
||||
return x > 3;
|
||||
};
|
||||
|
||||
module.exports = function () {
|
||||
var arr = [1, 2, 3, 4, 5, 6];
|
||||
if (typeof arr.find !== 'function') return false;
|
||||
if (typeof arr.find !== "function") return false;
|
||||
return arr.find(fn) === 4;
|
||||
};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var findIndex = require('../find-index/shim');
|
||||
var findIndex = require("../find-index/shim");
|
||||
|
||||
module.exports = function (predicate/*, thisArg*/) {
|
||||
var index = findIndex.apply(this, arguments);
|
||||
return (index === -1) ? undefined : this[index];
|
||||
return index === -1 ? undefined : this[index];
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var toPosInt = require('../../number/to-pos-integer')
|
||||
, value = require('../../object/valid-value')
|
||||
var toPosInt = require("../../number/to-pos-integer")
|
||||
, value = require("../../object/valid-value")
|
||||
|
||||
, hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var firstIndex = require('./first-index');
|
||||
var firstIndex = require("./first-index");
|
||||
|
||||
module.exports = function () {
|
||||
var i;
|
||||
|
||||
+3
-3
@@ -1,14 +1,14 @@
|
||||
// Stack grow safe implementation
|
||||
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var ensureValue = require('../../object/valid-value')
|
||||
var ensureValue = require("../../object/valid-value")
|
||||
|
||||
, isArray = Array.isArray, hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
|
||||
module.exports = function () {
|
||||
var input = ensureValue(this), index = 0, remaining, remainingIndexes, l, i, result = [];
|
||||
main: //jslint: ignore
|
||||
main: // Jslint: ignore
|
||||
while (input) {
|
||||
l = input.length;
|
||||
for (i = index; i < l; ++i) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var toPosInt = require('../../number/to-pos-integer')
|
||||
, callable = require('../../object/valid-callable')
|
||||
, value = require('../../object/valid-value')
|
||||
var toPosInt = require("../../number/to-pos-integer")
|
||||
, callable = require("../../object/valid-callable")
|
||||
, value = require("../../object/valid-value")
|
||||
|
||||
, hasOwnProperty = Object.prototype.hasOwnProperty
|
||||
, call = Function.prototype.call;
|
||||
@@ -14,7 +14,7 @@ module.exports = function (cb/*, thisArg*/) {
|
||||
callable(cb);
|
||||
thisArg = arguments[1];
|
||||
|
||||
for (i = (toPosInt(self.length) - 1); i >= 0; --i) {
|
||||
for (i = toPosInt(self.length) - 1; i >= 0; --i) {
|
||||
if (hasOwnProperty.call(self, i)) call.call(cb, thisArg, self[i], i, self);
|
||||
}
|
||||
};
|
||||
|
||||
+4
-4
@@ -1,17 +1,17 @@
|
||||
// Inspired by Underscore's groupBy:
|
||||
// http://documentcloud.github.com/underscore/#groupBy
|
||||
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var callable = require('../../object/valid-callable')
|
||||
, value = require('../../object/valid-value')
|
||||
var callable = require("../../object/valid-callable")
|
||||
, value = require("../../object/valid-value")
|
||||
|
||||
, forEach = Array.prototype.forEach, apply = Function.prototype.apply;
|
||||
|
||||
module.exports = function (cb/*, thisArg*/) {
|
||||
var r;
|
||||
|
||||
(value(this) && callable(cb));
|
||||
value(this) && callable(cb);
|
||||
|
||||
r = {};
|
||||
forEach.call(this, function (v) {
|
||||
|
||||
+37
-37
@@ -1,40 +1,40 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
'@@iterator': require('./@@iterator'),
|
||||
binarySearch: require('./binary-search'),
|
||||
clear: require('./clear'),
|
||||
compact: require('./compact'),
|
||||
concat: require('./concat'),
|
||||
contains: require('./contains'),
|
||||
copyWithin: require('./copy-within'),
|
||||
diff: require('./diff'),
|
||||
eIndexOf: require('./e-index-of'),
|
||||
eLastIndexOf: require('./e-last-index-of'),
|
||||
entries: require('./entries'),
|
||||
exclusion: require('./exclusion'),
|
||||
fill: require('./fill'),
|
||||
filter: require('./filter'),
|
||||
find: require('./find'),
|
||||
findIndex: require('./find-index'),
|
||||
first: require('./first'),
|
||||
firstIndex: require('./first-index'),
|
||||
flatten: require('./flatten'),
|
||||
forEachRight: require('./for-each-right'),
|
||||
keys: require('./keys'),
|
||||
group: require('./group'),
|
||||
indexesOf: require('./indexes-of'),
|
||||
intersection: require('./intersection'),
|
||||
isCopy: require('./is-copy'),
|
||||
isUniq: require('./is-uniq'),
|
||||
last: require('./last'),
|
||||
lastIndex: require('./last-index'),
|
||||
map: require('./map'),
|
||||
remove: require('./remove'),
|
||||
separate: require('./separate'),
|
||||
slice: require('./slice'),
|
||||
someRight: require('./some-right'),
|
||||
splice: require('./splice'),
|
||||
uniq: require('./uniq'),
|
||||
values: require('./values')
|
||||
"@@iterator": require("./@@iterator"),
|
||||
"binarySearch": require("./binary-search"),
|
||||
"clear": require("./clear"),
|
||||
"compact": require("./compact"),
|
||||
"concat": require("./concat"),
|
||||
"contains": require("./contains"),
|
||||
"copyWithin": require("./copy-within"),
|
||||
"diff": require("./diff"),
|
||||
"eIndexOf": require("./e-index-of"),
|
||||
"eLastIndexOf": require("./e-last-index-of"),
|
||||
"entries": require("./entries"),
|
||||
"exclusion": require("./exclusion"),
|
||||
"fill": require("./fill"),
|
||||
"filter": require("./filter"),
|
||||
"find": require("./find"),
|
||||
"findIndex": require("./find-index"),
|
||||
"first": require("./first"),
|
||||
"firstIndex": require("./first-index"),
|
||||
"flatten": require("./flatten"),
|
||||
"forEachRight": require("./for-each-right"),
|
||||
"keys": require("./keys"),
|
||||
"group": require("./group"),
|
||||
"indexesOf": require("./indexes-of"),
|
||||
"intersection": require("./intersection"),
|
||||
"isCopy": require("./is-copy"),
|
||||
"isUniq": require("./is-uniq"),
|
||||
"last": require("./last"),
|
||||
"lastIndex": require("./last-index"),
|
||||
"map": require("./map"),
|
||||
"remove": require("./remove"),
|
||||
"separate": require("./separate"),
|
||||
"slice": require("./slice"),
|
||||
"someRight": require("./some-right"),
|
||||
"splice": require("./splice"),
|
||||
"uniq": require("./uniq"),
|
||||
"values": require("./values")
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var indexOf = require('./e-index-of');
|
||||
var indexOf = require("./e-index-of");
|
||||
|
||||
module.exports = function (value/*, fromIndex*/) {
|
||||
var r = [], i, fromIndex = arguments[1];
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var value = require('../../object/valid-value')
|
||||
, contains = require('./contains')
|
||||
, byLength = require('./_compare-by-length')
|
||||
var value = require("../../object/valid-value")
|
||||
, contains = require("./contains")
|
||||
, byLength = require("./_compare-by-length")
|
||||
|
||||
, filter = Array.prototype.filter, push = Array.prototype.push
|
||||
, slice = Array.prototype.slice;
|
||||
|
||||
module.exports = function (/*…list*/) {
|
||||
module.exports = function (/* …list*/) {
|
||||
var lists;
|
||||
if (!arguments.length) slice.call(this);
|
||||
push.apply(lists = [this], arguments);
|
||||
lists.forEach(value);
|
||||
lists.sort(byLength);
|
||||
return lists.reduce(function (a, b) {
|
||||
return filter.call(a, function (x) { return contains.call(b, x); });
|
||||
return filter.call(a, function (x) {
|
||||
return contains.call(b, x);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
+5
-5
@@ -1,14 +1,14 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var toPosInt = require('../../number/to-pos-integer')
|
||||
, eq = require('../../object/eq')
|
||||
, value = require('../../object/valid-value')
|
||||
var toPosInt = require("../../number/to-pos-integer")
|
||||
, eq = require("../../object/eq")
|
||||
, value = require("../../object/valid-value")
|
||||
|
||||
, hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
|
||||
module.exports = function (other) {
|
||||
var i, l;
|
||||
(value(this) && value(other));
|
||||
value(this) && value(other);
|
||||
l = toPosInt(this.length);
|
||||
if (l !== toPosInt(other.length)) return false;
|
||||
for (i = 0; i < l; ++i) {
|
||||
|
||||
+5
-3
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var indexOf = require('./e-index-of')
|
||||
var indexOf = require("./e-index-of")
|
||||
|
||||
, every = Array.prototype.every
|
||||
, isFirst;
|
||||
@@ -9,4 +9,6 @@ isFirst = function (value, index) {
|
||||
return indexOf.call(this, value) === index;
|
||||
};
|
||||
|
||||
module.exports = function () { return every.call(this, isFirst, this); };
|
||||
module.exports = function () {
|
||||
return every.call(this, isFirst, this);
|
||||
};
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
if (!require('./is-implemented')()) {
|
||||
Object.defineProperty(Array.prototype, 'keys', { value: require('./shim'),
|
||||
configurable: true, enumerable: false, writable: true });
|
||||
if (!require("./is-implemented")()) {
|
||||
Object.defineProperty(Array.prototype, "keys", { value: require("./shim"),
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true });
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = require('./is-implemented')() ?
|
||||
Array.prototype.keys : require('./shim');
|
||||
module.exports = require("./is-implemented")()
|
||||
? Array.prototype.keys : require("./shim");
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = function () {
|
||||
var arr = [1, 'foo'], iterator, result;
|
||||
if (typeof arr.keys !== 'function') return false;
|
||||
var arr = [1, "foo"], iterator, result;
|
||||
if (typeof arr.keys !== "function") return false;
|
||||
iterator = arr.keys();
|
||||
if (!iterator) return false;
|
||||
if (typeof iterator.next !== 'function') return false;
|
||||
if (typeof iterator.next !== "function") return false;
|
||||
result = iterator.next();
|
||||
if (!result) return false;
|
||||
if (result.value !== 0) return false;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var ArrayIterator = require('es6-iterator/array');
|
||||
module.exports = function () { return new ArrayIterator(this, 'key'); };
|
||||
var ArrayIterator = require("es6-iterator/array");
|
||||
module.exports = function () {
|
||||
return new ArrayIterator(this, "key");
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var toPosInt = require('../../number/to-pos-integer')
|
||||
, value = require('../../object/valid-value')
|
||||
var toPosInt = require("../../number/to-pos-integer")
|
||||
, value = require("../../object/valid-value")
|
||||
|
||||
, hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var lastIndex = require('./last-index');
|
||||
var lastIndex = require("./last-index");
|
||||
|
||||
module.exports = function () {
|
||||
var i;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
if (!require('./is-implemented')()) {
|
||||
Object.defineProperty(Array.prototype, 'map', { value: require('./shim'),
|
||||
configurable: true, enumerable: false, writable: true });
|
||||
if (!require("./is-implemented")()) {
|
||||
Object.defineProperty(Array.prototype, "map", { value: require("./shim"),
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true });
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = require('./is-implemented')() ?
|
||||
Array.prototype.map : require('./shim');
|
||||
module.exports = require("./is-implemented")()
|
||||
? Array.prototype.map : require("./shim");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var identity = require('../../../function/identity')
|
||||
, SubArray = require('../../_sub-array-dummy-safe');
|
||||
var identity = require("../../../function/identity")
|
||||
, SubArray = require("../../_sub-array-dummy-safe");
|
||||
|
||||
module.exports = function () {
|
||||
return (new SubArray()).map(identity) instanceof SubArray;
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var isPlainArray = require('../../is-plain-array')
|
||||
, callable = require('../../../object/valid-callable')
|
||||
var isPlainArray = require("../../is-plain-array")
|
||||
, callable = require("../../../object/valid-callable")
|
||||
|
||||
, isArray = Array.isArray, map = Array.prototype.map
|
||||
, forEach = Array.prototype.forEach, call = Function.prototype.call;
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var indexOf = require('./e-index-of')
|
||||
var indexOf = require("./e-index-of")
|
||||
|
||||
, forEach = Array.prototype.forEach, splice = Array.prototype.splice;
|
||||
|
||||
|
||||
+4
-2
@@ -1,10 +1,12 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var forEach = Array.prototype.forEach;
|
||||
|
||||
module.exports = function (sep) {
|
||||
var result = [];
|
||||
forEach.call(this, function (val, i) { result.push(val, sep); });
|
||||
forEach.call(this, function (val, i) {
|
||||
result.push(val, sep);
|
||||
});
|
||||
result.pop();
|
||||
return result;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
if (!require('./is-implemented')()) {
|
||||
Object.defineProperty(Array.prototype, 'slice', { value: require('./shim'),
|
||||
configurable: true, enumerable: false, writable: true });
|
||||
if (!require("./is-implemented")()) {
|
||||
Object.defineProperty(Array.prototype, "slice", { value: require("./shim"),
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true });
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = require('./is-implemented')()
|
||||
? Array.prototype.slice : require('./shim');
|
||||
module.exports = require("./is-implemented")()
|
||||
? Array.prototype.slice : require("./shim");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var SubArray = require('../../_sub-array-dummy-safe');
|
||||
var SubArray = require("../../_sub-array-dummy-safe");
|
||||
|
||||
module.exports = function () {
|
||||
return (new SubArray()).slice() instanceof SubArray;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var toInteger = require('../../../number/to-integer')
|
||||
, toPosInt = require('../../../number/to-pos-integer')
|
||||
, isPlainArray = require('../../is-plain-array')
|
||||
var toInteger = require("../../../number/to-integer")
|
||||
, toPosInt = require("../../../number/to-pos-integer")
|
||||
, isPlainArray = require("../../is-plain-array")
|
||||
|
||||
, isArray = Array.isArray, slice = Array.prototype.slice
|
||||
, hasOwnProperty = Object.prototype.hasOwnProperty, max = Math.max;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var toPosInt = require('../../number/to-pos-integer')
|
||||
, callable = require('../../object/valid-callable')
|
||||
, value = require('../../object/valid-value')
|
||||
var toPosInt = require("../../number/to-pos-integer")
|
||||
, callable = require("../../object/valid-callable")
|
||||
, value = require("../../object/valid-value")
|
||||
|
||||
, hasOwnProperty = Object.prototype.hasOwnProperty
|
||||
, call = Function.prototype.call;
|
||||
@@ -13,7 +13,7 @@ module.exports = function (cb/*, thisArg*/) {
|
||||
callable(cb);
|
||||
thisArg = arguments[1];
|
||||
|
||||
for (i = (toPosInt(self.length) - 1); i >= 0; --i) {
|
||||
for (i = toPosInt(self.length) - 1; i >= 0; --i) {
|
||||
if (hasOwnProperty.call(self, i) &&
|
||||
call.call(cb, thisArg, self[i], i, self)) {
|
||||
return true;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
if (!require('./is-implemented')()) {
|
||||
Object.defineProperty(Array.prototype, 'splice', { value: require('./shim'),
|
||||
configurable: true, enumerable: false, writable: true });
|
||||
if (!require("./is-implemented")()) {
|
||||
Object.defineProperty(Array.prototype, "splice", { value: require("./shim"),
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true });
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = require('./is-implemented')()
|
||||
? Array.prototype.splice : require('./shim');
|
||||
module.exports = require("./is-implemented")()
|
||||
? Array.prototype.splice : require("./shim");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var SubArray = require('../../_sub-array-dummy-safe');
|
||||
var SubArray = require("../../_sub-array-dummy-safe");
|
||||
|
||||
module.exports = function () {
|
||||
return (new SubArray()).splice(0) instanceof SubArray;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var isPlainArray = require('../../is-plain-array')
|
||||
var isPlainArray = require("../../is-plain-array")
|
||||
|
||||
, isArray = Array.isArray, splice = Array.prototype.splice
|
||||
, forEach = Array.prototype.forEach;
|
||||
@@ -9,6 +9,8 @@ module.exports = function (start, deleteCount/*, …items*/) {
|
||||
var arr = splice.apply(this, arguments), result;
|
||||
if (!this || !isArray(this) || isPlainArray(this)) return arr;
|
||||
result = new this.constructor(arr.length);
|
||||
forEach.call(arr, function (val, i) { result[i] = val; });
|
||||
forEach.call(arr, function (val, i) {
|
||||
result[i] = val;
|
||||
});
|
||||
return result;
|
||||
};
|
||||
|
||||
+5
-3
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var indexOf = require('./e-index-of')
|
||||
var indexOf = require("./e-index-of")
|
||||
|
||||
, filter = Array.prototype.filter
|
||||
|
||||
@@ -10,4 +10,6 @@ isFirst = function (value, index) {
|
||||
return indexOf.call(this, value) === index;
|
||||
};
|
||||
|
||||
module.exports = function () { return filter.call(this, isFirst, this); };
|
||||
module.exports = function () {
|
||||
return filter.call(this, isFirst, this);
|
||||
};
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
if (!require('./is-implemented')()) {
|
||||
Object.defineProperty(Array.prototype, 'values', { value: require('./shim'),
|
||||
configurable: true, enumerable: false, writable: true });
|
||||
if (!require("./is-implemented")()) {
|
||||
Object.defineProperty(Array.prototype, "values", { value: require("./shim"),
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true });
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = require('./is-implemented')() ? Array.prototype.values : require('./shim');
|
||||
module.exports = require("./is-implemented")() ? Array.prototype.values : require("./shim");
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = function () {
|
||||
var arr = ['foo', 1], iterator, result;
|
||||
if (typeof arr.values !== 'function') return false;
|
||||
var arr = ["foo", 1], iterator, result;
|
||||
if (typeof arr.values !== "function") return false;
|
||||
iterator = arr.values();
|
||||
if (!iterator) return false;
|
||||
if (typeof iterator.next !== 'function') return false;
|
||||
if (typeof iterator.next !== "function") return false;
|
||||
result = iterator.next();
|
||||
if (!result) return false;
|
||||
if (result.value !== 'foo') return false;
|
||||
if (result.value !== "foo") return false;
|
||||
if (result.done !== false) return false;
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var ArrayIterator = require('es6-iterator/array');
|
||||
module.exports = function () { return new ArrayIterator(this, 'value'); };
|
||||
var ArrayIterator = require("es6-iterator/array");
|
||||
module.exports = function () {
|
||||
return new ArrayIterator(this, "value");
|
||||
};
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = (function () {
|
||||
var SubArray = require('./_sub-array-dummy'), arr;
|
||||
var SubArray = require("./_sub-array-dummy"), arr;
|
||||
|
||||
if (!SubArray) return false;
|
||||
arr = new SubArray();
|
||||
if (!Array.isArray(arr)) return false;
|
||||
if (!(arr instanceof SubArray)) return false;
|
||||
|
||||
arr[34] = 'foo';
|
||||
return (arr.length === 35);
|
||||
arr[34] = "foo";
|
||||
return arr.length === 35;
|
||||
}());
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var setPrototypeOf = require('../object/set-prototype-of')
|
||||
, isExtensible = require('./_is-extensible');
|
||||
var setPrototypeOf = require("../object/set-prototype-of")
|
||||
, isExtensible = require("./_is-extensible");
|
||||
|
||||
module.exports = (function () {
|
||||
var SubArray;
|
||||
|
||||
if (isExtensible) return require('./_sub-array-dummy');
|
||||
if (isExtensible) return require("./_sub-array-dummy");
|
||||
|
||||
if (!setPrototypeOf) return null;
|
||||
SubArray = function () {
|
||||
@@ -16,7 +16,9 @@ module.exports = (function () {
|
||||
};
|
||||
setPrototypeOf(SubArray, Array);
|
||||
SubArray.prototype = Object.create(Array.prototype, {
|
||||
constructor: { value: SubArray, enumerable: false, writable: true,
|
||||
constructor: { value: SubArray,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true }
|
||||
});
|
||||
return SubArray;
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var setPrototypeOf = require('../object/set-prototype-of');
|
||||
var setPrototypeOf = require("../object/set-prototype-of");
|
||||
|
||||
module.exports = (function () {
|
||||
var SubArray;
|
||||
|
||||
if (!setPrototypeOf) return null;
|
||||
SubArray = function () { Array.apply(this, arguments); };
|
||||
SubArray = function () {
|
||||
Array.apply(this, arguments);
|
||||
};
|
||||
setPrototypeOf(SubArray, Array);
|
||||
SubArray.prototype = Object.create(Array.prototype, {
|
||||
constructor: { value: SubArray, enumerable: false, writable: true,
|
||||
constructor: { value: SubArray,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true }
|
||||
});
|
||||
return SubArray;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
if (!require('./is-implemented')()) {
|
||||
Object.defineProperty(Array, 'from', { value: require('./shim'),
|
||||
configurable: true, enumerable: false, writable: true });
|
||||
if (!require("./is-implemented")()) {
|
||||
Object.defineProperty(Array, "from", { value: require("./shim"),
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true });
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = require('./is-implemented')()
|
||||
module.exports = require("./is-implemented")()
|
||||
? Array.from
|
||||
: require('./shim');
|
||||
: require("./shim");
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = function () {
|
||||
var from = Array.from, arr, result;
|
||||
if (typeof from !== 'function') return false;
|
||||
arr = ['raz', 'dwa'];
|
||||
if (typeof from !== "function") return false;
|
||||
arr = ["raz", "dwa"];
|
||||
result = from(arr);
|
||||
return Boolean(result && (result !== arr) && (result[1] === 'dwa'));
|
||||
return Boolean(result && (result !== arr) && (result[1] === "dwa"));
|
||||
};
|
||||
|
||||
+8
-8
@@ -1,12 +1,12 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var iteratorSymbol = require('es6-symbol').iterator
|
||||
, isArguments = require('../../function/is-arguments')
|
||||
, isFunction = require('../../function/is-function')
|
||||
, toPosInt = require('../../number/to-pos-integer')
|
||||
, callable = require('../../object/valid-callable')
|
||||
, validValue = require('../../object/valid-value')
|
||||
, isString = require('../../string/is-string')
|
||||
var iteratorSymbol = require("es6-symbol").iterator
|
||||
, isArguments = require("../../function/is-arguments")
|
||||
, isFunction = require("../../function/is-function")
|
||||
, toPosInt = require("../../number/to-pos-integer")
|
||||
, callable = require("../../object/valid-callable")
|
||||
, validValue = require("../../object/valid-value")
|
||||
, isString = require("../../string/is-string")
|
||||
|
||||
, isArray = Array.isArray, call = Function.prototype.call
|
||||
, desc = { configurable: true, enumerable: true, writable: true, value: null }
|
||||
|
||||
+5
-5
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var toPosInt = require('../number/to-pos-integer')
|
||||
, value = require('../object/valid-value')
|
||||
var toPosInt = require("../number/to-pos-integer")
|
||||
, value = require("../object/valid-value")
|
||||
|
||||
, slice = Array.prototype.slice;
|
||||
|
||||
@@ -10,8 +10,8 @@ module.exports = function (length/*, …fill*/) {
|
||||
length = toPosInt(value(length));
|
||||
if (length === 0) return [];
|
||||
|
||||
arr = (arguments.length < 2) ? [undefined] :
|
||||
slice.call(arguments, 1, 1 + length);
|
||||
arr = arguments.length < 2 ? [undefined]
|
||||
: slice.call(arguments, 1, 1 + length);
|
||||
|
||||
while ((l = arr.length) < length) {
|
||||
arr = arr.concat(arr.slice(0, length - l));
|
||||
|
||||
+8
-8
@@ -1,11 +1,11 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
'#': require('./#'),
|
||||
from: require('./from'),
|
||||
generate: require('./generate'),
|
||||
isPlainArray: require('./is-plain-array'),
|
||||
of: require('./of'),
|
||||
toArray: require('./to-array'),
|
||||
validArray: require('./valid-array')
|
||||
"#": require("./#"),
|
||||
"from": require("./from"),
|
||||
"generate": require("./generate"),
|
||||
"isPlainArray": require("./is-plain-array"),
|
||||
"of": require("./of"),
|
||||
"toArray": require("./to-array"),
|
||||
"validArray": require("./valid-array")
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var isArray = Array.isArray, getPrototypeOf = Object.getPrototypeOf;
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
if (!require('./is-implemented')()) {
|
||||
Object.defineProperty(Array, 'of', { value: require('./shim'),
|
||||
configurable: true, enumerable: false, writable: true });
|
||||
if (!require("./is-implemented")()) {
|
||||
Object.defineProperty(Array, "of", { value: require("./shim"),
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true });
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = require('./is-implemented')()
|
||||
module.exports = require("./is-implemented")()
|
||||
? Array.of
|
||||
: require('./shim');
|
||||
: require("./shim");
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = function () {
|
||||
var of = Array.of, result;
|
||||
if (typeof of !== 'function') return false;
|
||||
result = of('foo', 'bar');
|
||||
return Boolean(result && (result[1] === 'bar'));
|
||||
if (typeof of !== "function") return false;
|
||||
result = of("foo", "bar");
|
||||
return Boolean(result && (result[1] === "bar"));
|
||||
};
|
||||
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var isFunction = require('../../function/is-function')
|
||||
var isFunction = require("../../function/is-function")
|
||||
|
||||
, slice = Array.prototype.slice, defineProperty = Object.defineProperty
|
||||
, desc = { configurable: true, enumerable: true, writable: true, value: null };
|
||||
|
||||
module.exports = function (/*…items*/) {
|
||||
module.exports = function (/* …items*/) {
|
||||
var result, i, l;
|
||||
if (!this || (this === Array) || !isFunction(this)) return slice.call(arguments);
|
||||
result = new this(l = arguments.length);
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var from = require('./from')
|
||||
var from = require("./from")
|
||||
|
||||
, isArray = Array.isArray;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var isArray = Array.isArray;
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
isBoolean: require('./is-boolean')
|
||||
isBoolean: require("./is-boolean")
|
||||
};
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var toString = Object.prototype.toString
|
||||
|
||||
, id = toString.call(true);
|
||||
|
||||
module.exports = function (x) {
|
||||
return (typeof x === 'boolean') || ((typeof x === 'object') &&
|
||||
return (typeof x === "boolean") || ((typeof x === "object") &&
|
||||
((x instanceof Boolean) || (toString.call(x) === id)));
|
||||
};
|
||||
|
||||
+4
-2
@@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var getTime = Date.prototype.getTime;
|
||||
|
||||
module.exports = function () { return new Date(getTime.call(this)); };
|
||||
module.exports = function () {
|
||||
return new Date(getTime.call(this));
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var getMonth = Date.prototype.getMonth;
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var setHours = Date.prototype.setHours;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var floorDay = require('./floor-day');
|
||||
var floorDay = require("./floor-day");
|
||||
|
||||
module.exports = function () {
|
||||
floorDay.call(this).setDate(1);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var floorMonth = require('./floor-month');
|
||||
var floorMonth = require("./floor-month");
|
||||
|
||||
module.exports = function () {
|
||||
floorMonth.call(this).setMonth(0);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user