Skip to content

Commit

Permalink
fix: constructor exposure
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Oct 17, 2017
1 parent 9d57772 commit dbc0c51
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion array.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ ArrayIterator = module.exports = function (arr, kind) {
};
if (setPrototypeOf) setPrototypeOf(ArrayIterator, Iterator);

// Internal %ArrayIteratorPrototype% doesn't expose its constructor
delete ArrayIterator.prototype.constructor;

ArrayIterator.prototype = Object.create(Iterator.prototype, {
constructor: d(ArrayIterator),
_resolve: d(function (i) {
if (this.__kind__ === "value") return this.__list__[i];
if (this.__kind__ === "key+value") return [i, this.__list__[i]];
Expand Down
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ module.exports = Iterator = function (list, context) {
context.on("_clear", this._onClear);
};

// Internal %IteratorPrototype% doesn't expose its constructor
delete Iterator.prototype.constructor;

defineProperties(
Iterator.prototype,
assign(
{
constructor: d(Iterator),
_next: d(function () {
var i;
if (!this.__list__) return undefined;
Expand Down
4 changes: 3 additions & 1 deletion string.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ StringIterator = module.exports = function (str) {
};
if (setPrototypeOf) setPrototypeOf(StringIterator, Iterator);

// Internal %ArrayIteratorPrototype% doesn't expose its constructor
delete StringIterator.prototype.constructor;

StringIterator.prototype = Object.create(Iterator.prototype, {
constructor: d(StringIterator),
_next: d(function () {
if (!this.__list__) return undefined;
if (this.__nextIndex__ < this.__length__) return this.__nextIndex__++;
Expand Down

0 comments on commit dbc0c51

Please sign in to comment.