🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

array.prototype.flatmap

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array.prototype.flatmap - npm Package Compare versions

Comparing version

to
1.1.0

6

CHANGELOG.md

@@ -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 @@ =================

14

implementation.js

@@ -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