🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@andrewbranch/untar.js

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@andrewbranch/untar.js

untar salvaged from bitjs

1.0.3
latest
npm
Version published
Weekly downloads
194K
-16%
Maintainers
1
Weekly downloads
 
Created
Source

untar.js

Here's a simple pure-javascript implementation of untar (it's mostly taken verbatim from Jeff Schiller's bitjs, but no longer in a webworker— though ironically I'm making this in order to stick it back in a webworker, but I digress).

Here's a basic usage, it seems to work alright.

var untar = require('untar.js');
var fs = require('fs');

var file = fs.readFileSync(__dirname + '/' + 'test.tar');
untar.untar(file).forEach(function(file){
    console.log(file.filename, file.fileData.length);
})

It's also possible to combine this with pako in order to decode tarballs

var untar = require('untar.js')
var pako = require('pako')
var fs = require('fs')

var unzipped = pako.inflate(fs.readFileSync(__dirname + '/' + 'with-5.0.0.tgz'));

untar.untar(unzipped).map(function(file){
	console.log(file.filename)
})

It's pretty minimal as far as APIs go, it exposes a single method untar which can be passed an ArrayBuffer. It returns a list of TarLocalFile objects. The important fields are size, filename, and fileData.

Changelog

  • 0.2.3 — Fixing #2, thanks @jedie!
  • 0.2.2 — Fixing more decode bugs
  • 0.2.0 — Fixed a pretty major bug which led to decode errors from rounding to the wrong block.
  • 0.1.0 — Initial Release

FAQs

Package last updated on 15 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts