Skip to content
Simple rule-based filtering for node.js
JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.gitignore
.npmignore
LICENSE.txt
README.md
colander.js
package.json
test.js

README.md

Colander

Colander is a simple rule-based filtering tool. Keep the stuff you want, discard the stuff you don't.

installation

npm install colander

usage

Code speaks louder than words, so here we go. Say we have some spaghetti that's just finished cooking, so it's still in the water...

var pot = [
  {type: "spaghetti"},
  {type: "water"},
  {type: "spaghetti"},
  {type: "water"},
  {type: "water"},
  {type: "spaghetti"},
  {type: "spaghetti"},
  {type: "water"},
]

var colander = require('colander')
var strainer = colander({
  accept_when: {"type": "spaghetti"},
  reject_when: {"type": "water"}
})

// test some individual objects
strainer.strain({type: "spaghetti"}) // => true
strainer.strain({type: "water"}) // => false

// strain the whole pot at once
strainer.strain(pot)
Something went wrong with that request. Please try again.