CollectionIterator_next: async + async/yield -> sync.

This commit is contained in:
Edward Lee 2009-06-05 00:38:23 -07:00
parent 3a4f2ca0ee
commit e7a503025a
2 changed files with 10 additions and 14 deletions

View File

@ -148,21 +148,17 @@ CollectionIterator.prototype = {
get count() { return this._coll.data.length; },
next: function CollIter_next(onComplete) {
let fn = function CollIter__next() {
let self = yield;
next: function CollectionIterator_next() {
if (this._idx >= this.count)
return null;
if (this._idx >= this.count)
return;
let item = this._coll.data[this._idx++];
let record = new this._coll._recordObj();
record.deserialize(JSON.stringify(item)); // FIXME: inefficient
record.baseUri = this._coll.uri;
record.id = record.data.id;
let item = this._coll.data[this._idx++];
let record = new this._coll._recordObj();
record.deserialize(JSON.stringify(item)); // FIXME: inefficient
record.baseUri = this._coll.uri;
record.id = record.data.id;
self.done(record);
};
fn.async(this, onComplete);
return record;
},
reset: function CollIter_reset() {

View File

@ -347,7 +347,7 @@ SyncEngine.prototype = {
let count = {applied: 0, reconciled: 0};
this._lastSyncTmp = 0;
while ((item = yield newitems.iter.next(self.cb))) {
while ((item = newitems.iter.next())) {
this._lowMemCheck();
try {
item.decrypt(ID.get('WeaveCryptoID').password);