{"_id":"prop-search","_rev":"4527043","name":"prop-search","description":"Simple property searches on your JavaScript objects.","dist-tags":{"latest":"1.1.8"},"maintainers":[{"name":"bojand","email":"dbojan@gmail.com"}],"time":{"modified":"2026-04-09T13:23:31.000Z","created":"2014-07-07T14:05:36.099Z","1.1.8":"2014-07-28T12:24:12.018Z","1.1.7":"2014-07-28T12:22:28.900Z","1.1.6":"2014-07-27T22:35:06.514Z","1.1.5":"2014-07-27T22:33:44.396Z","1.1.4":"2014-07-09T17:37:04.999Z","1.1.0":"2014-07-07T19:35:35.948Z","1.0.4":"2014-07-07T17:34:20.323Z","1.0.3":"2014-07-07T17:16:49.007Z","1.0.2":"2014-07-07T14:23:19.720Z","1.0.1":"2014-07-07T14:05:36.099Z"},"users":{},"author":{"name":"Bojan D.","email":"dbojan@gmail.com"},"repository":{"type":"git","url":"git://github.com/bojand/prop-search.git"},"versions":{"1.1.8":{"name":"prop-search","version":"1.1.8","description":"Simple property searches on your JavaScript objects.","main":"index.js","repository":{"type":"git","url":"git://github.com/bojand/prop-search.git"},"homepage":"https://github.com/bojand/prop-search","keywords":["object","property","search"],"devDependencies":{"mocha":"*"},"scripts":{"test":"mocha"},"author":{"name":"Bojan D.","email":"dbojan@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/bojand/prop-search/issues"},"_id":"prop-search@1.1.8","_shasum":"241dd285815db1bf3e50c0ea5404ed8473ed806c","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"bojand","email":"dbojan@gmail.com"},"maintainers":[{"name":"bojand","email":"dbojan@gmail.com"}],"dist":{"shasum":"241dd285815db1bf3e50c0ea5404ed8473ed806c","size":4851,"noattachment":false,"key":"/prop-search/-/prop-search-1.1.8.tgz","tarball":"http://registry.cnpm.dingdandao.com/prop-search/download/prop-search-1.1.8.tgz"},"directories":{},"publish_time":1406550252018,"_hasShrinkwrap":false,"_cnpm_publish_time":1406550252018,"_cnpmcore_publish_time":"2021-12-16T22:31:13.182Z"},"1.1.7":{"name":"prop-search","version":"1.1.7","description":"Simple property searches on your JavaScript objects.","main":"index.js","repository":{"type":"git","url":"git://github.com/bojand/prop-search.git"},"homepage":"https://github.com/bojand/prop-search","keywords":["object","property","search"],"devDependencies":{"mocha":"*"},"scripts":{"test":"mocha"},"author":{"name":"Bojan D.","email":"dbojan@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/bojand/prop-search/issues"},"_id":"prop-search@1.1.7","_shasum":"5db0506ec4adc98f07b9ec3aca6b538b945be7ae","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"bojand","email":"dbojan@gmail.com"},"maintainers":[{"name":"bojand","email":"dbojan@gmail.com"}],"dist":{"shasum":"5db0506ec4adc98f07b9ec3aca6b538b945be7ae","size":3636,"noattachment":false,"key":"/prop-search/-/prop-search-1.1.7.tgz","tarball":"http://registry.cnpm.dingdandao.com/prop-search/download/prop-search-1.1.7.tgz"},"directories":{},"publish_time":1406550148900,"_hasShrinkwrap":false,"_cnpm_publish_time":1406550148900,"_cnpmcore_publish_time":"2021-12-16T22:31:13.362Z"},"1.1.6":{"name":"prop-search","version":"1.1.6","description":"Simple property searches on your JavaScript objects.","main":"index.js","repository":{"type":"git","url":"git://github.com/bojand/prop-search.git"},"homepage":"https://github.com/bojand/prop-search","keywords":["object","property","search"],"devDependencies":{"mocha":"*"},"scripts":{"test":"mocha"},"author":{"name":"Bojan D.","email":"dbojan@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/bojand/prop-search/issues"},"_id":"prop-search@1.1.6","_shasum":"88132a375989e2c622fe2cb296fb5a9f6d00f2bc","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"bojand","email":"dbojan@gmail.com"},"maintainers":[{"name":"bojand","email":"dbojan@gmail.com"}],"dist":{"shasum":"88132a375989e2c622fe2cb296fb5a9f6d00f2bc","size":4520,"noattachment":false,"key":"/prop-search/-/prop-search-1.1.6.tgz","tarball":"http://registry.cnpm.dingdandao.com/prop-search/download/prop-search-1.1.6.tgz"},"directories":{},"publish_time":1406500506514,"_hasShrinkwrap":false,"_cnpm_publish_time":1406500506514,"_cnpmcore_publish_time":"2021-12-16T22:31:13.571Z"},"1.1.5":{"name":"prop-search","version":"1.1.5","description":"Simple property searches on your JavaScript objects.","main":"index.js","repository":{"type":"git","url":"git://github.com/bojand/prop-search.git"},"homepage":"https://github.com/bojand/prop-search","keywords":["object","property","search"],"devDependencies":{"mocha":"*"},"scripts":{"test":"mocha"},"author":{"name":"Bojan D.","email":"dbojan@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/bojand/prop-search/issues"},"_id":"prop-search@1.1.5","_shasum":"0030dbe6a8e9a5d36108efea5141509fafd52528","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"bojand","email":"dbojan@gmail.com"},"maintainers":[{"name":"bojand","email":"dbojan@gmail.com"}],"dist":{"shasum":"0030dbe6a8e9a5d36108efea5141509fafd52528","size":3294,"noattachment":false,"key":"/prop-search/-/prop-search-1.1.5.tgz","tarball":"http://registry.cnpm.dingdandao.com/prop-search/download/prop-search-1.1.5.tgz"},"directories":{},"publish_time":1406500424396,"_hasShrinkwrap":false,"_cnpm_publish_time":1406500424396,"_cnpmcore_publish_time":"2021-12-16T22:31:13.789Z"},"1.1.4":{"name":"prop-search","version":"1.1.4","description":"Simple property searches on your JavaScript objects.","main":"index.js","repository":{"type":"git","url":"git://github.com/bojand/prop-search.git"},"homepage":"https://github.com/bojand/prop-search","keywords":["object","property","search"],"devDependencies":{"mocha":"*"},"scripts":{"test":"mocha"},"author":{"name":"Bojan D.","email":"dbojan@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/bojand/prop-search/issues"},"_id":"prop-search@1.1.4","_shasum":"90a0e4df4ee37206ccfab5758f12ef8f163b6093","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"bojand","email":"dbojan@gmail.com"},"maintainers":[{"name":"bojand","email":"dbojan@gmail.com"}],"dist":{"shasum":"90a0e4df4ee37206ccfab5758f12ef8f163b6093","size":4403,"noattachment":false,"key":"/prop-search/-/prop-search-1.1.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/prop-search/download/prop-search-1.1.4.tgz"},"directories":{},"publish_time":1404927424999,"_hasShrinkwrap":false,"_cnpm_publish_time":1404927424999,"_cnpmcore_publish_time":"2021-12-16T22:31:13.972Z"},"1.1.0":{"name":"prop-search","version":"1.1.0","description":"Simple property searches on your JavaScript objects.","main":"index.js","repository":{"type":"git","url":"git://github.com/bojand/prop-search.git"},"homepage":"https://github.com/bojand/prop-search","keywords":["object","property","search"],"devDependencies":{"mocha":"*"},"scripts":{"test":"mocha"},"author":{"name":"Bojan D.","email":"dbojan@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/bojand/prop-search/issues"},"_id":"prop-search@1.1.0","_shasum":"15b7d159c5755dadf905e5d35072ed74480b4a4d","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"bojand","email":"dbojan@gmail.com"},"maintainers":[{"name":"bojand","email":"dbojan@gmail.com"}],"dist":{"shasum":"15b7d159c5755dadf905e5d35072ed74480b4a4d","size":4167,"noattachment":false,"key":"/prop-search/-/prop-search-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/prop-search/download/prop-search-1.1.0.tgz"},"directories":{},"publish_time":1404761735948,"_hasShrinkwrap":false,"_cnpm_publish_time":1404761735948,"_cnpmcore_publish_time":"2021-12-16T22:31:14.178Z"},"1.0.4":{"name":"prop-search","version":"1.0.4","description":"Simple property searches on your JavaScript objects.","main":"index.js","repository":{"type":"git","url":"git://github.com/bojand/prop-search.git"},"homepage":"https://github.com/bojand/prop-search","keywords":["object","property","search"],"devDependencies":{"mocha":"*"},"scripts":{"test":"mocha"},"author":{"name":"Bojan D.","email":"dbojan@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/bojand/prop-search/issues"},"_id":"prop-search@1.0.4","_shasum":"1af981d3895459cb838019587b2a7c5a1a039f72","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"bojand","email":"dbojan@gmail.com"},"maintainers":[{"name":"bojand","email":"dbojan@gmail.com"}],"dist":{"shasum":"1af981d3895459cb838019587b2a7c5a1a039f72","size":3842,"noattachment":false,"key":"/prop-search/-/prop-search-1.0.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/prop-search/download/prop-search-1.0.4.tgz"},"directories":{},"publish_time":1404754460323,"_hasShrinkwrap":false,"_cnpm_publish_time":1404754460323,"_cnpmcore_publish_time":"2021-12-16T22:31:14.400Z"},"1.0.3":{"name":"prop-search","version":"1.0.3","description":"Simple property searches on your JavaScript objects.","main":"index.js","repository":{"type":"git","url":"git://github.com/bojand/prop-search.git"},"homepage":"https://github.com/bojand/prop-search","keywords":["object","property","search"],"devDependencies":{"mocha":"*"},"scripts":{"test":"mocha"},"author":{"name":"Bojan D.","email":"dbojan@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/bojand/prop-search/issues"},"_id":"prop-search@1.0.3","_shasum":"2570ba4103b856573f7c70a868f5171e5d4aa9e5","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"bojand","email":"dbojan@gmail.com"},"maintainers":[{"name":"bojand","email":"dbojan@gmail.com"}],"dist":{"shasum":"2570ba4103b856573f7c70a868f5171e5d4aa9e5","size":3821,"noattachment":false,"key":"/prop-search/-/prop-search-1.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/prop-search/download/prop-search-1.0.3.tgz"},"directories":{},"publish_time":1404753409007,"_hasShrinkwrap":false,"_cnpm_publish_time":1404753409007,"_cnpmcore_publish_time":"2021-12-16T22:31:14.661Z"},"1.0.2":{"name":"prop-search","version":"1.0.2","description":"Simple property searches on your JavaScript objects.","main":"index.js","repository":{"type":"git","url":"git://github.com/bojand/prop-search.git"},"homepage":"https://github.com/bojand/prop-search","keywords":["object","property","search"],"devDependencies":{"mocha":"*"},"scripts":{"test":"mocha"},"author":{"name":"Bojan D.","email":"dbojan@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/bojand/prop-search/issues"},"_id":"prop-search@1.0.2","_shasum":"d8084cef177ca6ee417d0c5de1c6892d391e61d8","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"bojand","email":"dbojan@gmail.com"},"maintainers":[{"name":"bojand","email":"dbojan@gmail.com"}],"dist":{"shasum":"d8084cef177ca6ee417d0c5de1c6892d391e61d8","size":3544,"noattachment":false,"key":"/prop-search/-/prop-search-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/prop-search/download/prop-search-1.0.2.tgz"},"directories":{},"publish_time":1404742999720,"_hasShrinkwrap":false,"_cnpm_publish_time":1404742999720,"_cnpmcore_publish_time":"2021-12-16T22:31:14.872Z"},"1.0.1":{"name":"prop-search","version":"1.0.1","description":"Simple property searches on your JavaScript objects.","main":"index.js","repository":{"type":"git","url":"git://github.com/bojand/prop-search.git"},"homepage":"https://github.com/bojand/prop-search","keywords":["object","property","search"],"devDependencies":{"mocha":"*"},"scripts":{"test":"mocha"},"author":{"name":"Bojan D.","email":"dbojan@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/bojand/prop-search/issues"},"_id":"prop-search@1.0.1","_shasum":"169d1219642df9586d4c30decdd745f35195592b","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"bojand","email":"dbojan@gmail.com"},"maintainers":[{"name":"bojand","email":"dbojan@gmail.com"}],"dist":{"shasum":"169d1219642df9586d4c30decdd745f35195592b","size":3514,"noattachment":false,"key":"/prop-search/-/prop-search-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/prop-search/download/prop-search-1.0.1.tgz"},"directories":{},"publish_time":1404741936099,"_hasShrinkwrap":false,"_cnpm_publish_time":1404741936099,"_cnpmcore_publish_time":"2021-12-16T22:31:15.076Z"}},"readme":"# prop-search\n\nSimple property searches on your JavaScript objects.\n\n## Installation\n\n`npm install prop-search`\n\n## Usage overview\n\nHelper module to search an object for properties and conditions, and returns the array of results.\nWe can search for specific boolean values by key and optionally value. We can search for existence of keys, or perform\na numerical / text search, and find results with the value. Finally we can search using a test function.\nAll functions returns an array of result objects, which have the format:\n\n```js\n{\n  path: {Array},   // path to the result. ex. ['keys', 'to', 'result']\n  value: {*},      // value of the result ex. { lookup : true }\n  key: {String}    // The key where result can be found ex. 'someProp'\n}\n```\n\nIn case that any part of the path is an element in an array the index of that element will be in the path as a number.\nFor example something like:\n\n```js\n['keys', 2, 'to', 'result']\n```\nor\n```js\n['keys', 'to', 'result', 1]\n```\n\nOptionally we can do `join` on the `path` array by passing options with a `separator` options specified.\n\nA good complementary module to this module is [mpath](https://www.npmjs.org/package/mpath) which can be used to\nretrieve the object at tha path.\n\n```js\nvar ps = require('prop-search');\n\nvar someObj = {\n  someProp = {\n    lookup: true\n  }\n};\n\nvar res = ps.searchForBoolean(someObj, 'lookup');\n\nconsole.dir(res);\n```\n\nOutput:\n\n```\n[ {\n  path: ['someObj', 'someProp'],\n  value: { lookup: true },\n  key: 'someProp'\n}]\n```\n\nShould work with array properties:\n\n```js\nvar thing = {\n  something: {\n    otherthing: {\n      something: [\n        {\n          something: true\n        },\n        {\n          other: false\n        }\n      ]\n    }\n  }\n};\n\nvar res = ps.searchForBoolean(thing, 'something');\n```\n`res`:\n```js\n[\n  {\n    path: [ 'something', 'otherthing', 'something', 0 ],\n    value: [\n      { something: true },\n      { other: false }\n    ],\n    key: 'something'\n  }\n]\n```\nOr for example:\n```js\nvar thing = {\n  something: {\n    other: {\n      something: [ 'val1', 'val2', 'val3' ]\n    }\n  }\n};\n\nvar res = ps.searchForValue(thing, 'val2');\n```\n`res`:\n```js\n[\n  {\n    path: [ 'something', 'other', 'something', 1 ],\n    value: [ 'val1', 'val2', 'val3' ],\n    key: 'something',\n  }\n]\n```\n\n## API\n\n#### searchForBoolean(obj, query, options, value)\n\nSearches for boolean values.\n\n* `obj`     - The object to search\n* `query`   - The key(s) of properties to test for the value. It can be a string or an array of strings.\n* `options` - Optionally specify the `separator` string to be used to do `join` on the `path` in the results.\n* `value`   - Optionally specify what to match against, `true` or `false`. Default it `true`.\n\n```js\nvar obj = {\n  prop: {\n    nested: {\n      stuff: {\n        something: {\n          something: false\n        }\n      }\n    }\n  }\n};\n\nvar res = ps.searchForBoolean(obj, 'something', { separator: '.' }, false);\n```\n`res`:\n```js\n[{\n  path: 'prop.nested.stuff.something',\n  value: { something: true },\n  key: 'something' }\n}]\n```\n\n#### searchForExistence(obj, query, options)\n\nSearches for keys if they exist in the object.\n\n* `obj`     - The object to search\n* `query`   - The key(s) of properties to test for existence. It can be a string or an array of strings.\n* `options` - Optionally specify the `separator` string to be used to do `join` on the `path` in the results.\n\n```js\nvar obj = {\n  prop: {\n    nested: {\n      stuff: {\n        something: {\n          other: 'blah'\n        }\n      }\n    }\n  }\n};\n\nvar res = ps.searchForExistence(obj, 'other');\n```\n`res`:\n```js\n[ { path: [ 'prop', 'nested', 'stuff', 'something' ],\n    value: { other: 'blah' },\n    key: 'something' } ]\n```\n\n#### searchForValue(obj, query, options)\n\nSearches for numerical or text value if they exist in the object.\n\n* `obj`     - The object to search\n* `query`   - The text string(s) or number(s) to search in the object. It can be a single value or an array of values.\n* `options` - Optionally specify the `separator` string to be used to do `join` on the `path` in the results.\n\n```js\nvar obj = {\n  prop: {\n    nested: {\n      stuff: {\n        something: {\n          other: 'blah'\n        }\n      }\n    }\n  }\n};\n\nvar res = ps.searchForValue(obj, 'blah');\n```\n`res`:\n```js\n[ { path: [ 'prop', 'nested', 'stuff', 'something', 'other' ],\n    value: 'blah',\n    key: 'other' } ]\n```\n\n#### search(obj, test, options)\n\nSearches the object using the `test` function. `test` iterator function accepts a parameter `obj` which is an object\nas the search object is iterated. Test the object for whatever condition. The function has to return `true` or `false`.\n\n* `obj`     - The object to search\n* `test`    - The iterator test function.\n* `options` - Optionally specify the `separator` string to be used to do `join` on the `path` in the results.\n\n```js\nvar obj = {\n  prop: {\n    nested: {\n      stuff: {\n        something: {\n          other: 'blah'\n        }\n      }\n    }\n  }\n};\n\nvar tester = function (testObj) {\n  return testObj.other === 'blah';\n};\n\nvar res = ps.search(obj, tester, {separator: '.'});\n```\n`res`:\n```js\n[ { path: 'prop.nested.stuff.something',\n    value: { other: 'blah' },\n    key: 'something' } ]\n```\n\n## License\n\nMIT","_attachments":{},"homepage":"https://github.com/bojand/prop-search","bugs":{"url":"https://github.com/bojand/prop-search/issues"},"license":"MIT"}