"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/es6-iterator/array.js" (7 Feb 2017, 1040 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 setPrototypeOf = require('es5-ext/object/set-prototype-of')
    4   , contains       = require('es5-ext/string/#/contains')
    5   , d              = require('d')
    6   , Iterator       = require('./')
    7 
    8   , defineProperty = Object.defineProperty
    9   , ArrayIterator;
   10 
   11 ArrayIterator = module.exports = function (arr, kind) {
   12     if (!(this instanceof ArrayIterator)) return new ArrayIterator(arr, kind);
   13     Iterator.call(this, arr);
   14     if (!kind) kind = 'value';
   15     else if (contains.call(kind, 'key+value')) kind = 'key+value';
   16     else if (contains.call(kind, 'key')) kind = 'key';
   17     else kind = 'value';
   18     defineProperty(this, '__kind__', d('', kind));
   19 };
   20 if (setPrototypeOf) setPrototypeOf(ArrayIterator, Iterator);
   21 
   22 ArrayIterator.prototype = Object.create(Iterator.prototype, {
   23     constructor: d(ArrayIterator),
   24     _resolve: d(function (i) {
   25         if (this.__kind__ === 'value') return this.__list__[i];
   26         if (this.__kind__ === 'key+value') return [i, this.__list__[i]];
   27         return i;
   28     }),
   29     toString: d(function () { return '[object Array Iterator]'; })
   30 });