{"id":27404471,"url":"https://github.com/bimus-github/search-in-js","last_synced_at":"2025-10-07T12:36:25.967Z","repository":{"id":228385821,"uuid":"773863598","full_name":"bimus-github/search-in-js","owner":"bimus-github","description":null,"archived":false,"fork":false,"pushed_at":"2024-08-02T04:51:15.000Z","size":45,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-02T04:21:01.855Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bimus-github.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-03-18T14:31:23.000Z","updated_at":"2024-08-02T04:51:18.000Z","dependencies_parsed_at":"2024-03-18T15:14:37.172Z","dependency_job_id":"3662eccb-1589-4f43-b36f-de2c82da29e8","html_url":"https://github.com/bimus-github/search-in-js","commit_stats":null,"previous_names":["bimus-github/search-in-js"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/bimus-github/search-in-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bimus-github%2Fsearch-in-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bimus-github%2Fsearch-in-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bimus-github%2Fsearch-in-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bimus-github%2Fsearch-in-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bimus-github","download_url":"https://codeload.github.com/bimus-github/search-in-js/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bimus-github%2Fsearch-in-js/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278778435,"owners_count":26044255,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-04-14T05:29:46.816Z","updated_at":"2025-10-07T12:36:25.916Z","avatar_url":"https://github.com/bimus-github.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Array Data Filter Function\n\nThis is a custom function designed to filter data in an array based on a search query.\nIt provides flexibility in specifying the keys to search for within the data,\nas well as the type of search function to use.\n\n## Usage\n\n### Installation\n\n```bash\nnpm install search-in-js\n```\n\n```bash\nyarn add search-in-js\n```\n\n### Example\n\n```javascript\nimport { useState, useEffect } from \"react\";\nimport search from \"search-in-js\";\n\nconst ExampleComponent = () =\u003e {\n  const data = [\n    { id: 1, name: \"test1\", comment: { id: 1, text: \"some comment\" } },\n    { id: 2, name: \"test2\", comment: { id: 2, text: \"some other comment\" } },\n    // More data...\n  ];\n\n  // Define keys for searching\n  const keys = [\"id\", \"comment.text\"];\n\n  // State for search query and filtered data\n  const [value, setValue] = useState(\"\");\n  const [filteredData, setFilteredData] = useState(data);\n\n  // Update filtered data when search query changes\n  useEffect(() =\u003e {\n    setFilteredData(search(value, data, keys, \"fuzzy\"));\n  }, [value]);\n\n  return (\n    \u003cdiv\u003e\n      \u003cinput\n        type=\"text\"\n        value={value}\n        onChange={(e) =\u003e setValue(e.target.value)}\n      /\u003e\n      \u003cul\u003e\n        {filteredData.map((item) =\u003e (\n          \u003cli key={item.id}\u003e{item.name}\u003c/li\u003e\n        ))}\n      \u003c/ul\u003e\n    \u003c/div\u003e\n  );\n};\n```\n\n### API\n\n#### `search(value, data, keys, functionType)`\n\n- `value` (`string`): The value to search for in the data.\n- `data` (`Array\u003cT\u003e`): The array of data to search.\n- `keys` (`Array\u003cstring\u003e`): The array of keys to search for in the data.\n\n  if you want to search by id and name, you can use the following keys:\n  const keys = [\"id\", \"name\"];\n\n  if you want to search by comments.id and comments.text, you can use the following keys:\n  const keys = [\"comments.id\", \"comments.text\"];\n\n- `functionType` (`SEARCH_FUNCTION`, optional): The type of search function to use. Defaults to \"fuzzy\".\n\n  Available search function types:\n  equal, fuzzy, contains, starts-with, ends-with, starts-with-no-space, greater, less, greater-equal, less-equal\n\nReturns: `Array\u003cT\u003e` - The filtered data based on the search query.\n\n## Contributing\n\nContributions are welcome! Please feel free to open a pull request.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n```\n\nFeel free to modify and expand upon it to suit your needs!\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbimus-github%2Fsearch-in-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbimus-github%2Fsearch-in-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbimus-github%2Fsearch-in-js/lists"}