iterate.js 1.1 KB

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