Skip to content

Commit

Permalink
[Fix] Move the receiver length check higher
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Dec 9, 2017
1 parent 8b800d0 commit da2f629
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion implementation.js
Expand Up @@ -46,6 +46,8 @@ var FlattenIntoArray = function FlattenIntoArray(target, original, source, sourc

module.exports = function flatMap(callbackfn) {
var O = ES.ToObject(this);
var sourceLen = ES.ToLength(ES.Get(O, 'length'));

if (!ES.IsCallable(callbackfn)) {
throw new TypeError('callback must be a function');
}
Expand All @@ -55,7 +57,6 @@ module.exports = function flatMap(callbackfn) {
T = arguments[1];
}

var sourceLen = ES.ToLength(ES.Get(O, 'length'));
var A = ES.ArraySpeciesCreate(O, 0);
var nextIndex = FlattenIntoArray(A, O, O, sourceLen, 0, 1, callbackfn, T);
ES.Set(A, 'length', nextIndex, true);
Expand Down

0 comments on commit da2f629

Please sign in to comment.