array.prototype.flatmap
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -0,1 +1,7 @@ | ||
1.1.0 / 2017-10-03 | ||
================= | ||
* [New] add explicit setting of “length” on target array | ||
* [Fix] `FlattenIntoArray`: add assertion that `thisArg` and `mapperFunction` are both passed together | ||
* [Tests] make coverage required | ||
1.0.1 / 2017-10-02 | ||
@@ -2,0 +8,0 @@ ================= |
@@ -7,3 +7,3 @@ 'use strict'; | ||
// eslint-disable-next-line max-params, max-statements | ||
// eslint-disable-next-line max-params | ||
var FlattenIntoArray = function FlattenIntoArray(target, original, source, sourceLen, start, depth) { | ||
@@ -17,6 +17,2 @@ var targetIndex = start; | ||
} | ||
var thisArg; | ||
if (arguments.length > 7) { | ||
thisArg = arguments[7]; | ||
} | ||
@@ -29,3 +25,6 @@ while (sourceIndex < sourceLen) { | ||
if (typeof mapperFunction !== 'undefined') { | ||
element = ES.Call(mapperFunction, thisArg, [element, sourceIndex, original]); | ||
if (arguments.length <= 7) { | ||
throw new TypeError('Assertion failed: thisArg is required when mapperFunction is provided'); | ||
} | ||
element = ES.Call(mapperFunction, arguments[7], [element, sourceIndex, original]); | ||
} | ||
@@ -64,4 +63,5 @@ var spreadable = ES.IsArray(element); | ||
var A = ES.ArraySpeciesCreate(O, 0); | ||
FlattenIntoArray(A, O, O, sourceLen, 0, 1, callbackfn, T); | ||
var lastIndex = FlattenIntoArray(A, O, O, sourceLen, 0, 1, callbackfn, T); | ||
ES.Set(A, 'length', lastIndex + 1, true); | ||
return A; | ||
}; |
{ | ||
"name": "array.prototype.flatmap", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name": "Jordan Harband", |
@@ -33,2 +33,10 @@ 'use strict'; | ||
}); | ||
t.test('sparse arrays', function (st) { | ||
var identity = function (x) { return x; }; | ||
// eslint-disable-next-line no-sparse-arrays | ||
st.deepEqual(flatMap([, [1]], identity), flatMap([[], [1]], identity), 'an array hole is treated the same as an empty array'); | ||
st.end(); | ||
}); | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19220
157