当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript pako.inflate函数代码示例

本文整理汇总了TypeScript中pako.inflate函数的典型用法代码示例。如果您正苦于以下问题:TypeScript inflate函数的具体用法?TypeScript inflate怎么用?TypeScript inflate使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了inflate函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: getZbook

async function getZbook(book : Book) : Promise<Database> {
  let file = files[book.file];
  if (!file) {
    file = await localforage.getItem<BookFile>(book.file);
    if (file) {
      if (file.version !== book.file_version) {
        // Update book in background.
        fetchBinary(
          book.url,
          "Updating book " + book.name + "..."
        ).then(data => {
          file.data = data;
          // TODO: notify UI book has been updated
          files[book.file] = file;
          return localforage.setItem(book.file, file);
        });
      }
    }
    else {
      file = {
        version: book.file_version,
        data: await fetchBinary(
          book.url,
          "Downloading book " + book.name + "..."
        )
      };
      await localforage.setItem(book.file, file);
    }
  }

  return new Database(inflate(file.data));
}
开发者ID:creationix,项目名称:gospel-viewer,代码行数:32,代码来源:app.ts

示例2: maybeDecompressGzip

export function maybeDecompressGzip(data: ArrayBuffer|ArrayBufferView) {
  let byteView: Uint8Array;
  if (data instanceof ArrayBuffer) {
    byteView = new Uint8Array(data);
  } else {
    byteView = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
  }
  if (isGzipFormat(byteView)) {
    return inflate(byteView);
  }
  return byteView;
}
开发者ID:google,项目名称:neuroglancer,代码行数:12,代码来源:gzip.ts

示例3: decodeBossNpzChunk

export function decodeBossNpzChunk(chunk: VolumeChunk, response: ArrayBuffer) {
  let parseResult = parseNpy(inflate(new Uint8Array(response)));
  let chunkDataSize = chunk.chunkDataSize!;
  let source = chunk.source!;
  let {shape} = parseResult;
  if (shape.length !== 3 || shape[0] !== chunkDataSize[2] ||
      shape[1] !== chunkDataSize[1] || shape[2] !== chunkDataSize[0]) {
    throw new Error(
        `Shape ${JSON.stringify(shape)} does not match chunkDataSize ${vec3Key(chunkDataSize)}`);
  }
  let parsedDataType = parseResult.dataType.dataType;
  let {spec} = source;
  if (parsedDataType !== spec.dataType) {
    throw new Error(
        `Data type ${DataType[parsedDataType]} does not match expected data type ${DataType[spec.dataType]}`);
  }
  postProcessRawData(chunk, parseResult.data);
}
开发者ID:google,项目名称:neuroglancer,代码行数:18,代码来源:bossNpz.ts

示例4: decodeChunk

function decodeChunk(chunk: VolumeChunk, response: ArrayBuffer, encoding: VolumeChunkEncoding) {
  const dv = new DataView(response);
  const mode = dv.getUint16(0, /*littleEndian=*/ false);
  if (mode !== 0) {
    throw new Error(`Unsupported mode: ${mode}.`);
  }
  const numDimensions = dv.getUint16(2, /*littleEndian=*/ false);
  if (numDimensions !== 3) {
    throw new Error(`Number of dimensions must be 3.`);
  }
  let offset = 4;
  const shape = new Uint32Array(numDimensions);
  for (let i = 0; i < numDimensions; ++i) {
    shape[i] = dv.getUint32(offset, /*littleEndian=*/ false);
    offset += 4;
  }
  chunk.chunkDataSize = vec3.fromValues(shape[0], shape[1], shape[2]);
  let buffer = new Uint8Array(response, offset);
  if (encoding === VolumeChunkEncoding.GZIP) {
    buffer = inflate(buffer);
  }
  decodeRawChunk(chunk, buffer.buffer, Endianness.BIG, buffer.byteOffset, buffer.byteLength);
}
开发者ID:google,项目名称:neuroglancer,代码行数:23,代码来源:backend.ts

示例5: loadRaw

 async loadRaw(hash : Hash) {
   const raw = await super.loadRaw(hash);
   return raw ? pako.inflate(raw) : undefined;
 }
开发者ID:strangesast,项目名称:es-git,代码行数:4,代码来源:index.ts

示例6: inflateBase64

export function inflateBase64(encoded: string): string {
    const bytes = Base64.atob(encoded);
    return pako.inflate(bytes, { to: "string" });
}
开发者ID:nrkn,项目名称:quicktype,代码行数:4,代码来源:Support.ts


注:本文中的pako.inflate函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。