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

space-shuttle

v0.5.2

Published

wip append-only scuttlebutt db with nested data

Downloads

5

Readme

space-shuttle

Work in progress append-only scuttlebutt db with nested data. Requires node >= 0.12.

npm status Travis build status AppVeyor build status Dependency status

features

  • Nested data; construct object graphs of any size
  • Retains full history. Data can't be truly deleted, but you can erase data. Erasing is like saying: "Forget that value I sent in an earlier update".
  • Streaming replication with eventual consistency. The only thing it needs to keep in memory is the latest timestamp of each source (to save unnecessary writes) (even without this, old updates will effectively be ignored because of how the db is ordered).
  • Tested in Node.js (0.12, 4 and 5) and Google Chrome with leveldown (node), a fork of level.js (Chrome) and memdown (both). Note: in the browser I've seen a CPU usage of ~25%, during the initial sync of 60.000+ items.
  • ~~Compatible with scuttlebutt/model~~

missing features

  • Verification. You must control or be able to trust the peers. Currently, only the update format is validated (invalid updates are ignored). But a peer can send an update with a timestamp in the far future, which would invalidate all other future updates. It can also impersonate other peers, send updates on their behalf.
  • Lists. You can write to ["a", 0] but not read it out as an array.
  • Sublevels/prefixes/cursors
  • Behavior is undefined if you write values to ["a"] and a sub-property ["a", "a"]. One does not invalidate the other.
  • Browsing a certain point in time. You can ask for "newer than x", but not "older than x". It's theoretically possible because space-shuttle saves data twice: newest-first (for object graphs) and oldest-first (for replication).
  • Bytespace is the biggest bottleneck right now, maybe I'll switch to a handcoded thing with lexints etc

example

Example is out of date. I moved the drain event from the db to the stream, as commit. This way, streams can't block each other. The sync event means the initial sync is done (and committed), commit means subsequent updates have been committed.

const space = require('space-shuttle')
    , assert = require('assert')
    , disk = require('test-level')({ clean: true })

const db1 = space('source a', disk())
    , db2 = space('source b', disk())

db1.batch([
  { path: ['penguins', 'henry', 'age'], value: 14 },
  { path: ['penguins', 'henry', 'hobby'], value: 'ice skating' }
], function(err) {
  // Setup live replication
  const s1 = db1.replicate()
      , s2 = db2.replicate()

  s2.pipe(s1).pipe(s2).once('sync', function(){
    // Construct a tree from the updated history
    db2.tree(['penguins'], function(err, tree){
      console.log('db2', tree)

      assert.deepEqual(tree, {
        henry: {
          age: 14,
          hobby: 'ice skating'
        }
      })

      // Note: without callbacks, you should add db.on('error', cb)
      db2.put(['penguins', 'henry', 'age'], 15)
      db2.put(['penguins', 'henry', 'likes'], ['emma', 'sunshine'])

      // Wait for db1 to have received and saved these updates
      db1.once('drain', function() {
        db1.tree(['penguins', 'henry'], function(err, tree){
          console.log('db1', tree)

          assert.deepEqual(tree, {
            age: 15,
            hobby: 'ice skating',
            likes: ['emma', 'sunshine']
          })
        })
      })
    })
  })
})

install

With npm do:

npm install space-shuttle

license

MIT © Vincent Weevers