Repository URL to install this package:
Version:
1.2.7 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var IteratorWrap = /** @class */ (function () {
function IteratorWrap(array) {
this.index = -1;
this.array = array;
}
IteratorWrap.prototype.hasNext = function () {
return this.index + 1 < this.array.length;
};
IteratorWrap.prototype.next = function () {
this.index += 1;
if (this.index > this.array.length) {
return {
done: true,
value: undefined,
};
}
else {
return {
value: this.array[this.index],
done: false,
};
}
};
IteratorWrap.prototype.remove = function () {
this.index -= 1;
this.array.splice(this.index, 1);
};
return IteratorWrap;
}());
exports.IteratorWrap = IteratorWrap;
function toIterator(x) {
if (Array.isArray(x)) {
return x[Symbol.iterator]();
}
else if (typeof x === 'object') {
return Object.entries(x)[Symbol.iterator]();
}
else {
return new IteratorWrap([x]);
}
}
exports.toIterator = toIterator;
//# sourceMappingURL=Iterator.js.map