{"id":17725659,"url":"https://github.com/fedemartinm/search-operators","last_synced_at":"2026-03-02T19:09:31.949Z","repository":{"id":38227598,"uuid":"256639787","full_name":"fedemartinm/search-operators","owner":"fedemartinm","description":"A search operators parser to filter search results","archived":false,"fork":false,"pushed_at":"2023-01-06T03:42:16.000Z","size":1780,"stargazers_count":4,"open_issues_count":13,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-09-30T07:17:26.238Z","etag":null,"topics":["javascript","nodejs","parser","search"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/fedemartinm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-18T00:41:57.000Z","updated_at":"2023-01-13T15:00:42.000Z","dependencies_parsed_at":"2023-02-05T06:00:36.134Z","dependency_job_id":null,"html_url":"https://github.com/fedemartinm/search-operators","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fedemartinm%2Fsearch-operators","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fedemartinm%2Fsearch-operators/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fedemartinm%2Fsearch-operators/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fedemartinm%2Fsearch-operators/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fedemartinm","download_url":"https://codeload.github.com/fedemartinm/search-operators/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246552923,"owners_count":20795836,"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","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":["javascript","nodejs","parser","search"],"created_at":"2024-10-25T16:05:15.540Z","updated_at":"2026-03-02T19:09:26.924Z","avatar_url":"https://github.com/fedemartinm.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![npm](https://img.shields.io/npm/v/search-operators)\n![npm bundle size](https://img.shields.io/bundlephobia/minzip/search-operators?color=green)\n\n# Search Operators\nA search operators parser to filter search requests\n\n- Unicode support \n- Case-insensitive\n- Based on LR parser\n- No dependencies\n\n### Installation\n```shell\nyarn add search-operators\n```\n\nor\n\n```shell\nnpm install search-operators --save\n```\n\n### Basic Usage\n```js\nconst searchOperators = require('./search-operators');\nvar value = searchOperators.parse('+github.com useState useEffect');\nconsole.log(value); \n//the parser will separate the text in terms and filters.\n//{\n//  \"filters\": [{ \"type\": \"exact\", \"value\": \"github.com\" }],\n//  \"terms\": [\"useState\",\"useEffect\"]\n//}\n```\n\n\n### Operators\n\n\nOperator | Description  | Parser input | Parser output |\n| :--: | -- | -- | -- |\n| **\" \"** | exact word or phrase | \"bash history file\"   | { filters : [ { type: 'exact', value: 'bash history file' } ] }\n| **+** | exact word | +github.com   | { filters:[ { type: 'exact', value: 'github.com' } ] }\n| **-** | exclude word | -php  | { filters:[ { type: 'exclude', value: 'php' } ] }\n| **:** | match | in:general  | { filters:[ { type: 'match', key:'in', value: 'general' } ] }\n| **not :** | inverse match  | not in:random  | { filters:[ { type: 'not-match', key:'in', value: 'random' } ] }\n\n### API\n- Parse\n```js \nparser.parse(\n  search, //string to parse\n  { keys:[] } //keys used by match operator\n);\n```\n- Tokens\n```js \n//populated after parse, contains token location\n//useful to highlight syntax!\nparser.parse(\"-😊\");\nconsole.log(parser.tokens);\n//{\n//    type: 'EXCLUDE_OP',\n//    value: '😊',\n//    startOffset: 0,\n//    endOffset: 3,\n//    startLine: 1,\n//    endLine: 1,\n//    startColumn: 0,\n//    endColumn: 3\n//}\n```\n\n### Development\n\nThis project is intended to be extended or modified.  It's uses syntax to generate the parser; in case you need to modify the grammar, [syntax](https://github.com/DmitrySoshnikov/syntax) is very well documented. Any contribution is very appreciated.\n\n1. Fork [search-operators](https://github.com/fedemartinm/search-operators/) repo.\n2. Make your changes\n3. Validate grammar with `npm run validate`\n4. Test parser with `npm run test`\n\nUse `npm run build` to transpile and generate production build.\n\n## Licence \n[MIT](https://github.com/fedemartinm/search-operators/blob/master/LICENSE) do whatever you want to do!\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffedemartinm%2Fsearch-operators","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffedemartinm%2Fsearch-operators","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffedemartinm%2Fsearch-operators/lists"}