localforage-driver-memory
Version:
in-memory localforage driver that resets on page reload
25 lines • 939 B
JavaScript
import { executeCallback } from 'localforage-driver-commons';
export function iterate(iterator, callback) {
var _this = this;
var promise = this.ready().then(function () {
var store = _this._dbInfo.mStore;
var keys = store.keys();
for (var i = 0; i < keys.length; i++) {
var value = store.get(keys[i]);
// If a result was found, parse it from the serialized
// string into a JS object. If result isn't truthy, the
// key is likely undefined and we'll pass it straight
// to the iterator.
if (value) {
value = _this._dbInfo.serializer.deserialize(value);
}
value = iterator(value, keys[i], i + 1);
if (value !== undefined) {
return value;
}
}
});
executeCallback(promise, callback);
return promise;
}
//# sourceMappingURL=iterate.js.map