How to use the lz-string.decompress function in lz-string

To help you get started, we’ve selected a few lz-string 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 OriginProtocol / origin / packages / graphql / src / utils / eventCache.js View on Github external
async function getPastEvents() {
    if (processing) {
      await isDone()
    }
    processing = true
    if (!triedIpfs && config.ipfsEventCache) {
      debug('Try IPFS cache...')
      let ipfsData
      try {
        ipfsData = await get(config.ipfsGateway, config.ipfsEventCache)
        if (ipfsData.compressed) {
          const decompressed = LZString.decompress(ipfsData.compressed)
          ipfsData = JSON.parse(decompressed)
        }
      } catch (e) {
        /* Ignore */
      }
      if (ipfsData && ipfsData.events) {
        debug('Got IPFS cache')
        // console.log(ipfsData)
        events = ipfsData.events
        lastLookup = ipfsData.lastLookup
        fromBlock = ipfsData.lastLookup
        // ({ events, lastLookup } = ipfsData)
      } else {
        debug('Error getting IPFS cache')
      }
      triedIpfs = true
github OriginProtocol / origin / packages / graphql / src / utils / genericEventCache.js View on Github external
function getBlockNumber() {
    return toBlock
  }

  if (!contract.options.address) {
    return { updateBlock }
  }

  const cacheStr = `eventCache${contract.options.address.slice(2, 8)}`

  try {
    if (window.localStorage[cacheStr]) {
      let str = window.localStorage[cacheStr]
      if (str[0] !== '{') {
        str = LZString.decompress(str)
      }
      const parsed = JSON.parse(str)
      events = parsed.events
      lastLookup = fromBlock = parsed.lastLookup
      triedIpfs = true
    }
  } catch (e) {
    /* Ignore */
  }

  const isDone = () => new Promise(resolve => queue.push(resolve))

  async function getPastEvents() {
    if (processing) {
      await isDone()
    }
github OriginProtocol / origin / packages / graphql / src / utils / genericEventCache.js View on Github external
async function getPastEvents() {
    if (processing) {
      await isDone()
    }
    processing = true
    if (!triedIpfs && config.ipfsEventCache) {
      debug('Try IPFS cache...')
      let ipfsData
      try {
        ipfsData = await get(config.ipfsGateway, ipfsEventCache)
        if (ipfsData.compressed) {
          const decompressed = LZString.decompress(ipfsData.compressed)
          ipfsData = JSON.parse(decompressed)
        }
      } catch (e) {
        /* Ignore */
      }
      if (ipfsData && ipfsData.events) {
        debug('Got IPFS cache')
        events = ipfsData.events
        lastLookup = ipfsData.lastLookup
        fromBlock = ipfsData.lastLookup
      } else {
        debug('Error getting IPFS cache')
      }
      triedIpfs = true
    }
    if (!toBlock) {
github myter / Spiders.js / ReactiveMicroserviceExample / FleetMember.js View on Github external
decompress() {
        this.id = LZString.decompress(this.id);
        this.lat = LZString.decompress(this.lat);
        this.lon = LZString.decompress(this.lon);
        this.speed = LZString.decompress(this.speed);
    }
}
github encrypted-dev / userbase / src / userbase-js / ws.js View on Github external
if (!database) return

        const openingDatabase = message.dbNameHash && message.dbKey
        if (openingDatabase) {
          const dbKeyString = await crypto.aesGcm.decryptString(this.keys.encryptionKey, message.dbKey)
          database.dbKeyString = dbKeyString
          database.dbKey = await crypto.aesGcm.getKeyFromKeyString(dbKeyString)
        }

        if (!database.dbKey) return

        if (message.bundle) {
          const bundleSeqNo = message.bundleSeqNo
          const base64Bundle = message.bundle
          const compressedString = await crypto.aesGcm.decryptString(database.dbKey, base64Bundle)
          const plaintextString = LZString.decompress(compressedString)
          const bundle = JSON.parse(plaintextString)

          database.applyBundle(bundle, bundleSeqNo)
        }

        const newTransactions = message.transactionLog
        await database.applyTransactions(newTransactions)
        database.onChange(database.getItems())

        if (!database.init) {
          this.state.dbIdToHash[dbId] = dbNameHash
          database.dbId = dbId
          database.init = true
        }

        break
github okamilab / nebula / src / base / middlewares / localStorage.js View on Github external
unpack(raw) {
    const uncompressed = LZString.decompress(raw);
    return uncompressed ? jsonpack.unpack(uncompressed) : {};
  }
}
github emadalam / atvjs / src / settings.js View on Github external
get(key) {
		let item = localStorage.getItem(key);
		let val;
		
		if (!_.isUndefined(item)) {
			item = LZString.decompress(item);
		}
		try {
			val = JSON.parse(item);
		} catch (ex) {
			val = item;
		}
		return val;
	},
	/**
github okamilab / nebula / src / base / storage.js View on Github external
get() {
    const value = localStorage.getItem(STORAGE_KEY);
    const uncompressed = LZString.decompress(value);
    return uncompressed ? jsonpack.unpack(uncompressed) : {};
  },
github elastic / kibana / x-pack / plugins / canvas / public / lib / history_provider.js View on Github external
parse(payload) {
      try {
        const stateJSON = lzString.decompress(payload);
        return JSON.parse(stateJSON);
      } catch (e) {
        return null;
      }
    },