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

short-revs

v1.0.3

Published

shorten the revisions in a pouchdb-dump stream

Downloads

5

Readme

short-revs Build Status

Shorten the revs in a stream from pouchdb-replication-stream (or a dump from pouchdb-dump-cli).

Designed to be run over the entire stream (e.g. for a large initial dumpfile). Shortens all the revs to the smallest possible size while retaining uniqueness for that document.

Input:

{"docs":[{"_id":"bar","_rev":"1-315f3ff4beb880fc2888c6b5c314493c"}]}
{"docs":[{"_id":"baz","_rev":"1-77c56f7edfb51c6a5d51bf47b15a1f18"},{"_id":"buzz","_rev":"1-a34f0b7f5ef75d3911355f7398826bb7"},{"_id":"quux","_rev":"1-ed3e56a4f66dc55aa582d9ef24f9e6d9"},{"_id":"toto","_rev":"1-c803e606ca9c905d8126f03cc355e77c"},{"_id":"fifi","_rev":"1-c82778a17dab711489c8b95be0281e19"}]}
{"docs":[{"_id":"fubar","_rev":"1-5b8eb7bb8242571279aeea28dea01943","_deleted":true,"_revisions":{"start":1,"ids":["5b8eb7bb8242571279aeea28dea01943"]}},{"_id":"fubar","_rev":"1-3dd249bec829a05ab5aa998fc97952d1","_deleted":true,"_revisions":{"start":1,"ids":["3dd249bec829a05ab5aa998fc97952d1"]}},{"_id":"fubar","_rev":"2-f870e5f50110e158910807b783737331","_revisions":{"start":2,"ids":["3dd249bec829a05ab5aa998fc97952d1","f870e5f50110e158910807b783737331"]}}]}

Output:

{"docs":[{"_id":"bar","_rev":"1-A"}]}
{"docs":[{"_id":"baz","_rev":"1-A"},{"_id":"buzz","_rev":"1-A"},{"_id":"quux","_rev":"1-A"},{"_id":"toto","_rev":"1-A"},{"_id":"fifi","_rev":"1-A"}]}
{"docs":[{"_id":"fubar","_rev":"1-A","_deleted":true,"_revisions":{"start":1,"ids":["A"]}},{"_id":"fubar","_rev":"1-B","_deleted":true,"_revisions":{"start":1,"ids":["B"]}},{"_id":"fubar","_rev":"2-C","_revisions":{"start":2,"ids":["B","C"]}}]}

Usage

This module can be used via JavaScript or the command line.

Via the command line

npm install -g short-revs
short-revs < dumpfile.txt > smaller_dumpfile.txt

Via JavaScript

npm install short-revs
// db is a PouchDB with pouchdb-replication-stream set up
var db = ...

// stream is a stream
var stream = ...

// transform the stream
var shortRevs = require('short-revs');
db.dump(stream).pipe(shortRevs());

(See the tests for more example usages, including dumping to in-memory.)

In the browser

Need a browser build? Check out http://wzrd.in/standalone/short-revs.

Otherwise, feel free to browserify/webpack it yourself.

Test

npm test
npm run coverage

Coverage is 100%; check the tests if you need proof. :)