{"_id":"filter-where","_rev":"50728","name":"filter-where","description":"Filter an array using any combination of scalars, object queries, functions or regular expressions.","dist-tags":{"latest":"2.0.0"},"maintainers":[{"name":"75lb","email":"75pound@gmail.com"}],"time":{"modified":"2021-06-03T10:15:30.000Z","created":"2016-02-25T11:49:06.420Z","2.0.0":"2018-11-28T22:39:03.227Z","1.0.1":"2016-02-25T12:00:00.151Z","1.0.0":"2016-02-25T11:49:06.420Z"},"users":{},"author":{"name":"Lloyd Brookes","email":"75pound@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/75lb/filter-where.git"},"versions":{"2.0.0":{"name":"filter-where","author":{"name":"Lloyd Brookes","email":"75pound@gmail.com"},"version":"2.0.0","description":"Filter an array using any combination of scalars, object queries, functions or regular expressions.","repository":{"type":"git","url":"git+https://github.com/75lb/filter-where.git"},"license":"MIT","keywords":["where","array","filter","custom"],"engines":{"node":">=6"},"scripts":{"test":"test-runner test.js","docs":"jsdoc2md -t jsdoc2md/README.hbs index.js > README.md; echo"},"devDependencies":{"test-runner":"^0.5.1"},"dependencies":{"test-value":"^3.0.0"},"gitHead":"a7bc9fe8f603c2248ce7ca7891e5b8c449943ba1","bugs":{"url":"https://github.com/75lb/filter-where/issues"},"homepage":"https://github.com/75lb/filter-where#readme","_id":"filter-where@2.0.0","_npmVersion":"6.4.1","_nodeVersion":"11.2.0","_npmUser":{"name":"75lb","email":"75pound@gmail.com"},"dist":{"shasum":"b6803b017cf94b4cb879e769248feb05b3356cf6","size":3042,"noattachment":false,"key":"/filter-where/-/filter-where-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/filter-where/download/filter-where-2.0.0.tgz"},"maintainers":[{"name":"75lb","email":"75pound@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/filter-where_2.0.0_1543444742960_0.2737863844859503"},"_hasShrinkwrap":false,"publish_time":1543444743227,"_cnpm_publish_time":1543444743227},"1.0.1":{"name":"filter-where","author":{"name":"Lloyd Brookes","email":"75pound@gmail.com"},"version":"1.0.1","description":"Filter an array using any combination of scalars, object queries, functions or regular expressions.","repository":{"type":"git","url":"git+https://github.com/75lb/filter-where.git"},"license":"MIT","main":"./lib/filter-where.js","keywords":["where","array","filter","custom"],"engines":{"node":">=0.10.0"},"scripts":{"test":"tape test/*.js","docs":"jsdoc2md2 -t jsdoc2md/README.md lib/*.js > README.md; echo"},"devDependencies":{"tape":"^4.4.0"},"dependencies":{"test-value":"^1.0.1"},"gitHead":"7c576932076f7bd4ed9c534e7b00f2e24151bb87","bugs":{"url":"https://github.com/75lb/filter-where/issues"},"homepage":"https://github.com/75lb/filter-where#readme","_id":"filter-where@1.0.1","_shasum":"1b042569edce36bc1c4e9f73740d2c4e2feef77d","_from":".","_npmVersion":"3.7.5","_nodeVersion":"5.7.0","_npmUser":{"name":"75lb","email":"75pound@gmail.com"},"dist":{"shasum":"1b042569edce36bc1c4e9f73740d2c4e2feef77d","size":3104,"noattachment":false,"key":"/filter-where/-/filter-where-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/filter-where/download/filter-where-1.0.1.tgz"},"maintainers":[{"name":"75lb","email":"75pound@gmail.com"}],"_npmOperationalInternal":{"host":"packages-6-west.internal.npmjs.com","tmp":"tmp/filter-where-1.0.1.tgz_1456401597358_0.14866211777552962"},"directories":{},"publish_time":1456401600151,"_cnpm_publish_time":1456401600151,"_hasShrinkwrap":false},"1.0.0":{"name":"filter-where","author":{"name":"Lloyd Brookes","email":"75pound@gmail.com"},"version":"1.0.0","description":"filter-where","repository":{"type":"git","url":"git+https://github.com/75lb/filter-where.git"},"license":"MIT","main":"./lib/filter-where.js","keywords":["where","array","filter","custom"],"engines":{"node":">=0.10.0"},"scripts":{"test":"tape test/*.js","docs":"jsdoc2md2 -t jsdoc2md/README.md lib/*.js > README.md; echo"},"devDependencies":{"tape":"^4.4.0"},"dependencies":{"test-value":"^1.0.1"},"gitHead":"9d63d9b6bb511eb3d8b829a76cf432057c0b1976","bugs":{"url":"https://github.com/75lb/filter-where/issues"},"homepage":"https://github.com/75lb/filter-where#readme","_id":"filter-where@1.0.0","_shasum":"cf69613bfcaef00d754339fc523a5220e7b92aa7","_from":".","_npmVersion":"3.7.5","_nodeVersion":"5.7.0","_npmUser":{"name":"75lb","email":"75pound@gmail.com"},"dist":{"shasum":"cf69613bfcaef00d754339fc523a5220e7b92aa7","size":2910,"noattachment":false,"key":"/filter-where/-/filter-where-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/filter-where/download/filter-where-1.0.0.tgz"},"maintainers":[{"name":"75lb","email":"75pound@gmail.com"}],"_npmOperationalInternal":{"host":"packages-5-east.internal.npmjs.com","tmp":"tmp/filter-where-1.0.0.tgz_1456400945269_0.6231970840599388"},"directories":{},"publish_time":1456400946420,"_cnpm_publish_time":1456400946420,"_hasShrinkwrap":false}},"readme":"[![view on npm](http://img.shields.io/npm/v/filter-where.svg)](https://www.npmjs.org/package/filter-where)\n[![npm module downloads](http://img.shields.io/npm/dt/filter-where.svg)](https://www.npmjs.org/package/filter-where)\n[![Build Status](https://travis-ci.org/75lb/filter-where.svg?branch=master)](https://travis-ci.org/75lb/filter-where)\n[![Dependency Status](https://david-dm.org/75lb/filter-where.svg)](https://david-dm.org/75lb/filter-where)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](https://github.com/feross/standard)\n\n<a name=\"module_filter-where\"></a>\n\n## filter-where\nFilter an array using any combination of scalars, object queries, functions or regular expressions.\n\n<a name=\"exp_module_filter-where--where\"></a>\n\n### where(query) ⇒ <code>function</code> ⏏\n**Kind**: Exported function  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| query | <code>any</code> \\| <code>Array.&lt;any&gt;</code> | one or more queries |\n\n**Example**  \nSay you have a recordset:\n```js\n> data = [\n    { name: 'Dana', age: 30 },\n    { name: 'Yana', age: 20 },\n    { name: 'Zhana', age: 10 }\n]\n```\n\nYou can return records with properties matching an exact value:\n```js\n> data.filter(where({ age: 10 }))\n[ { name: 'Zhana', age: 10 } ]\n```\n\nor where NOT the value (prefix the property name with `!`)\n```js\n> data.filter(where({ '!age': 10 }))\n[ { name: 'Dana', age: 30 }, { name: 'Yana', age: 20 } ]\n```\n\nmatch using a function:\n```js\n> function over10(age){ return age > 10; }\n> data.filter(where({ age: over10 }))\n[ { name: 'Dana', age: 30 }, { name: 'Yana', age: 20 } ]\n```\n\nmatch using a regular expression\n```js\n> data.filter(where({ name: /ana/ }))\n[ { name: 'Dana', age: 30 },\n  { name: 'Yana', age: 20 },\n  { name: 'Zhana', age: 10 } ]\n```\n\nYou can query to any arbitrary depth. So with deeper data, like this:\n```js\n> deepData = [\n    { name: 'Dana', favourite: { colour: 'light red' } },\n    { name: 'Yana', favourite: { colour: 'dark red' } },\n    { name: 'Zhana', favourite: { colour: [ 'white', 'red' ] } }\n]\n```\n\nget records with `favourite.colour` values matching `/red/`\n```js\n> deepData.filter(where({ favourite: { colour: /red/ } }))\n[ { name: 'Dana', favourite: { colour: 'light red' } },\n  { name: 'Yana', favourite: { colour: 'dark red' } } ]\n```\n\nif the value you're looking for _maybe_ part of an array, prefix the property name with `+`. Now Zhana is included:\n```js\n> deepData.filter(where({ favourite: { '+colour': /red/ } }))\n[ { name: 'Dana', favourite: { colour: 'light red' } },\n  { name: 'Yana', favourite: { colour: 'dark red' } },\n  { name: 'Zhana', favourite: { colour: [ 'white', 'red' ] } } ]\n```\n\nyou can combine any of the above by supplying an array of queries. Records will be returned if _any_ of the queries match:\n```js\n> const nameBeginsWithY = { name: /^Y/ }\n> const faveColourIncludesWhite = { favourite: { '+colour': 'white' } }\n\n> deepData.filter(where([ nameBeginsWithY, faveColourIncludesWhite ]))\n[ { name: 'Yana', favourite: { colour: 'dark red' } },\n  { name: 'Zhana', favourite: { colour: [ 'white', 'red' ] } } ]\n```\n\n* * *\n\n&copy; 2016-18 Lloyd Brookes \\<75pound@gmail.com\\>. Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).\n","_attachments":{},"homepage":"https://github.com/75lb/filter-where#readme","bugs":{"url":"https://github.com/75lb/filter-where/issues"},"license":"MIT"}