Browse Source

[misc] Minor changes

master
Muthu Kumar 6 years ago
parent
commit
c8da648780
  1. 1
      .gitignore
  2. 15
      es5/infinity.js
  3. 21
      index.js

1
.gitignore

@ -1 +1,2 @@
node_modules
example.js

15
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;
};

21
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;

Loading…
Cancel
Save