How to use it-tar - 1 common examples

To help you get started, we’ve selected a few it-tar 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 ipfs / js-ipfs-http-client / src / get.js View on Github external
if (options.offset) {
      searchParams.set('offset', options.offset)
    }

    if (options.length) {
      searchParams.set('length', options.length)
    }

    const res = await ky.post('get', {
      timeout: options.timeout,
      signal: options.signal,
      headers: options.headers,
      searchParams
    })

    const extractor = Tar.extract()

    for await (const { header, body } of extractor(toIterable(res.body))) {
      if (header.type === 'directory') {
        yield {
          path: header.name
        }
      } else {
        yield {
          path: header.name,
          content: body
        }
      }
    }
  }
})

it-tar

it-tar is a streaming tar parser (and maybe a generator in the future) and nothing else. It operates purely using async iterables which means you can easily extract/parse tarballs without ever hitting the file system.

Apache-2.0 OR MIT
Latest version published 10 months ago

Package Health Score

64 / 100
Full package analysis

Popular it-tar functions