🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

filter-observable-store

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
f

filter-observable-store

Filter down an observable-store

0.0.2
latest
69

Supply Chain Security

100

Vulnerability

84

Quality

76

Maintenance

100

License

Version published
Maintainers
1
Created
Issues
0

Filter-observable-store

Filter down an observable store https://github.com/flams/observable-store.

A filtered observable-store will:

  • Return a count of items that match the filter
  • Only loop over items that match the filter
  • Only trigger events on items that match the filter

Installation

npm install filter-observable-store

How to use

var Store = require("observable-store");
var Filter = require("filter-observable-store");

var store = new Store([5, 10, 15]);

// Create a new filter around an existing store
var filter = new Filter(store);


// Set a filter function
filter.setFilter(function (value) {
    return value >= 10;
}, scope);

// Get filtered count:
filter.count(); // 2

// Loop over filtered items
filter.loop(function (value) {
    // value... 10, 15...
});

// See if an item is in the filtered model
filter.has(5); // false
filter.has(10); // true

// Clear filter
filter.clearFilter();

Changelog

0.0.2 - 6 APR 2015

  • Add filtered has()

0.0.1 - 5 APR 2015

  • first release

License:

MIT

FAQs

Package last updated on 07 Apr 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts