How to use the localforage.iterate function in localforage

To help you get started, we’ve selected a few localforage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Irrelon / ForerunnerDB / js / lib / Persist.js View on Github external
callback(err);
						}
					});
					
					break;
				
				case 'object':
					// DB object was provided
					// determine size of DB
					// by iterating over all key/value pairs
					// filtering for this DB
					
					// we want to measure all persisted collections of a DB
					// independent of whether they're attached to the DB
					// at runtime via db.collection(name)
					localforage.iterate(function (value, key) {
						if ((key.lastIndexOf(target.name(), 0) === 0) && value !== null) {
							_mapSizeCb(value, key);
						}
					}).then(function () {
						// done - report back
						callback(null, resultMap);
					}).catch(function (err) {
						console.error(JSON.stringify(err));
						if (callback) {
							callback(err);
						}
					});
					break;
				
				default:
					if (callback) {
github rate-engineering / rate3-monorepo / packages / demo / token-swap / src / sagas / issuer.ts View on Github external
function* fetchS2E() {
  try {
    const resultList: any[] = [];
    const result = yield localforage.iterate((value: any, key, iterationNumber) => {
      if (value.type === 'S2E') {
        resultList.push(value);
      }
    });
    // console.log(resultList);
    yield put({ type: issuerActions.SET_S2E_APPROVAL_LIST, payload: resultList });
    return resultList;
  } catch (err) {
    throw err;
  }
}
github rate-engineering / rate3-monorepo / packages / demo / token-swap / src / sagas / issuer.ts View on Github external
function* fetchE2S() {
  try {
    const resultList: any[] = [];
    // const res = yield axios.get(
    //   `${HORIZON}/accounts/${STELLAR_USER}/payments?limit=10&order=desc`);
    // res.data._embedded.records.forEach((item) => {
    //   resultList.push(item);
    // });
    const result = yield localforage.iterate((value: any, key, iterationNumber) => {
      if (value.type === 'E2S') {
        resultList.push(value);
      }
    });
    yield put({ type: issuerActions.SET_E2S_APPROVAL_LIST, payload: resultList });
    return resultList;
  } catch (err) {
    throw err;
  }
}
function* fetchS2E() {
github mpigsley / sectors-without-number / src / store / api / local.js View on Github external
.then(() =>
            localForage
              .iterate((entity, key) => {
                const [entityType, entityId] = key.split('.');
                entities[entityType] = entities[entityType] || {};
                entities[entityType][entityId] = entity;
              })
              .then(() => resolve(entities)),
          );