1 | 'use strict';
|
2 |
|
3 | var getBuiltIn = require('../internals/get-built-in');
|
4 | var aConstructor = require('../internals/a-constructor');
|
5 | var arrayFromAsync = require('../internals/array-from-async');
|
6 | var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
|
7 | var arrayFromConstructorAndList = require('../internals/array-from-constructor-and-list');
|
8 |
|
9 | var aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor;
|
10 | var exportTypedArrayStaticMethod = ArrayBufferViewCore.exportTypedArrayStaticMethod;
|
11 |
|
12 |
|
13 |
|
14 | exportTypedArrayStaticMethod('fromAsync', function fromAsync(asyncItems /* , mapfn = undefined, thisArg = undefined */) {
|
15 | var C = this;
|
16 | var argumentsLength = arguments.length;
|
17 | var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
|
18 | var thisArg = argumentsLength > 2 ? arguments[2] : undefined;
|
19 | return new (getBuiltIn('Promise'))(function (resolve) {
|
20 | aConstructor(C);
|
21 | resolve(arrayFromAsync(asyncItems, mapfn, thisArg));
|
22 | }).then(function (list) {
|
23 | return arrayFromConstructorAndList(aTypedArrayConstructor(C), list);
|
24 | });
|
25 | }, true);
|