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

webdup

v0.1.1

Published

Client and server for the dataset update protocol

Downloads

2

Readme

webdup.js - web dataset update protocol

NPM version

Status: in progress

The Dataset API

Inside both the client and server, application code interacts with webdup code mostly by each of them modifying and listening for modifications to one or more "dataset" objects.

By default, we create datasets as instances of KeyedSet, but you're welcome to provide your own, as long as they conforms to the same interface.

Specifically, the server needs:

  • ds.on('change', ...)
  • ds.diff(...)
  • ds.clone()

And the client needs:

  • ds.change(...)

Typically the application code on the server will be changing the dataset and the application code on the client will be using the latest state and/or listening for changes.

On both sides, if possible, the dataset should provide a .etag property whose value is a string which will be different for every state of the dataset, statistically speaking. While it's tempting to make this as SHA-256 of the dataset, any deletion would require recomputing the entire hash. A suggested alternative is to hash each element separately, and have the etag be the XOR of all the hashes. This is not as secure, but should be sufficient for accurately identifying versions.

The dataset should also provide:

  • ds.stringify([items]) => string

Given an array (not just an iterable) of zero or more items or their keys (as per KeyedSet), return a string which encodes them such that they can be reconstructed by ds.parse. JSON.stringify should generally work for this.

  • ds.parse(str) => [items]

Parse a string of the preferred serialization format and return an iterable of zero or more items encountered. JSON.parse works, given the string encodes an array, as above.

  • new ds.Parser()

In addition to parse(), the dataset may provider a streaming parser implementing writableStream, allowing data to be made available while arriving over the network and with less buffering.

  • new ds.Stringifier()

In addition to stringify(), the dataset may provide a streaming serializer, a readableStream, which can be piped to a suitable output stream.

Issues

Browsers limit the number of streams per origin, so EventSource() wont work in parallel beyond about 5. (This is a reason to use WebSockets as the underlying transport. That, and better flow control. Also, serializing as text vs allowing cbor, which might be nice.) Workarounds? Multiple origins, via servers on different ports or hostnames. Or a combined EventSource() for multiple resources; add a "path:" field, and let the URL include ?paths=....&etags=.... matched arrays. Or path2, etag2, etc. Or JSON.stringified array of {path, etag}. So Link: <...>; rel=.../webdup-service That'd be a nice thing anyway, one stream per origin (per user).