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

easier-level-multiplexer

v1.0.6

Published

Multiplex leveldowns--accessing values from multiple stores through one

Downloads

15

Readme

easier-level-multiplexer

A level-multiplexer designed with easier-abstract-leveldown in mind (still compatible with abstract-leveldown)

Multiplex a single leveldown compatible store to many, determining which store will have a copy of the value based on some mapper function which utilizes the value.

Is similar but slightly more versitile than level-mount as instead of depending on the key, it enables you to sort based on the value. This however results in more overhead because you have to save pointers to the values in the multiplexed stores.

Fortunately this project supports singular values existing in multiple backend stores (replication), it also abuses the easier-leveldown post method enabling the put keys of the level-multiplexer to be completely independent of the keys in the replicated stores (which are obtained via a post).

Example:

const hybrid_db = levelup(levelmount({
  store: leveldown('root'),
  options: {}, // options for leveldown open
  stores: [
    {
      key: 'fallback',
      store: memdown(),
    },
    {
      key: 'a',
      store: memdown(),
    },
    {
      key: 'b',
      store: someotherdown(),
      options: {}, // someotherdown options for leveldown open
    }
  ],
  // We'll map based on a `stores` variable which takes a list
  mapper: (v) => {
    const stores = v.stores.filter((store) => ['a', 'b'].indexOf(store))
    if (stores.length === 0)
      return ['fallback']
    return stores
  }
})

hybrid_db.put('hello', { stores: ['a', 'b'], doc: 'whatever' }) // ends up in stores `a` and `b` with an arbitrarily generated keys for each
hybrid_db.put('goodbye', { stores: [], doc: 'whatever' }) // ends up in store `fallback` with an arbitrarily generated key

hybrid_db.get('hello') // fetches the document versions back from the `a` and `b`, potentially dealing with collisions

It also supports the features of easier-abstract-leveldown, including post, propagation of changes from underlying easier leveldowns.