抖音开放平台Logo
开发者文档
“/”唤起搜索
控制台
  • JavaScript API
  • API 概览
  • 基础
  • 界面
  • 渲染
  • 字体
  • 帧率
  • 图片
  • 资源压缩
  • tt.createBuffer
  • tt.inflate
  • 鼠标样式
  • 数据缓存
  • 文件
  • 位置
  • 设备
  • 网络
  • 媒体
  • Worker
  • 数据分析
  • 支付
  • 广告
  • 开放能力
  • C# API
  • 基础库 1.3.0 开始支持本方法,这是一个同步方法。

    提供解压缩的能力,支持由 zlib.deflateSync 和 zlib.deflateRawSync 得到的压缩数据。与 node 提供的异步解压缩方法不同,这是一个同步方法。

    前提条件无
    业务背景无
    使用限制无
    注意事项无
    相关教程无

    语法

    tt.inflate(buffer, raw)

    参数说明

    buffer

    类型默认值必填说明最低支持版本
    arrayBuffer是

    可以通过 tt.createBuffer() 提供的 from 方法得到

    1.3.0

    raw

    类型默认值必填说明最低支持版本
    booleanfalse否

    当参数 raw 为 false 时,对应的压缩方法为 zlib.deflateSync,对应的解压缩方法为 zlib.inflateSync,与 zlib 提供的异步解压缩方法不同,小游戏中提供的 tt.inflate 是同步的。
    当参数 raw 为 true 时,对应的压缩方法为
    zlib.deflateRawSync,对应的解压缩方法为 zlib.inflateRawSync ,与 zlib 提供的异步解压缩方法不同,小游戏中提供的 tt.inflate 是同步的

    1.98.0

    返回值

    类型说明最低支持版本
    arrayBuffer

    Uint8Array。可以通过 tt.createBuffer() 提供的 toString 方法将结果转化为字符串

    1.3.0

    扫码体验

    请使用字节宿主APP扫码

    代码示例

    开发者工具中预览

    const Buffer = tt.createBuffer(); const content1 = "eJxzT03NLgYABXQB8A=="; const buffer1 = Buffer.from(content1, "base64"); const result1 = tt.inflate(buffer1); // 默认为false console.log( `[API: ZLIB] the result of inflate is: ${Buffer.toString(result1)}` ); // [API: ZLIB] the result of inflate is: Geeks const content2 = "c09NzS4GAA=="; const buffer2 = Buffer.from(content2, "base64"); const result2 = tt.inflate(buffer2, true); console.log( `[API: ZLIB] the result of inflate raw is: ${Buffer.toString(result2)}` ); // [API: ZLIB] the result of inflate raw is: Geeks