diff --git a/.gitignore b/.gitignore index b512c09..ea87153 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -node_modules \ No newline at end of file +node_modules +example.js \ No newline at end of file diff --git a/es5/infinity.js b/es5/infinity.js index ab9a033..63b13f3 100644 --- a/es5/infinity.js +++ b/es5/infinity.js @@ -211,20 +211,19 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons var source = void 0, target = void 0; - // "from" number of elements if (isNonZeroFalsy(to)) { + // "from" number of elements source = 0; target = from; - } - // "target" is the end index! - else { - source = from; - target = to + 1; - }; + } else { + // "target" is the end index! + source = from; + target = to + 1; + }; for (var i = source; i < target; i++) { arr.push(this.get(i)); - }; + } return arr; }; diff --git a/index.js b/index.js index 3fb8d2b..0ae9b84 100644 --- a/index.js +++ b/index.js @@ -50,7 +50,7 @@ class InfiniteListItem { return ('InfiniteListItem [ .. ' + stringify(this.value) + ' .. ]') - }; + } } class InfiniteList { @@ -90,7 +90,7 @@ class InfiniteList { if (!cache[0]) cache[0] = start; // If index were to be infinity, value and index are infinity - if (index === Infinity) return new InfiniteListItem(this, Infinity, Infinity) + if (index === Infinity) return new InfiniteListItem(this, Infinity, Infinity); // If index exists in cache, return the value if (index in cache) return new InfiniteListItem(this, cache[index], index); @@ -124,7 +124,7 @@ class InfiniteList { done: false, value: this.get(j++) }) - } + }; }; } } @@ -146,20 +146,19 @@ InfiniteList.prototype.take = function (from, to) { ) return arr; let source, target; - // "from" number of elements if (isNonZeroFalsy(to)) { + // "from" number of elements source = 0; target = from; - } - // "target" is the end index! - else { + } else { + // "target" is the end index! source = from; target = to + 1 }; for (let i = source; i < target; i++) { arr.push(this.get(i)); - }; + } return arr; }; @@ -168,7 +167,7 @@ InfiniteList.prototype.take = function (from, to) { * @returns {InfiniteListItem} Instance of InfiniteListItem */ InfiniteList.prototype.top = function () { - return this.get(0) + return this.get(0); }; /** @@ -176,7 +175,7 @@ InfiniteList.prototype.top = function () { * @returns {InfiniteListItem} Instance of InfiniteListItem */ InfiniteList.prototype.end = function () { - return this.get(Infinity) + return this.get(Infinity); }; /** @@ -195,7 +194,7 @@ InfiniteList.prototype.toString = function () { '... ]' ] .join(' '); -} +}; /* Convenience methods */ InfiniteList.prototype.first = InfiniteList.prototype.top;