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:
894 bytes
|
Rev | Line | |
---|
[d565449] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var GetIntrinsic = require('get-intrinsic');
|
---|
| 4 | var hasPropertyDescriptors = require('has-property-descriptors')();
|
---|
| 5 |
|
---|
| 6 | var $TypeError = require('es-errors/type');
|
---|
| 7 | var $defineProperty = hasPropertyDescriptors && GetIntrinsic('%Object.defineProperty%', true);
|
---|
| 8 |
|
---|
| 9 | var iterProto = require('iterator.prototype');
|
---|
| 10 | var callBound = require('call-bind/callBound');
|
---|
| 11 |
|
---|
| 12 | var $isPrototypeOf = callBound('Object.prototype.isPrototypeOf');
|
---|
| 13 |
|
---|
| 14 | var $Iterator = typeof Iterator === 'function' ? Iterator : function Iterator() {
|
---|
| 15 | if (
|
---|
| 16 | !(this instanceof Iterator)
|
---|
| 17 | || this.constructor === Iterator
|
---|
| 18 | || !$isPrototypeOf(Iterator, this.constructor)
|
---|
| 19 | ) {
|
---|
| 20 | throw new $TypeError('`Iterator` can not be called or constructed directly');
|
---|
| 21 | }
|
---|
| 22 | };
|
---|
| 23 |
|
---|
| 24 | if ($Iterator.prototype !== iterProto) {
|
---|
| 25 | $Iterator.prototype = iterProto;
|
---|
| 26 | }
|
---|
| 27 | $defineProperty($Iterator, 'prototype', { writable: false });
|
---|
| 28 |
|
---|
| 29 | module.exports = $Iterator;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.