]> 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/array.js
885ad0a4fd7870f011e721e88271e39040e58150
[rbdr/dotfiles] / atom / packages / vim-mode / node_modules / grim / node_modules / emissary / node_modules / es6-weak-map / node_modules / es6-iterator / array.js
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 });