"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/es6-iterator/string.js" (7 Feb 2017, 1190 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 // Thanks @mathiasbynens
    2 // http://mathiasbynens.be/notes/javascript-unicode#iterating-over-symbols
    3 
    4 'use strict';
    5 
    6 var setPrototypeOf = require('es5-ext/object/set-prototype-of')
    7   , d              = require('d')
    8   , Iterator       = require('./')
    9 
   10   , defineProperty = Object.defineProperty
   11   , StringIterator;
   12 
   13 StringIterator = module.exports = function (str) {
   14     if (!(this instanceof StringIterator)) return new StringIterator(str);
   15     str = String(str);
   16     Iterator.call(this, str);
   17     defineProperty(this, '__length__', d('', str.length));
   18 
   19 };
   20 if (setPrototypeOf) setPrototypeOf(StringIterator, Iterator);
   21 
   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__++;
   27         this._unBind();
   28     }),
   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__++];
   34         return char;
   35     }),
   36     toString: d(function () { return '[object String Iterator]'; })
   37 });