Skip to content

Commit

Permalink
fix: toString and toStringTag symbol definitions.
Browse files Browse the repository at this point in the history
Fixes #6
  • Loading branch information
medikoo committed Oct 17, 2017
1 parent dbc0c51 commit 2d17786
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
5 changes: 2 additions & 3 deletions array.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
var setPrototypeOf = require("es5-ext/object/set-prototype-of")
, contains = require("es5-ext/string/#/contains")
, d = require("d")
, Symbol = require("es6-symbol")
, Iterator = require("./");

var defineProperty = Object.defineProperty, ArrayIterator;
Expand All @@ -26,8 +27,6 @@ ArrayIterator.prototype = Object.create(Iterator.prototype, {
if (this.__kind__ === "value") return this.__list__[i];
if (this.__kind__ === "key+value") return [i, this.__list__[i]];
return i;
}),
toString: d(function () {
return "[object Array Iterator]";
})
});
defineProperty(ArrayIterator.prototype, Symbol.toStringTag, d("c", "Array Iterator"));
3 changes: 1 addition & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ defineProperties(
this.__context__ = null;
}),
toString: d(function () {
return "[object Iterator]";
return "[object " + (this[Symbol.toStringTag] || "Object") + "]";
})
},
autoBind({
Expand Down Expand Up @@ -104,4 +104,3 @@ defineProperty(
return this;
})
);
defineProperty(Iterator.prototype, Symbol.toStringTag, d("", "Iterator"));
5 changes: 2 additions & 3 deletions string.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

var setPrototypeOf = require("es5-ext/object/set-prototype-of")
, d = require("d")
, Symbol = require("es6-symbol")
, Iterator = require("./");

var defineProperty = Object.defineProperty, StringIterator;
Expand Down Expand Up @@ -33,8 +34,6 @@ StringIterator.prototype = Object.create(Iterator.prototype, {
code = char.charCodeAt(0);
if (code >= 0xd800 && code <= 0xdbff) return char + this.__list__[this.__nextIndex__++];
return char;
}),
toString: d(function () {
return "[object String Iterator]";
})
});
defineProperty(StringIterator.prototype, Symbol.toStringTag, d("", "String Iterator"));

0 comments on commit 2d17786

Please sign in to comment.