UNPKG

708 BJavaScriptView Raw
1'use strict';
2var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
3var $map = require('../internals/array-iteration').map;
4var typedArraySpeciesConstructor = require('../internals/typed-array-species-constructor');
5
6var aTypedArray = ArrayBufferViewCore.aTypedArray;
7var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
8
9// `%TypedArray%.prototype.map` method
10// https://tc39.es/ecma262/#sec-%typedarray%.prototype.map
11exportTypedArrayMethod('map', function map(mapfn /* , thisArg */) {
12 return $map(aTypedArray(this), mapfn, arguments.length > 1 ? arguments[1] : undefined, function (O, length) {
13 return new (typedArraySpeciesConstructor(O))(length);
14 });
15});