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

combox

v1.0.0-alpha

Published

A PouchDB plugin that mirrors a database with a Dat archive.

Downloads

5

Readme

ComBox

Build Status Coverage Status Stability NPM Version JS Standard Style

A PouchDB plugin that mirrors the database with a Dat archive using Beaker's DatArchive API. As a result, you can use ComBox in the browser with Beaker! To use it in NodeJS, you'll need node-dat-archive.

Install

You can get ComBox with npm:

$ npm i combox

Once installed, you can require() it in your projects:

const PouchDB = require('PouchDB')
const ComBox = require('combox')
PouchDB.plugin(ComBox)

const db = new PouchDB('combox')
await db.setupDatArchive()

Once the archive has been set up, its contents will be automatically mirrored to PouchDB.

If you cannot write to the attached archive, any calls to destructive methods like .bulkDocs will fail. Read-only methods like .get() and .query() will continue to operate normally.

Usage

ComBox

The ComBox plugin adds and modifies some methods. They are documented here:

async .setupDatArchive([options])

Creates, loads, or simply attaches an archive to the database, and initializes the mirroring process.

Parameters:

  • options: Options object.
  • options.archive: A specific archive to mirror. Must have been created using DatArchive.
  • options.DatArchive: A DatArchive constructor. Use this parameter with node-dat-archive if you are writing a server-side application.
  • options.options: Options for DatArchive when it constructs the archive. Only useful when the constructor from node-dat-archive is used, as Beaker's does not take options.
  • options.url: A Dat URL to follow. Following an archive you cannot write to will block destructive methods like .bulkDocs().

async .bulkDocs(docs, [options], [callback])

ComBox wraps PouchDB#bulkDocs to mirror writes, including deletes, to the archive. Because of how PouchDB performs writes internally, wrapping this method causes other methods like .put, .post, and .remove to also affect the archive.

The parameters are unchanged from the original.

async .destroy([options], [callback])

Wraps PouchDB#destroy to also stop sharing the associated archive and destroy any associated files.

The parameters are unchanged from the original.

Development

To hack on ComBox, check out the issues page. To submit a patch, submit a pull request.

To run the test suite, use npm test in the source directory:

$ git clone garbados/combox
$ cd combox
$ npm i
$ npm test

A formal code of conduct is forthcoming. Pending it, contributions will be moderated at the maintainers' discretion.

License

Apache-2.0