2 var getBuiltIn = require('../internals/get-built-in');
3 var aConstructor = require('../internals/a-constructor');
4 var arrayFromAsync = require('../internals/array-from-async');
5 var TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS = require('../internals/typed-array-constructors-require-wrappers');
6 var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
7 var arrayFromConstructorAndList = require('../internals/array-from-constructor-and-list');
9 var aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor;
10 var exportTypedArrayStaticMethod = ArrayBufferViewCore.exportTypedArrayStaticMethod;
12 // `%TypedArray%.fromAsync` method
13 // https://github.com/tc39/proposal-array-from-async
14 exportTypedArrayStaticMethod('fromAsync', function fromAsync(asyncItems /* , mapfn = undefined, thisArg = undefined */) {
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) {
21 resolve(arrayFromAsync(asyncItems, mapfn, thisArg));
22 }).then(function (list) {
23 return arrayFromConstructorAndList(aTypedArrayConstructor(C), list);
25 }, TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS);