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 🙏

© 2025 – Pkg Stats / Ryan Hefner

bagit-fs

v1.1.1

Published

node fs implementation for bagit format

Downloads

18

Readme

bagit-fs

node fs implementation for the bagit spec.

npm travis standard

Install

npm install bagit-fs

Usage

var BagIt = require('bagit-fs')

var bag = BagIt('/put/my/bag/here', 'sha256', {'Contact-Name': 'Joe Hand'})

// write files to bag's data folder
fs.createReadStream('readme.md').pipe(bag.createWriteStream('/readme.md'))

// ... LATER after all files are written
bag.finalize(function () {
  console.log('finalized')
})

See example/index.js for an example usage with mirror-folder.

API

var bag = BagIt(dest, algorithm, [bagInfo])

  • dest is the destination directory for the bag
  • algorithm is a string specifying which checksum algorithms to use. Default is sha256.
  • bagInfo is a object with data to be written to bag-info.txt, e.g. bagInfo = {'Contact-Name': 'Joe Hand'}. See below for details on bag-info.txt.

bag.finalize(cb)

Finalize the bag, writing bag-info.txt and bagit.txt. Date and size are automatically written to the info. This should only be called when the bag is complete.

Using Finalized Bags

bag.readFile(name, [opts], cb)

Read a file from a completed bag. File is verified with checksum in manifest unless opts.verify === false.

bag.readManifest(callback(err, entries))

Get all entries in the manifest.

bag.getManifestEntry(name, callback(err, entry))

Get specific entry {checksum: <hash>, name: data/file.txt} in the manifest.

fs API

Several of the node fs functions are implemented allowing you to create or read from bags like the fs. Most of these just wrap the fs calls to act on the bag's data folder.

  • bag.createWriteStream(name, opts, cb) - writes file to bagDir/data and the checksum hash to the manifest.
  • bag.mkdir(name, opts, cb) - make a dir in the data/ folder.
  • bag.createReadStream(name, opts, cb) - file is not verified with manifest (yet).
  • bag.mkdir(name, cb)
  • bag.stat(name, cb)
  • bag.lstat(name, cb)
  • bag.readdir(name, cb)
  • bag.unlink(name, cb)
  • bag.rmdir(name, cb)

BagIt Spec Support

bagit-fs is a fully compliant implementation of the specification but there are some optional parts not yet implemented.

TODO:

Bag Info

bag-info spec

The "bag-info.txt" file is a tag file that contains metadata elements describing the bag and the payload. The metadata elements contained in the "bag-info.txt" file are intended primarily for human readability. All metadata elements are optional and MAY be repeated.

Bagging-Date and Bag-Size are written automatically on bag.finalize().

Here is an example "bag-info.txt" file:

Source-Organization: Spengler University
Organization-Address: 1400 Elm St., Cupertino, California, 95014
Contact-Name: Edna Janssen
Contact-Phone: +1 408-555-1212
Contact-Email: [email protected]
External-Description: Uncompressed greyscale TIFF images from the
    Yoshimuri papers colle...
Bagging-Date: 2008-01-15
External-Identifier: spengler_yoshimuri_001
Bag-Size: 260 GB
Payload-Oxum: 279164409832.1198
Bag-Group-Identifier: spengler_yoshimuri
Bag-Count: 1 of 15
Internal-Sender-Identifier: /storage/images/yoshimuri
Internal-Sender-Description: Uncompressed greyscale TIFFs created
    from microfilm and are...

License

MIT