How to use the node-persist.persistSync function in node-persist

To help you get started, we’ve selected a few node-persist 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 KhaosT / HAP-NodeJS / src / lib / model / AccessoryInfo.ts View on Github external
relayPairedControllers: this.relayPairedControllers,
      accessoryBagURL: this.accessoryBagURL
    };

    for (var username in this.pairedClients) {
      const pairingInformation = this.pairedClients[username];
      //@ts-ignore
      saved.pairedClients[username] = pairingInformation.publicKey.toString('hex');
      // @ts-ignore
      saved.pairedClientsPermission[username] = pairingInformation.permission;
    }

    var key = AccessoryInfo.persistKey(this.username);

    storage.setItemSync(key, saved);
    storage.persistSync();
  }
github KhaosT / HAP-NodeJS / src / lib / model / IdentifierCache.ts View on Github external
save = () => {
    var newCacheHash = crypto.createHash('sha1').update(JSON.stringify(this._cache)).digest('hex'); //calculate hash of new cache
    if (newCacheHash != this._savedCacheHash) { //check if cache need to be saved and proceed accordingly
      var saved = {
        cache: this._cache
      };
      var key = IdentifierCache.persistKey(this.username);
      storage.setItemSync(key, saved);
      storage.persistSync();
      this._savedCacheHash = newCacheHash; //update hash of saved cache for future use
    }
  }