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

tree-filter

v0.0.4

Published

Stateful expression tree for set algebra

Downloads

19

Readme

Tree Filter

A stateful binary expression tree for set algebra. Nodes in the tree are Node.js EventEmitters, providing granular control of each part of the expression. Nodes representing an operation cache their result set, and re-cache their result when their child nodes change.

Install

$ npm install tree-filter

Use

var Filter = require('tree-filter');

var filter = new Filter();
var node = filter.add(['one', 'two', 'three']);
filter.add(['two', 'three', 'four']);
var resultSet = filter.results()
// returns the intersection by default: `['two', 'three']`

filter.remove(node);
filter.results();  // returns `['two', 'three', 'four']`

API

TreeFilter()

Construct an empty expression tree. The tree is an EvenEmitter and emits 'change' events if the expression changes.

add(array set [string operation])

Add the given set to the tree, using operation. Operations for now are only 'intersect'or 'union'. Operations can be referenced as properties on a filter instance: filterInstance.ops.intersect.

Returns LeafNode -- the tree node that was created for this set. This is a Node.js EvenEmitter, emitting a 'destroy' event.

removeNode(Node Node)

Remove the given Node from the tree. A Node is an instance of Node, returned by calling TreeFilter.add. Removing a node will update the results of the expression and emit a 'change' event on the tree instance.

results()

Returns the set that results from computing the expression, or false if the expression is empty.

Returns Array