matching

Find list items by example

Usage no npm install needed!

<script type="module">
  import matching from 'https://cdn.skypack.dev/matching';
</script>

README

Build Status

Tiny utility to filter lists by example

Example:

var matching = require('matching');

var list = [
  { type: 'foo', foo: 23 },
  { type: 'foo', foo: 42 },
  { type: 'bar', bar: 23 }
];

var foo = matching({ type: 'foo' }, list);
// => [ { type: 'foo', foo: 23 }, { type: 'foo', foo: 42 } ]

About

This package has been written to accompany tools like flatten, uniqs or intersect as simple and lightweight alternative to utility collections like underscore or lodash where you could achieve the same result like this:

_.where(list, {type: 'foo'});

The order of the arguments has been reveresed to allow currying.

License

MIT