Skip to content

Instantly share code, notes, and snippets.

@ste2425
Last active August 1, 2018 07:34
Show Gist options
  • Save ste2425/43053b89bea0505f3f5595779693d68f to your computer and use it in GitHub Desktop.
Save ste2425/43053b89bea0505f3f5595779693d68f to your computer and use it in GitHub Desktop.
Close Contacts Enumerator polly-fill
if (!window.Enumerator) {
window.Enumerator = function (c) {
this._c = Array.from(c);
this._index = 0;
}
window.Enumerator.prototype.atEnd = function () {
return this._index >= this._c.length - 1;
}
window.Enumerator.prototype.moveFirst = function () {
this._index = 0;
}
window.Enumerator.prototype.moveNext = function () {
if (this._index >= (this._c.length - 1))
this._index = (this._c.length - 1);
else {
this._index += 1;
}
}
window.Enumerator.prototype.item = function () {
return this._c[this._index];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment