"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/es6-iterator/for-of.js" (8 Mar 2017, 1144 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 'use strict';
    2 
    3 var callable = require('es5-ext/object/valid-callable')
    4   , isString = require('es5-ext/string/is-string')
    5   , get      = require('./get')
    6 
    7   , isArray = Array.isArray, call = Function.prototype.call;
    8 
    9 module.exports = function (iterable, cb/*, thisArg*/) {
   10     var mode, thisArg = arguments[2], result, doBreak, broken, i, l, char, code;
   11     if (isArray(iterable)) mode = 'array';
   12     else if (isString(iterable)) mode = 'string';
   13     else iterable = get(iterable);
   14 
   15     callable(cb);
   16     doBreak = function () { broken = true; };
   17     if (mode === 'array') {
   18         iterable.some(function (value) {
   19             call.call(cb, thisArg, value, doBreak);
   20             if (broken) return true;
   21         });
   22         return;
   23     }
   24     if (mode === 'string') {
   25         l = iterable.length;
   26         for (i = 0; i < l; ++i) {
   27             char = iterable[i];
   28             if ((i + 1) < l) {
   29                 code = char.charCodeAt(0);
   30                 if ((code >= 0xD800) && (code <= 0xDBFF)) char += iterable[++i];
   31             }
   32             call.call(cb, thisArg, char, doBreak);
   33             if (broken) break;
   34         }
   35         return;
   36     }
   37     result = iterable.next();
   38 
   39     while (!result.done) {
   40         call.call(cb, thisArg, result.value, doBreak);
   41         if (broken) return;
   42         result = iterable.next();
   43     }
   44 };