How to use the lz-string.compress 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
...events,
        ...newEvents.map(e => ({ ...e, block: { id: e.blockNumber } }))
      ],
      e => e.id
    )

    debug(`Found ${events.length} events, ${newEvents.length} new`)

    fromBlock = toBlock + 1
    processing = false
    while (queue.length) {
      queue.pop()()
    }

    if (typeof window !== 'undefined') {
      const compressed = LZString.compress(
        JSON.stringify({
          lastLookup,
          events
        })
      )
      window.localStorage[cacheStr] = compressed

      // const hash = await post(config.ipfsRPC, { compressed }, true)
      // console.log('IPFS Hash', hash)
    }
  }
github emadalam / atvjs / src / settings.js View on Github external
set(key, val) {
		// convert all values to string for proper compression
		if (!_.isUndefined(val)) {
			val = JSON.stringify(val);
			console.log(`Setting key: ${key} with value: ${val}`);
			localStorage.setItem(key, LZString.compress(val));
		} else {
			this.remove(key);
		}
	},
	/**
github alikhil / sttp / src / packer.js View on Github external
this.pack = function(data) {
		if (typeof data !== "string")
			data = JSON.stringify(data);
		let compressed = lz.compress(data);
		let bytesPerChar = zaes.utils.detectBytesPerChar(compressed);
		let compressedBytes = zaes.utils.stringToBytes(compressed, bytesPerChar);  
		let crypted = zaes.encrypt(compressedBytes, aesKey);
		let total = [bytesPerChar].concat(crypted); // to decrypt then 
		return zaes.utils.bytesToString(total, 2);
	};
github okamilab / nebula / src / base / middlewares / localStorage.js View on Github external
revealAddress
        }
      };

      const publicKey = get(state, 'account.publicKey');
      if (publicKey) {
        const username = get(state, 'account.username');
        model[publicKey] = {
          username,
          contacts: state.contacts,
          chats: state.chats,
        };
      }

      const value = jsonpack.pack(model);
      const compressed = LZString.compress(value);
      localStorage.setItem(this.key, compressed);
    }
github myter / Spiders.js / ReactiveMicroserviceExample / FleetMember.ts View on Github external
compress(){
        this.id     = LZString.compress((JSON.stringify(this.id)))
        this.lat    = LZString.compress((JSON.stringify(this.lat)))
        this.lon    = LZString.compress((JSON.stringify(this.lon)))
        this.speed  = LZString.compress((JSON.stringify(this.speed)))
    }
github encrypted-dev / userbase / src / userbase-js / ws.js View on Github external
const bundle = {
          items: database.items,
          itemsIndex: database.itemsIndex.array
        }

        const itemKeys = []

        for (let i = 0; i < bundle.itemsIndex.length; i++) {
          const itemId = bundle.itemsIndex[i].itemId
          const itemKey = await crypto.hmac.signString(this.keys.hmacKey, itemId)
          itemKeys.push(itemKey)
        }

        const plaintextString = JSON.stringify(bundle)
        const compressedString = LZString.compress(plaintextString)
        const base64Bundle = await crypto.aesGcm.encryptString(database.dbKey, compressedString)

        const action = 'Bundle'
        const params = { dbId, seqNo: database.lastSeqNo, bundle: base64Bundle, keys: itemKeys }
        this.request(action, params)

        break
      }

      case 'ReceiveRequestForSeed': {
        if (!this.keys.init) return

        const requesterPublicKey = message.requesterPublicKey
        this.sendSeed(requesterPublicKey)

        break
github ian13456 / mine.js / core / modules / managers / chunkManager / mesher.js View on Github external
y: y + dy,
        z: z + dz
      })

      matrix.makeTranslation(wx, wy, wz)
      mergedGeometry.merge(geometry, matrix, i)

      materials.push([type, geo, face])
    }

    const finalGeometry = new THREE.BufferGeometry().fromGeometry(
      mergedGeometry
    )

    const JSONGeo = finalGeometry.toJSON()
    return [LZString.compress(JSON.stringify(JSONGeo)), materials]
  }
github myter / Spiders.js / ReactiveMicroserviceExample / FleetMember.js View on Github external
compress() {
        this.id = LZString.compress((JSON.stringify(this.id)));
        this.lat = LZString.compress((JSON.stringify(this.lat)));
        this.lon = LZString.compress((JSON.stringify(this.lon)));
        this.speed = LZString.compress((JSON.stringify(this.speed)));
    }
    decompress() {