]>
git.r.bdr.sh - rbdr/dotfiles/blob - atom/packages/vim-mode/node_modules/grim/node_modules/emissary/node_modules/es6-weak-map/node_modules/es6-iterator/string.js
cdb39ea4e4993186f846a8d61fc2f10dd4f13e3b
1 // Thanks @mathiasbynens
2 // http://mathiasbynens.be/notes/javascript-unicode#iterating-over-symbols
6 var setPrototypeOf
= require('es5-ext/object/set-prototype-of')
8 , Iterator
= require('./')
10 , defineProperty
= Object
.defineProperty
13 StringIterator
= module
.exports = function (str
) {
14 if (!(this instanceof StringIterator
)) return new StringIterator(str
);
16 Iterator
.call(this, str
);
17 defineProperty(this, '__length__', d('', str
.length
));
20 if (setPrototypeOf
) setPrototypeOf(StringIterator
, Iterator
);
22 StringIterator
.prototype = Object
.create(Iterator
.prototype, {
23 constructor: d(StringIterator
),
24 _next: d(function () {
25 if (!this.__list__
) return;
26 if (this.__nextIndex__
< this.__length__
) return this.__nextIndex__
++;
29 _resolve: d(function (i
) {
30 var char = this.__list__
[i
], code
;
31 if (this.__nextIndex__
=== this.__length__
) return char;
32 code
= char.charCodeAt(0);
33 if ((code
>= 0xD800) && (code
<= 0xDBFF)) return char + this.__list__
[this.__nextIndex__
++];
36 toString: d(function () { return '[object String Iterator]'; })