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 🙏

© 2025 – Pkg Stats / Ryan Hefner

cumulo

v0.0.1

Published

Server data store built by learning from Flux

Downloads

11

Readme

Cumulo: Flux like architechture on server

Cumulo is a realtime framework for small apps. It's designed like Flux to work with React.

Action Schema

This is the schema of actions used to connect server and clients:

action =
  name: 'scope/behavior'
  data: "JSON Data"

Usage

npm i --save cumulo

Here are the methods and constructors exposed:

exports.router = require './router'
exports.database = require './database'

exports.State = require './state'
exports.Store = require './store'
exports.Scene = require './scene'
exports.View = require './view'

exports.push = (state, name, data) ->
  action = {name, data}
  raw = JSON.stringify action, null, 2
  state.ws.send raw

State

State needs to be intrdoces first, it's plain Object.

  • .userId will be used to detect if used logined.
  • .cache is a place for holding cache, and removed with state
  • .ws is also important, cumulo uses state.ws to push data to client
wss = new Server port: 3000
wss.on 'connection', (ws) ->

  state =
    # states will dispatch based on userId?
    userId: null
    id: shortid.generate()
    cache: {}
    ws: ws
    userId: null
    page:
      message: 1
      thread: 1
      step: 5

Router

cumulo = require 'cumulo'
router = cumulo.router

# for debugging
router.display = (state, action) ->
  console.log state.userId, action

# events in router are mostly actions from websocket
ws.on 'message', (raw) ->
  data = JSON.parse raw
  router.dispatch state, data

# and we will do this in a store
router.register 'account/login', (state, data) ->

Database

It's actually a JSON in memory, with frequently writing to disk:

cumulo = require 'cumulo'

cumulo.database.init
  # how long does it saves to disk
  duration: 100000

  dbPath: path.join __dirname, '../data/database.json'

  initialData:
    # JSON object

  gatherData: ->
    # collect data before saving

  onLoad: (json) ->
    # get JSON data, and dispatch to stores

State

And example of state, actually it's states of all websockets. First you need to define a file named states:

cumulo = require 'cumulo'
lodash = require 'lodash'

router = cumulo.router
states = new cumulo.State

module.exports = states

router.register 'state/morePage', (state, data) ->
  # it's also a dispatcher listened by scenes
  states.dispatch state

and with .record .unrecord to keep track of all states:

states.record state
console.info 'state record', state.id
ws.on 'close', ->
  states.unrecord state
  console.info 'state unrecord', state.id
  state = null

Store

cumulo = require 'cumulo'
router = cumulo.router

# initial data will be used in patching
# and it's mostly [] or {}
store = new cumulo.Store data: []

# store responds to router, and it's a dispatcher listend by scene too
router.register 'profile/add', (state, data) ->
  store.data.push data
  store.dispatch()

Scene

cumulo = require 'cumulo'

states = require '../states'
client = require '../view/client'

module.exports = new cumulo.Scene
  # default value
  data: {}
  # duration of the looper to check .changed
  duration: 400

  broadcast: ->
    # define how to notify all clients
    states.each (state) =>
      client.patch state, world: @get()

  listen: ->
    # when store changes, mark this scene changed
    messagesStore.register =>
      @changed = yes
    # when state changes, call view patching
    states.register (state) =>
      client.patch state, world: @get()

  render: ->
    # returns an object representing the whole world

View

View represents a single user's perspective of a scene:

cumulo = require 'cumulo'
lodash = require 'lodash'

module.exports = new cumulo.View
  # a name to caching data in state.cache
  cacheName: 'client'

  # here we use comulo.push to send data
  syncSolution: (state, data) ->
    cumulo.push state, 'client/sync', data

  patchSolution: (state, data) ->
    cumulo.push state, 'client/patch', data

  # renderer when state.userId is null
  renderGuest: ->
    # JSON data, will be diffed

  # renderer when state.userId is defined, meaning loginged
  renderUser: (state, scene) ->
    # JSON data, will be diffed

See chat-distract for Details.

License

MIT