How to use the bodec.Binary function in bodec

To help you get started, we’ve selected a few bodec 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 es-git / es-git / ts / lib / inflate.ts View on Github external
: function inflate(value : Uint8Array) {
    return new Binary(pako.inflate(new Uint8Array(value)));
  };
github es-git / es-git / ts / mixins / mem-cache.ts View on Github external
function dupe(type : Type, value : Body) {
  if (type === "blob") {
    if (type.length >= 100) return value;
    return new Binary(value as Uint8Array);
  }
  return decoders[type]((encoders[type] as any)(value as any) as any);
}
github es-git / es-git / ts / lib / inflate-stream.ts View on Github external
export default function inflateStream() {
  let inf = new Inflate();
  const b = new Uint8Array(1);
  const empty = new Binary(0);

  return {
    write: write,
    recycle: recycle,
    flush: Binary === Uint8Array ? flush : flushConvert
  };

  function write(byte : number) {
    b[0] = byte;
    inf.push(b);
    return !(inf as any).ended;
  }

  function recycle() { inf = new Inflate(); }

  function flush() { return inf.result as Uint8Array || empty; }
github es-git / es-git / ts / lib / deflate.ts View on Github external
: function deflate(value : Uint8Array) {
    return new Binary(pako.deflate(new Uint8Array(value)));
  };
github es-git / es-git / ts / lib / inflate-stream.ts View on Github external
function flushConvert() {
    return inf.result ? new Binary((inf as any).result) : empty;
  }
};