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

stream-sift

v0.2.2

Published

A minimal high-performance specification-backed stateful object matching engine

Downloads

13

Readme

stream-sift

A minimal high-performance specification-backed stateful object matching engine

Installation

Until this project is published do this:

npm install --save stream-sift

Overview

What

stream-sift is a document [1] pattern-matching library. If you have used mongoDB query search syntax, this will feel familiar. Also, because stream-sift works at the document level, it is suitable to build higher-level abstractions that compile down to a stream-sift schema (eg: a RQL-like library). However, direct document pattern-matching can be (or is the) correct API sometimes (eg: HTTP payloads, function argument pattern-matching, ...).

[1] "Document" in the NoSQL sense; JavaScript "objects", Ruby "hashes", Elm "records", etc.

How

stream-sift is divided into a "core" and "library". The core is an engine suitable for building arbitrary $functions on top of. Currently this project is "batteries included" meaning that a $function library is included, but is entirely modular and apart from core. In the future the $function library will be made its own project.

$fn API

$eq / $neq

Check for an exact match.

{ input: { percent: 10 } }
{ input: { percent: { $eq: 10 } } } // true
{ input: { percent: { $eq: 20 } } } // false

You should not have to use $eq directly because it is the default semantic:

{ input: { percent: 10 } // true
{ input: { percent: 20 } } // false

$gt / $gte / $lt / $lte

Check for numeric conditions.

{ input: { percent: 10 } }
{ input: { percent: { $gt: 9 } } } // true
{ input: { percent: { $gt: 10 } } } // false
{ input: { percent: { $gte: 9 } } } // true
{ input: { percent: { $gte: 10 } } } // true
{ input: { percent: { $lt: 9 } } } // false
{ input: { percent: { $lt: 10 } } } // false
{ input: { percent: { $lte: 9 } } } // false
{ input: { percent: { $lte: 10 } } } // true

$cross / $crossOrEqual

$c / $ce

Non-directional threshold functions. Check if a number crosses a given level.

{ input: { percent: 10 } },   { input: { percent: 50 } },   { input: { percent: 10 } }
{ input: { percent: { $cross: 50 } } } // false, false, false
{ input: { percent: { $cross: 40 } } } // false, true, true
{ input: { percent: { $crossOrEqual: 50 } } } // false, true, true

$crossGreaterThan / $crossGreaterThanOrEqual / $crossLessThan / $crossLessThanOrEqual

$cgt / $cgte / $clt / $clte

Directional threshold functions. Check if numbers rise/fall (respective to the function) past a given level.

{ input: { percent: 10 } },   { input: { percent: 70 } },   { input: { percent: 30 } }
{ input: { percent: { $crossGreaterThan: 69 } } } // false, true, false
{ input: { percent: { $crossGreaterThan: 70 } } } // false, false, false
{ input: { percent: { $crossGreaterThanOrEqual: 69 } } }  // false, true, false
{ input: { percent: { $crossGreaterThanOrEqual: 70 } } }  // false, true, false
{ input: { percent: { $crossLessThan: 30 } } } // false, false, false
{ input: { percent: { $crossLessThan: 31 } } } // false, false, true
{ input: { percent: { $crossLessThanOrEqual: 30 } } }  // false, false, true
{ input: { percent: { $crossLessThanOrEqual: 31 } } }  // false, false, true

$not

Negate the sub-expression.

{ input: { percent: 100, foo: 'bar' } }, { input: { percent: 100, foo: 'zed' } }, { input: { percent: 50, foo: 'zed' } }
{ input: { $not { percent: 100 } } } // false, false, true

$or / $nor / $xor / $and / $nand

Logical functions.

{ input: { percent: 100, foo: 'bar' } }, { input: { percent: 100, foo: 'zed' } }, { input: { percent: 50, foo: 'zed' } }
{ input: { $or [ { percent: 100 }, { foo: 'bar' } ] } } // true, true, false
{ input: { $nor [ { percent: 100 }, { foo: 'bar' } ] } } // false, false, true
{ input: { $xor [ { percent: 100 }, { foo: 'bar' } ] } } // false, true, false
{ input: { $and [ { percent: 100 }, { foo: 'bar' } ] } } // true, false, false
// $and is the default semantic; thus usually does not need to be used directly:
{ input: { percent: 100, foo: 'bar' } } // true, false, false
{ input: { $nand [ { percent: 100 }, { foo: 'bar' } ] } } // false, true, true

Roadmap

New $fns

  • $in
  • $nin
  • $regex