esnext.async-iterator.constructor.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. 'use strict';
  2. var $ = require('../internals/export');
  3. var anInstance = require('../internals/an-instance');
  4. var getPrototypeOf = require('../internals/object-get-prototype-of');
  5. var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
  6. var hasOwn = require('../internals/has-own-property');
  7. var wellKnownSymbol = require('../internals/well-known-symbol');
  8. var AsyncIteratorPrototype = require('../internals/async-iterator-prototype');
  9. var IS_PURE = require('../internals/is-pure');
  10. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  11. var $TypeError = TypeError;
  12. var AsyncIteratorConstructor = function AsyncIterator() {
  13. anInstance(this, AsyncIteratorPrototype);
  14. if (getPrototypeOf(this) === AsyncIteratorPrototype) throw new $TypeError('Abstract class AsyncIterator not directly constructable');
  15. };
  16. AsyncIteratorConstructor.prototype = AsyncIteratorPrototype;
  17. if (!hasOwn(AsyncIteratorPrototype, TO_STRING_TAG)) {
  18. createNonEnumerableProperty(AsyncIteratorPrototype, TO_STRING_TAG, 'AsyncIterator');
  19. }
  20. if (IS_PURE || !hasOwn(AsyncIteratorPrototype, 'constructor') || AsyncIteratorPrototype.constructor === Object) {
  21. createNonEnumerableProperty(AsyncIteratorPrototype, 'constructor', AsyncIteratorConstructor);
  22. }
  23. // `AsyncIterator` constructor
  24. // https://github.com/tc39/proposal-async-iterator-helpers
  25. $({ global: true, constructor: true, forced: IS_PURE }, {
  26. AsyncIterator: AsyncIteratorConstructor
  27. });