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

dat-folder-archive

v1.1.1

Published

create a .dat folder db and return a hyperdrive archive

Downloads

9

Readme

dat-folder-archive Travis npm

Creates an archive in a folder using the .dat folder database.

  • Creates an archive with base as dir
  • Create/Open a level db in dir/.dat
  • Resumes existing archives

Similar to dat-folder-db, but also creates an archive and saves the key to the database.

Usage

Use dat-folder-archive to create a .dat folder and get the archive & database to be used in other modules.

For example, to import the current directory, share it over the dat network, and track the stats:

var folderArchive = require('dat-folder-archive')
var hyperdiscovery = require('hyperdiscovery')
var hyperstats = require('hyperdrive-stats')
var hyperimport = require('hyperdrive-import-files')

var dir = process.cwd()

folderArchive(dir, {resume: false}, function (err, archive, db) {
  if (err) return cb(err)
  console.log('archive ready')

  // import files from cwd
  var importer = hyperimport(archive, dir, function (err) {
    console.log('done importing')
  })

  // join the network & start replication
  var swarm = hyperdiscovery(archive)

  // track stats for the archive
  var stats = hyperstats({archive: archive, db: db})
  stats.on('update', function () {
    console.log(stats.get())
  })
})

API

datFolderArchive(directory, [opts], callback)

Creates a hyperdrive archive in directory, including making a .dat database, using dat-folder-db.

The callback returns cb(err, archive, db).

Options are passed to hyperdrive. They can include:

opts = {
  live: true, // archive is live
  resume: null, // force resume (see below)
  file: raf(dir, name) // file option for hyperdrive archive
}

Creating and Resuming an Archive

The .dat folder can be used to persist an archive in a folder. When creating a new archive in a directory, use opts.resume to specify what you're expecting in the folder:

  • resume = false: create an archive only if no archive exists in the given directory.
  • resume = true: resume an archive only if it already exists and, if specified, opts.key matches the key in the .dat folder.
  • resume = null (default): create or resume an archive. If opts.key is specified, check to make sure key matches.

The callback will set archive.resumed = true if the archive was resumed, not newly created.

License

MIT