source: imaps-frontend/node_modules/array.prototype.flatmap/implementation.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 758 bytes
Line 
1'use strict';
2
3var ArraySpeciesCreate = require('es-abstract/2023/ArraySpeciesCreate');
4var FlattenIntoArray = require('es-abstract/2023/FlattenIntoArray');
5var Get = require('es-abstract/2023/Get');
6var IsCallable = require('es-abstract/2023/IsCallable');
7var ToLength = require('es-abstract/2023/ToLength');
8var ToObject = require('es-abstract/2023/ToObject');
9
10module.exports = function flatMap(mapperFunction) {
11 var O = ToObject(this);
12 var sourceLen = ToLength(Get(O, 'length'));
13
14 if (!IsCallable(mapperFunction)) {
15 throw new TypeError('mapperFunction must be a function');
16 }
17
18 var T;
19 if (arguments.length > 1) {
20 T = arguments[1];
21 }
22
23 var A = ArraySpeciesCreate(O, 0);
24 FlattenIntoArray(A, O, sourceLen, 0, 1, mapperFunction, T);
25 return A;
26};
Note: See TracBrowser for help on using the repository browser.