json-api-schema
Version:
JSON Api Schema is a JSON dialect that can describe any Web Based API that uses JSON to exchange data.
45 lines (36 loc) • 858 B
JavaScript
var ObjectIterator;
ObjectIterator = (function() {
function ObjectIterator(data) {
var k, v, _ref;
this.data = data;
this.index = 0;
this.keys = [];
_ref = this.data;
for (k in _ref) {
v = _ref[k];
this.keys.push(k);
}
this.length = this.keys.length;
}
ObjectIterator.prototype.next = function() {
var element;
if (!this.hasNext()) {
return null;
}
element = this.current();
this.index += 1;
return element;
};
ObjectIterator.prototype.hasNext = function() {
return this.index < this.length;
};
ObjectIterator.prototype.rewind = function() {
this.index = 0;
return this.current();
};
ObjectIterator.prototype.current = function() {
return this.data[this.keys[this.index]];
};
return ObjectIterator;
})();
module.exports = ObjectIterator;