{"id":38468103,"url":"https://github.com/wise-introvert/deepsearchjs","last_synced_at":"2026-01-17T05:04:03.308Z","repository":{"id":65343331,"uuid":"590214466","full_name":"wise-introvert/deepsearchjs","owner":"wise-introvert","description":"Search across keys of a JSON object regardless of it's depth and complexity!","archived":false,"fork":false,"pushed_at":"2023-04-05T18:03:30.000Z","size":479,"stargazers_count":10,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-02T09:48:21.036Z","etag":null,"topics":["fast","fuzzy-search","json","key-finder","nodejs","object","search","typescript"],"latest_commit_sha":null,"homepage":"https://project-arda.gitbook.io/deepsearchjs/readme","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wise-introvert.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null}},"created_at":"2023-01-17T22:31:51.000Z","updated_at":"2024-10-30T10:18:19.000Z","dependencies_parsed_at":"2023-02-16T12:01:07.770Z","dependency_job_id":null,"html_url":"https://github.com/wise-introvert/deepsearchjs","commit_stats":null,"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"purl":"pkg:github/wise-introvert/deepsearchjs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wise-introvert%2Fdeepsearchjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wise-introvert%2Fdeepsearchjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wise-introvert%2Fdeepsearchjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wise-introvert%2Fdeepsearchjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wise-introvert","download_url":"https://codeload.github.com/wise-introvert/deepsearchjs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wise-introvert%2Fdeepsearchjs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28497998,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T04:31:57.058Z","status":"ssl_error","status_checked_at":"2026-01-17T04:31:45.816Z","response_time":85,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fast","fuzzy-search","json","key-finder","nodejs","object","search","typescript"],"created_at":"2026-01-17T05:04:03.211Z","updated_at":"2026-01-17T05:04:03.289Z","avatar_url":"https://github.com/wise-introvert.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## deepsearchjs\n\n[![build](https://github.com/wise-introvert/deepsearchjs/actions/workflows/npm-publish.yml/badge.svg)](https://github.com/wise-introvert/deepsearchjs/workflows/npm-publish.yml)\n[![test](https://github.com/wise-introvert/deepsearchjs/actions/workflows/test.yml/badge.svg)](https://github.com/wise-introvert/deepsearchjs/workflows/test.yml)\n\nSearch for key in deeply-nested objects.\n\n### Installation\n\n```bash\n$ yarn add deepsearchjs\n```\n\n### Usage\n\n```ts\nsearch\u003cT\u003e(object: T, any\u003e | Array\u003cany\u003e, searchTerm: string): P;\n```\n\n| Name         | Description                                                                                                                      | Required | Type                                                                                                              |\n| ------------ | -------------------------------------------------------------------------------------------------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------- |\n| `object`     | Object to be searched                                                                                                            | True     | `T = Record\u003cany, any\u003e \\| Array\u003cany\u003e`                                                                              |\n| `searchTerm` | string to search for, a function that determines if an object key matches the query, or a regular expression to use for matching | True     | `string` or `((key: string, value: any) =\u003e boolean)` or `RegExp`                                                  |\n| output       | Output object                                                                                                                    | ---      | `P = Record\u003ckey: string, any\u003e`\u003cbr /\u003e\u003csmall\u003eWhere, `key` is a valid object path(eg. `a.b.c[0].d.e`, etc..)\u003c/small\u003e |\n\n### Parameters\n\n- `obj` (`T`): The object to search. It is also generic, meaning it can accept any type of object.\n- `query` (`string` | `((key: string, value: any) =\u003e boolean)` | `RegExp`): The query to search for. This can be a string, a function, or a regular expression.\n  - If it is a string, the function will search for keys that end with that string.\n  - If it is a function, it will determine if the key matches the query.\n  - If it is a regular expression, it will test the key against that regular\n\n### Example\n\n\u003cdetails\u003e\n  \u003csummary\u003esample data\u003c/summary\u003e\n  \u003cpre\u003e\n{\n  \"users\": [\n    {\n      \"id\": 39101,\n      \"name\": \"Edwin Reichel\",\n      \"email\": \"Kirk.Bednar@yahoo.com\",\n      \"address\": {\n        \"street\": \"1709 Carole Branch\",\n        \"city\": \"Jenkinsboro\",\n        \"state\": \"TX\",\n        \"zip\": \"61317-0976\",\n        \"phoneNumbers\": [\n          { \"type\": \"work\", \"number\": \"232.844.3064 x29733\" },\n          { \"type\": \"work\", \"number\": \"950.846.8118 x9126\" }\n        ],\n        \"previousAddresses\": [\n          {\n            \"street\": \"82002 Connelly Dale\",\n            \"city\": \"Folsom\",\n            \"state\": \"MS\",\n            \"zip\": \"20367-6986\",\n            \"yearsLived\": 10,\n            \"phoneNumbers\": [{ \"type\": \"work\", \"number\": \"1-997-352-5842\" }],\n            \"previousAddresses\": [\n              {\n                \"street\": \"663 Emie Way\",\n                \"city\": \"Gradyton\",\n                \"state\": \"OH\",\n                \"zip\": \"09828-8254\",\n                \"yearsLived\": 5\n              },\n              {\n                \"street\": \"1991 Consuelo Roads\",\n                \"city\": \"Gusbury\",\n                \"state\": \"KY\",\n                \"zip\": \"69719\",\n                \"yearsLived\": 1\n              }\n            ]\n          }\n        ]\n      },\n      \"orders\": [\n        {\n          \"id\": 15686,\n          \"date\": \"Sun Jan 22 2023 15:36:15 GMT-0500 (Eastern Standard Time)\",\n          \"total\": 83285,\n          \"items\": [\n            {\n              \"name\": \"Incredible Metal Shoes\",\n              \"quantity\": 1,\n              \"price\": \"469.00\"\n            },\n            {\n              \"name\": \"Unbranded Concrete Chair\",\n              \"quantity\": 6,\n              \"price\": \"999.00\"\n            },\n            {\n              \"name\": \"Licensed Concrete Sausages\",\n              \"quantity\": 9,\n              \"price\": \"657.00\"\n            },\n            {\n              \"name\": \"Electronic Rubber Ball\",\n              \"quantity\": 7,\n              \"price\": \"117.00\"\n            }\n          ],\n          \"shippingAddress\": {\n            \"street\": \"034 Wiza Forge\",\n            \"city\": \"Glenniemouth\",\n            \"state\": \"VT\",\n            \"zip\": \"60082-4617\"\n          }\n        }\n      ]\n    },\n    {\n      \"id\": 41973,\n      \"name\": \"Melanie Upton\",\n      \"email\": \"Alisha.Boyle@yahoo.com\",\n      \"address\": {\n        \"street\": \"69147 Bode Junctions\",\n        \"city\": \"Bakersfield\",\n        \"state\": \"WA\",\n        \"zip\": \"83859\",\n        \"phoneNumbers\": [\n          { \"type\": \"home\", \"number\": \"(263) 786-2737 x719\" },\n          { \"type\": \"home\", \"number\": \"1-536-445-2960\" }\n        ],\n        \"previousAddresses\": [\n          {\n            \"street\": \"99456 Elliott Corner\",\n            \"city\": \"Joanneburgh\",\n            \"state\": \"ME\",\n            \"zip\": \"41321\",\n            \"yearsLived\": 9,\n            \"phoneNumbers\": [\n              { \"type\": \"work\", \"number\": \"(999) 243-1101\" },\n              { \"type\": \"work\", \"number\": \"353.548.4339 x89335\" }\n            ],\n            \"previousAddresses\": [\n              {\n                \"street\": \"591 Thomas Way\",\n                \"city\": \"New Richmond\",\n                \"state\": \"OH\",\n                \"zip\": \"19873\",\n                \"yearsLived\": 3\n              },\n              {\n                \"street\": \"215 Shanahan Crescent\",\n                \"city\": \"South Clarissa\",\n                \"state\": \"MS\",\n                \"zip\": \"31746\",\n                \"yearsLived\": 2\n              }\n            ]\n          }\n        ]\n      },\n      \"orders\": [\n        {\n          \"id\": 21059,\n          \"date\": \"Sun Jan 22 2023 11:09:50 GMT-0500 (Eastern Standard Time)\",\n          \"total\": 38281,\n          \"items\": [\n            { \"name\": \"Rustic Frozen Shirt\", \"quantity\": 3, \"price\": \"797.00\" },\n            {\n              \"name\": \"Luxurious Fresh Salad\",\n              \"quantity\": 3,\n              \"price\": \"290.00\"\n            },\n            {\n              \"name\": \"Ergonomic Bronze Pizza\",\n              \"quantity\": 10,\n              \"price\": \"380.00\"\n            }\n          ],\n          \"shippingAddress\": {\n            \"street\": \"35692 Miller Locks\",\n            \"city\": \"Bowie\",\n            \"state\": \"TN\",\n            \"zip\": \"40565-6785\"\n          }\n        }\n      ]\n    }\n  ]\n}\n\u003c/pre\u003e\n\u003c/details\u003e\n\n#### **`index.ts`**\n\n```ts\nimport { search } from \"deepsearchjs\";\nimport data from \"./data.json\";\n\n// string as query\nsearch(data, \"city\");\n\n// call back function as query\nsearch(data, (key: string, value: string): boolean =\u003e /city/gi.test(key));\n\n// regex as query\nsearch(data, /city/gi);\n\n/*\n * All three calls will have the same output:\n * {\n *   \"users[0].address.city\": \"Jenkinsboro\",\n *   \"users[0].address.previousAddresses[0].city\": \"Folsom\",\n *   ...\n * }\n */\n```\n\n### TODO\n\n- [ ] ci/cd: Automate versioning and releases\n- [ ] feat: Optimize search algorithm to handle oversized datasets\n- [ ] feat: Add a third parameter to the function to customize the search parameters ( leaf-node results only, etc... )\n- [ ] feat: Search across values??\n\n### Benchmark\n- text-based search x 8,817 ops/sec ±2.15% (68 runs sampled)\n- regex-based search x 11,201 ops/sec ±2.04% (62 runs sampled)\n- cb-based search x 3,621 ops/sec ±4.19% (65 runs sampled)\n- **Fastest method** ( for the current release ): **regex-based search** :sparkles::tada:!!\n\u003cdetails\u003e \u003csummary\u003eJSON results\u003c/summary\u003e \u003cpre\u003e{\n  \"0\": {\n    \"name\": \"text-based search\",\n    \"options\": {\n      \"async\": false,\n      \"defer\": false,\n      \"delay\": 0.005,\n      \"initCount\": 1,\n      \"maxTime\": 5,\n      \"minSamples\": 5,\n      \"minTime\": 0.05\n    },\n    \"async\": false,\n    \"defer\": false,\n    \"delay\": 0.005,\n    \"initCount\": 1,\n    \"maxTime\": 5,\n    \"minSamples\": 5,\n    \"minTime\": 0.05,\n    \"id\": 1,\n    \"stats\": {\n      \"moe\": 0.00000244106107115688,\n      \"rme\": 2.152356503618249,\n      \"sem\": 0.0000012454393220188163,\n      \"deviation\": 0.000010270155749962454,\n      \"mean\": 0.00011341341766818368,\n      \"sample\": [\n        0.000146803728,\n        0.00011572010606060607,\n        0.00011885346808510638,\n        0.00011830230673758866,\n        0.00011897977482269505,\n        0.00011784068262411348,\n        0.00011091230673758866,\n        0.00011458421099290781,\n        0.00012297653191489362,\n        0.00012383750177304964,\n        0.00009523692021276597,\n        0.00010188955673758866,\n        0.00008869730673758865,\n        0.00008125843981481482,\n        0.00011275360802469137,\n        0.00011499258950617285,\n        0.00011582341975308642,\n        0.00011910342901234568,\n        0.00011789552932098766,\n        0.00011935573148148148,\n        0.00011643807716049383,\n        0.00011778031635802468,\n        0.00011268225462962963,\n        0.00011816879629629629,\n        0.00011752594907407407,\n        0.00011881521604938272,\n        0.00011783940277777779,\n        0.00012157337808641975,\n        0.00011906084259259258,\n        0.00010911096759259259,\n        0.00010891824074074075,\n        0.00010719250462962964,\n        0.00011182879320987654,\n        0.00012052595061728396,\n        0.00012101155709876545,\n        0.00012251358179012344,\n        0.00012315302314814814,\n        0.00011561577777777778,\n        0.00011721190895061729,\n        0.00008452717746913581,\n        0.00011348285185185184,\n        0.00011867861419753087,\n        0.00012089339197530863,\n        0.0001201368225308642,\n        0.00011788082716049383,\n        0.00011924499228395062,\n        0.00012038604012345679,\n        0.00012245210648148148,\n        0.00011754411265432098,\n        0.00011424029166666667,\n        0.00012130361419753088,\n        0.0000923405262345679,\n        0.00010927869753086421,\n        0.00010884502932098765,\n        0.0001094378364197531,\n        0.00010971603240740741,\n        0.00010909693055555554,\n        0.00010877557407407407,\n        0.00010895136419753088,\n        0.00010877602006172839,\n        0.00010883273919753087,\n        0.00010900434413580247,\n        0.00010883138117283951,\n        0.00010934616820987655,\n        0.00010982493981481482,\n        0.0001090027962962963,\n        0.0000851349737654321,\n        0.00012336251851851853\n      ],\n      \"variance\": 1.0547609912848684e-10\n    },\n    \"times\": {\n      \"cycle\": 0.07349189464898302,\n      \"elapsed\": 5.73,\n      \"period\": 0.00011341341766818368,\n      \"timeStamp\": 1680125365607\n    },\n    \"running\": false,\n    \"count\": 648,\n    \"cycles\": 4,\n    \"hz\": 8817.298874862618\n  },\n  \"1\": {\n    \"name\": \"regex-based search\",\n    \"options\": {\n      \"async\": false,\n      \"defer\": false,\n      \"delay\": 0.005,\n      \"initCount\": 1,\n      \"maxTime\": 5,\n      \"minSamples\": 5,\n      \"minTime\": 0.05\n    },\n    \"async\": false,\n    \"defer\": false,\n    \"delay\": 0.005,\n    \"initCount\": 1,\n    \"maxTime\": 5,\n    \"minSamples\": 5,\n    \"minTime\": 0.05,\n    \"id\": 2,\n    \"stats\": {\n      \"moe\": 0.0000018237630468553652,\n      \"rme\": 2.042721765476309,\n      \"sem\": 9.304913504364108e-7,\n      \"deviation\": 0.000007326696220036183,\n      \"mean\": 0.00008928103071492518,\n      \"sample\": [\n        0.00010688481656804733,\n        0.00010174892307692307,\n        0.00010219668364030337,\n        0.00009354917876489707,\n        0.00009346165113759479,\n        0.00009200755471289274,\n        0.00009858578764897074,\n        0.00009119924377031419,\n        0.00008316187648970747,\n        0.00008352614409534128,\n        0.00008275436294691224,\n        0.00008452998374864571,\n        0.00008534723293607801,\n        0.00009527751245937161,\n        0.00009301724268689058,\n        0.0000990216738894908,\n        0.00009707387540628385,\n        0.0000958670054171181,\n        0.00008628216143011918,\n        0.0000836218255687974,\n        0.00008291111375947996,\n        0.00008224571830985915,\n        0.00008674919393282773,\n        0.0000934285698808234,\n        0.00009914981906825569,\n        0.00010451172481040087,\n        0.00009149689274106176,\n        0.00009555257963163597,\n        0.00009262662730227519,\n        0.00006575281798483207,\n        0.00009970973131094258,\n        0.00009413191115926327,\n        0.00009616364247020584,\n        0.00008442001408450703,\n        0.00008231284832069339,\n        0.00008209235644637053,\n        0.00008727267388949079,\n        0.00008222513759479956,\n        0.00008289228927410618,\n        0.00008270142578548213,\n        0.00008345532827735645,\n        0.00008770630444203684,\n        0.00008959519609967496,\n        0.00008974383531960996,\n        0.00009025828710725895,\n        0.0000880032502708559,\n        0.00008558602925243772,\n        0.00008313538894907909,\n        0.00008188517659804984,\n        0.00008838074756229686,\n        0.00009403221343445286,\n        0.00009832676814734561,\n        0.00009536374539544962,\n        0.00008869896533044421,\n        0.00009251110184182016,\n        0.000083015360780065,\n        0.00008454997941495125,\n        0.00008252108992416035,\n        0.00008277315817984832,\n        0.00008238436294691223,\n        0.00008270254604550378,\n        0.00008333324485373781\n      ],\n      \"variance\": 5.368047750069248e-11\n    },\n    \"times\": {\n      \"cycle\": 0.08240639134987594,\n      \"elapsed\": 5.57,\n      \"period\": 0.00008928103071492518,\n      \"timeStamp\": 1680125371338\n    },\n    \"running\": false,\n    \"count\": 923,\n    \"cycles\": 3,\n    \"hz\": 11200.587537939671\n  },\n  \"2\": {\n    \"name\": \"cb-based search\",\n    \"options\": {\n      \"async\": false,\n      \"defer\": false,\n      \"delay\": 0.005,\n      \"initCount\": 1,\n      \"maxTime\": 5,\n      \"minSamples\": 5,\n      \"minTime\": 0.05\n    },\n    \"async\": false,\n    \"defer\": false,\n    \"delay\": 0.005,\n    \"initCount\": 1,\n    \"maxTime\": 5,\n    \"minSamples\": 5,\n    \"minTime\": 0.05,\n    \"id\": 3,\n    \"stats\": {\n      \"moe\": 0.000011564930117061431,\n      \"rme\": 4.187226289344706,\n      \"sem\": 0.000005900474549521138,\n      \"deviation\": 0.00004757114665551519,\n      \"mean\": 0.0002761954888010441,\n      \"sample\": [\n        0.0002797260611111111,\n        0.00028398815,\n        0.0002809398333333333,\n        0.0002790591666666667,\n        0.00028411287222222223,\n        0.00028206295,\n        0.000285308125,\n        0.000269671525,\n        0.000287101125,\n        0.00029844556000000003,\n        0.00028658758,\n        0.0002899828066037736,\n        0.0002868383537735849,\n        0.00028940879716981134,\n        0.0002967127169811321,\n        0.00018237919855595668,\n        0.0001877599891696751,\n        0.00018923341516245487,\n        0.000209228880866426,\n        0.0002788044584837545,\n        0.00027827379422382673,\n        0.00027663329602888086,\n        0.00027426568592057765,\n        0.0002802523610108303,\n        0.00027461550902527074,\n        0.0002759419133574007,\n        0.00027409050180505416,\n        0.00028292609386281587,\n        0.00019734872924187727,\n        0.0002045947725631769,\n        0.00020263719494584837,\n        0.00021100980866425992,\n        0.00028059675812274365,\n        0.00027767110469314077,\n        0.00027417941516245486,\n        0.00027984070397111914,\n        0.0002877069927797834,\n        0.00028306761371841156,\n        0.0002865445379061372,\n        0.00028764361371841156,\n        0.00031500585920577617,\n        0.0003895472996389892,\n        0.0003826898086642599,\n        0.0002946485848375451,\n        0.00043763334657039715,\n        0.000234804321299639,\n        0.00034170996389891695,\n        0.0002760850324909747,\n        0.00025532186281588447,\n        0.00025329747653429606,\n        0.00028817528519855596,\n        0.000251139678700361,\n        0.0002823591010830325,\n        0.0002757479927797834,\n        0.00028322767148014443,\n        0.00029953190974729243,\n        0.00028734698916967505,\n        0.00040534606498194946,\n        0.000182999880866426,\n        0.0002478269198717949,\n        0.00028990541025641025,\n        0.00028514647756410253,\n        0.00028308919551282055,\n        0.0002902054262820513,\n        0.00020272324679487181\n      ],\n      \"variance\": 2.263013994120534e-9\n    },\n    \"times\": {\n      \"cycle\": 0.08617299250592576,\n      \"elapsed\": 5.44,\n      \"period\": 0.0002761954888010441,\n      \"timeStamp\": 1680125376908\n    },\n    \"running\": false,\n    \"count\": 312,\n    \"cycles\": 5,\n    \"hz\": 3620.6239440802183\n  },\n  \"options\": {},\n  \"length\": 3,\n  \"events\": {\n    \"cycle\": [\n      null\n    ],\n    \"complete\": [\n      null\n    ]\n  },\n  \"running\": false\n}\u003c/pre\u003e \u003c/details\u003e\n  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwise-introvert%2Fdeepsearchjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwise-introvert%2Fdeepsearchjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwise-introvert%2Fdeepsearchjs/lists"}