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

ar-async

v0.1.4

Published

Asynchronously read and write Unix archive files.

Downloads

72,007

Readme

ar

A Node library for asynchronously reading and writing Unix archive files. Currents supprts basic ar format, as well as BSD and GNU variants.

###ArReader

var ar = require('ar'),
    fs = require('fs'),
    path = require('path');

// extracts all of the files in "some_archive.a" to the folder "./output".
var outputDir = "./output";
if (!fs.existsSync(outputDir)) fs.mkdirSync(outputDir);

var reader = new ar.ArReader("some_archive.a");
reader.on("open", function() {
	// archive opened
});
reader.on("entry", function(entry, next) {
	// entry is an instance of ArEntry
	var name = entry.fileName();
	entry.fileData()
		.pipe(fs.createWriteStream(name))
		.on("finish", next);		
});
reader.on("error", function(err) {
	// archive reading error
});
reader.on("end", function() {
	// archive parsing ended
});
reader.on("close", function() {
	// archive closed
});

ArReader automatically detects and handles BSD and GNU variant formats. All events are optional, so you only have to listen for the ones you want.

###ArWriter

var ar = require('ar'),
    fs = require('fs'),
    path = require('path');

// write files into a new ar archive at "some_archive.a"
// in the case, specifies gnu variant format for long filenames
var writer = new ar.ArWriter("./some_archive.a", {variant:"gnu"});
writer.writeEntries([
		"./some_file",
		"./some_other_file",
		"./yet_another_file"
	], function() {
		// optional callback after completion
	});
writer.on("open", function() {
	// archive opened
});
writer.on("entry", function(entry) {
	// entry is an instance of ArEntry
	// signifies an entry has been written
	// unlike ArReader, there is no next function
});
writer.on("error", function(err) {
	// archive writing error
});
writer.on("finish", function() {
	// archive writing ended and closed
});

ArWriter by default will truncate filenames at 16 bytes long. For long file names, specify a variant format, like done above. Currently "GNU" and "BSD" are supported. Additionally, you can specify "uid", "gid", and "mode" number values in the options json; they will override the values for each file written. All events are optional, so you only have to listen for the ones you want.

###ArEntry See ar.js for inline ArEntry documention, but here are the key APIs

  • [ArEntry].fileName() - String - Filename of the file in the entry
  • [ArEntry].fileSize() - Number - Number of bytes the file takes up
  • [ArEntry].fileData() - Stream - Readable stream for file data
  • [ArEntry].date() - Date - Last modified date of the file
  • [ArEntry].uid() - Number - UID of the file
  • [ArEntry].gid() - Number - GID of the file
  • [ArEntry].mode() - Number - File mode

###License Licensed under the MIT License (MIT)

node-ar-async Copyright (c) 2014 Jason Robitaille. https://github.com/JayCanuck/node-ar-async

Based on, and including code from, from node-ar, Copyright (c) 2013 John Vilk. https://github.com/jvilk/node-ar