iterate.js 939 B

12345678910111213141516171819202122232425
  1. import { executeCallback } from 'localforage-driver-commons';
  2. export function iterate(iterator, callback) {
  3. var _this = this;
  4. var promise = this.ready().then(function () {
  5. var store = _this._dbInfo.mStore;
  6. var keys = store.keys();
  7. for (var i = 0; i < keys.length; i++) {
  8. var value = store.get(keys[i]);
  9. // If a result was found, parse it from the serialized
  10. // string into a JS object. If result isn't truthy, the
  11. // key is likely undefined and we'll pass it straight
  12. // to the iterator.
  13. if (value) {
  14. value = _this._dbInfo.serializer.deserialize(value);
  15. }
  16. value = iterator(value, keys[i], i + 1);
  17. if (value !== undefined) {
  18. return value;
  19. }
  20. }
  21. });
  22. executeCallback(promise, callback);
  23. return promise;
  24. }
  25. //# sourceMappingURL=iterate.js.map