How to use typedarray-to-buffer - 10 common examples

To help you get started, we’ve selected a few typedarray-to-buffer 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 transcend-io / penumbra / index.ts View on Github external
transform: async (chunk, controller) => {
          try {
            chunk = toBuffer(chunk);
          } catch (err) {
            console.error(err);
          }

          // Decrypt chunk and send it out
          const decryptedChunk = decipher.update(chunk);
          controller.enqueue(decryptedChunk);

          // Emit a progress update
          totalBytesRead += chunk.length;
          emitProgress(totalBytesRead, contentLength, url);
        },
      })
github transcend-io / penumbra / util.js View on Github external
transform: async (chunk, controller) => {
          try {
            chunk = toBuffer(chunk);
          } catch (err) {
            console.error(err);
          }

          // Decrypt chunk and send it out
          const decryptedChunk = decipher.update(chunk);
          controller.enqueue(decryptedChunk);

          // Emit a progress update
          totalBytesRead += chunk.length;
          emitProgress(totalBytesRead, contentLength, url);
        },
      })
github transcend-io / penumbra / util.js View on Github external
reader.read().then(({ done, value }) => {
          if (done) {
            controller.close();
            return;
          }

          const chunk = toBuffer(value);

          // Decrypt chunk
          const decValue = decipher.update(chunk);

          // Emit a progress update
          totalBytesRead += chunk.length;
          emitProgress(totalBytesRead, contentLength, url);

          controller.enqueue(decValue);
          push();
        });
      }
github transcend-io / penumbra / src / decrypt.ts View on Github external
reader.read().then(({ done, value }) => {
          if (done) {
            controller.close();
            return;
          }

          const chunk = toBuffer(value);

          // Decrypt chunk
          const decValue = decipher.update(chunk);

          // Emit a progress update
          totalBytesRead += chunk.length;
          emitProgress('decrypt', totalBytesRead, contentLength, id);

          controller.enqueue(decValue);
          push();
        });
      }
github transcend-io / penumbra / src / encrypt.ts View on Github external
reader.read().then(({ done, value }) => {
          if (done) {
            controller.close();
            return;
          }

          const chunk = toBuffer(value);

          // Encrypt chunk
          const encryptedChunk = cipher.update(chunk);

          controller.enqueue(encryptedChunk);
          push();

          // Emit a progress update
          totalBytesRead += chunk.length;
          emitProgress(
            'encrypt',
            totalBytesRead,
            contentLength,
            '[encrypted file]',
          );
github SamyPesse / gitkit-js / src / models / PackFile.js View on Github external
parser.buffer('byte', 1).tap(() => {
            const byte = parser.vars.byte;

            const ab = new Uint8Array(1);
            ab.fill(byte[0]);

            inflator.push(ab);

            if (inflator.ended) {
                if (inflator.err) {
                    parser.emit('error', new Error(inflator.msg));
                }

                parser.vars.content = uint8ToBuffer(inflator.result);

                end();
            }
        });
    });
github keybase / client / shared / engine / index.platform.native.tsx View on Github external
RNEmitter.addListener(nativeBridge.eventName, (payload: string) => {
    if (printRPCBytes) {
      logger.debug('[RPC] Read', payload.length, 'chars:', payload)
    }

    const buffer = toBuffer(toByteArray(payload))
    const measureName = `packetize${packetizeCount++}:${buffer.length}`
    measureStart(measureName)
    const ret = client.transport.packetize_data(buffer)
    measureStop(measureName)
    return ret
  })
github ecadlabs / taquito / packages / taquito-signer / src / ed-key.ts View on Github external
async secretKey(): Promise {
    await this.isInit;
    await sodium.ready;
    let key = this._key;
    const { privateKey } = sodium.crypto_sign_seed_keypair(
      new Uint8Array(key).slice(0, 32),
      'uint8array'
    );
    key = toBuffer(privateKey);

    return b58cencode(key, prefix[`edsk`]);
  }
}
github ecadlabs / taquito / packages / taquito-signer / src / ec-key.ts View on Github external
async sign(bytes: string, bytesHash: Uint8Array) {
    const key = new elliptic.ec(this.curve).keyFromPrivate(this._key);
    const sig = key.sign(bytesHash, { canonical: true });
    const signature = new Uint8Array(sig.r.toArray().concat(sig.s.toArray()));
    const signatureBuffer = toBuffer(signature);
    const sbytes = bytes + buf2hex(signatureBuffer);

    return {
      bytes,
      sig: b58cencode(signature, prefix.sig),
      prefixSig: b58cencode(signature, pref[this.curve].sig),
      sbytes,
    };
  }
github SamyPesse / gitkit-js / src / utils / zlib.js View on Github external
function unzip(buf: Buffer): Buffer {
    const input = bufferToUint8(buf);
    const output = pako.inflate(input);

    return uint8ToBuffer(output);
}

typedarray-to-buffer

Convert a typed array to a Buffer without a copy

MIT
Latest version published 3 years ago

Package Health Score

67 / 100
Full package analysis

Popular typedarray-to-buffer functions