npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

baltar

v1.0.1

Published

A few small utilities for working with tarballs and http.

Downloads

4

Readme

baltar

A few small utilities for working with tarballs and http. Because you need tarballs over HTTP like:

Usage

Fetch & send tarballs over the network

baltar.pull(opts, callback)

Makes a request to opts.url and unpacks it to opts.path. baltar.pull is the only method which accepts a callback so that it pass back all of the entries from the tar.Extract stream. The end of pipechain is also returned for future stream operations (if desired).

  • opts.url: {string} Location of the receiver.
  • opts.headers: {Object} HTTP headers to send.
  • opts.method: {string} HTTP Method to send.
  • opts.path: {string} Directory or file to unpack to.
  • opts.tarball: {string} Optional Path to save tarball to.
  • returns: {tar.Extract} Extraction stream for the pulled tarball.
baltar.pull({
  url: 'https://example.com/path/to/any/file.tgz',
  path: 'location/to/untar/into',
}, funciton (err, entries) {
  //
  // Unpacked tarball now exists in
  // 'location/to/untar/into'. All
  // tar entries are returned to work with
  //
  var filenames = entries.map(function (entry) {
    return e.path;
  });

  console.log(filenames);
});
baltar.push(opts)

Pushes a tarball created from opts.path to opts.url optionally accepting a opts.method and returns a stream that represents the response.

  • opts.path: Directory or file to pack
  • opts.ignoreFiles: Extra ignore files to parse
  • opts.url: {string} Location of the receiver.
  • opts.headers: {Object} HTTP headers to send.
  • opts.method: {string} HTTP Method to send.
  • returns: {hyperquest} HTTP request stream to opts.url.
baltar.push({
  path: 'directory/or/file/to/pack',
  url: 'http://example.com/path/to/tarball/uploaded.tgz'
})
.on('error', function (err) {
  // Handle any HTTP errors (e.g. Internet is down, etc.)
  console.dir(err);
})
.on('finish', function () {
  console.log('HTTP request finished.')
});

The stream returned is an instance of hyperquest, so you can perform any additional stream operations on it.

Pack and unpack tarballs locally

baltar.unpack(opts)

Returns a stream which will unpack and stream into the specified opts.path.

  • opts: {Object|string} Options for unpacking tarball.
  • opts.path: Directory or file to unpack to
  • returns: {Stream} Gunzip and untar pipechain to opts.path.
fs.createReadStream('path/to/any/file.tgz')
  .pipe(baltar.unpack({ path: 'location/to/untar/into' }))
  .on('error', function (err) {
    // Handle any HTTP errors (e.g. bad tarball, etc.)
    console.dir(err);
  })
  .on('entry', function (e) { entries.push(e.path); })
  .on('done', function () {
    //
    // Unpacked tarball now exists in
    // 'location/to/untar/into'.
    //
  });
baltar.pack(opts)

Returns a stream representing the tar.gz packed version of opts.dir.

  • opts: {Object|string} Options for packing tarball.
  • opts.path: Directory or file to pack.
  • opts.ignoreFiles: Extra ignore files to parse.
baltar.pack('just/a/path/also/works')
  .pipe(hyperquest.post('http://example.com/tarball/uploaded.tgz'))
LICENSE: MIT
AUTHOR: Charlie Robbins