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 🙏

© 2026 – Pkg Stats / Ryan Hefner

flux-stores

v0.11.2

Published

Flux stores

Readme

Build Status Join the chat at https://gitter.im/ksnabb/flux-stores

Flux Stores

This library provides FLUX stores and is somewhat inspired by Backbone models and collections.

The library itself is written in es6 and compiled with babel.

NOTE!! you might have to include babel polyfill in your code to make it work in some browsers. e.g. require("babel/polyfill")

If you cannot find what you want in this README, check out the test runs, the code, the chat or issues.

Installation

To install simply run

npm install flux-stores --save

Then in your node / browserifyable code do:

var fluxStores = require("flux-stores");
var Model = fluxStores.Model;
var Collection = fluxStores.Collection;

Events

all will receive all events triggered with the following parameters

(eventType, args...)

Models

Create a Model

var m = new Model()

You can also pass in a js object that will be set as the values for the model.

var m = new Model({
  "id": "idofsomekind",
  "age": 30
});

set(obj) set the values to the model that are passed in the obj. Each value changed will trigger a change event.

var m = new Model({
  "age": 30
});
m.set({
  "age": 31
}); --> {"age": 31}

get(attrKey) get value for attribute by passing the key.

var m = new Model({
  "age": 24
});
m.get("age") --> 24

extend(extensionObject) To extend a Model use extend.

var MyModel = Model.extend({
  "initialize": function() {
    console.log("this is me");
  }
});

on(eventName, fun) Listen to events on the model with on.

var m = new Model({
  "age": 30
});
m.on("change", function(model) {
  // do something with the new values
});

on(eventName:property, fun) You can also listen to specific properties on a model with on.

var m = new Model({
  "age": 30
});
m.on("change:age", function(model) {
  // do something when age prop has changed
});

clear() will clear the model and leave it empty.

var m = new Model({
  "just": "good"
});
m.clear() --> {}

Collection

Create a collection

var col = new Collection()

You can also pass in an array of objects that will be set to the collection.

var col = new Collection([{"id": 1},{"id": 2}])

extend(extensionObject) You can extend and override the default functions and params of the collection with extend.

var MyCollectoin = Collection.extend({
  Model: MyModel,
  initialize: function() {
    console.log("hey init");
  },
  justDoSomething: function() {
    console.log("something");
  }
});

add(objs) add function adds the passed in js objects to the collection. If a model in the collection already contains another model with the same id they will be merged.

col.add([{"hello": "me", "id": 1}, {"hello": "you", "id": 2}, {"hello": "me again", "id": 1}]);
col.length --> 2

add(obj) Also single js objects can be added.

col.add({"hello": "I am single", "id": 123});

add(model) fluxStore models can also be added.

let m = new Model({"hello": "I am model", "id": 1});
col.add(m);

filter(filterFunction) Filter will return an array of models for which the filterFunction returns true.

var col = new Collection([{"age": 29},{"age": 30},{"age": 31}])
col.filter( (mod) => {
  if(mod.get("age") < 30) {
    return true;
  }
  return false;
}) --> [{"age": 29}]

map(mapFunction) Map will return an array of models that has been passed through the mapFunction.

var col = new Collection([{"age": 29},{"age": 31}]);
col.map(function(model) {
  return model.toJSON().age + 1;
}) --> [{"age": 31},{"age": 32}]

each(fun) Will apply the function 'fun' on all containing models.

var col = new Collection([{"age": 29},{"age": 31}]);
col.each(function(model) {
  model.set({"age": 1})
}) --> [{"age": 1},{"age": 1}]

where(attributes) Where will return the models that has equal attributes to the passed in attributes.

var col = new Collection([{"age": 29},{"age": 31}]);
col.where({
  "age": 31
}) --> [{"age": 31}]

findWhere(attributes) The same as where but returns the first model matched

var col = new Collection([{"age": 31, "id": 1},{"age": 31, "id": 2}]);
col.where({
  "age": 31
}) --> [{"age": 31, "id": 1}]

reset(models) reset will replace all models in a collection with the passed in models. If no models are passed in it will just empty the collection.

var col = new Collection([{"age": 31, "id": 1},{"age": 31, "id": 2}]);
col.reset([{
  "age": 31
}]) --> [{"age": 31}]