當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。