{"id":13847004,"url":"https://github.com/mixmaxhq/search-string","last_synced_at":"2025-04-04T09:06:53.235Z","repository":{"id":49159175,"uuid":"104518129","full_name":"mixmaxhq/search-string","owner":"mixmaxhq","description":"Another simple parser for advanced search query syntax.","archived":false,"fork":false,"pushed_at":"2025-02-06T13:50:22.000Z","size":544,"stargazers_count":65,"open_issues_count":11,"forks_count":7,"subscribers_count":28,"default_branch":"master","last_synced_at":"2025-03-28T08:04:57.020Z","etag":null,"topics":["corgi-tag","javascript","nodejs","query-parser","querystrings"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/search-string","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/mixmaxhq.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2017-09-22T20:56:38.000Z","updated_at":"2025-02-06T13:50:26.000Z","dependencies_parsed_at":"2025-02-08T06:10:38.177Z","dependency_job_id":"5192e636-30df-45a2-b7d0-65c2475b4ee0","html_url":"https://github.com/mixmaxhq/search-string","commit_stats":{"total_commits":67,"total_committers":8,"mean_commits":8.375,"dds":"0.29850746268656714","last_synced_commit":"e75f5f4e79be511a2c3159604f1b8fcafe43d9f5"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixmaxhq%2Fsearch-string","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixmaxhq%2Fsearch-string/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixmaxhq%2Fsearch-string/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixmaxhq%2Fsearch-string/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mixmaxhq","download_url":"https://codeload.github.com/mixmaxhq/search-string/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247149500,"owners_count":20891954,"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":["corgi-tag","javascript","nodejs","query-parser","querystrings"],"created_at":"2024-08-04T18:00:52.199Z","updated_at":"2025-04-04T09:06:53.209Z","avatar_url":"https://github.com/mixmaxhq.png","language":"TypeScript","readme":"# Search String\n\n\u003e Another simple parser for advanced search query syntax.\n\n[![Build Status](https://travis-ci.org/mixmaxhq/search-string.svg?branch=master)](https://travis-ci.org/mixmaxhq/search-string) [![npm version](https://badge.fury.io/js/search-string.svg)](https://badge.fury.io/js/search-string)\n\nIt parses typical Gmail-style search strings like:\n\n```\nto:me -from:joe@mixmax.com foobar1 -foobar2\n```\n\nAnd returns an instance of `SearchString` which can be mutated, return different data structures, or return the gmail-style search string again.\n\nSee this [blog post](https://mixmax.com/blog/search-string-advanced-search-parser) introducing this library.\n\n\n## Installation\n\n```shell\n$ npm install search-string\n```\n\n## Usage\n\n```javascript\nconst SearchString = require('search-string');\n\n// Perform parsing\nconst str = 'to:me -from:joe@mixmax.com foobar1 -foobar2';\nconst searchString = SearchString.parse(str);\n\n/* Get text in different formats. */\n\n// [ { text: 'foorbar1', negated: false }, { text: 'foobar2', negated: true } ]\nsearchString.getTextSegments();\n\n// `foobar1 -foobar2`\nsearchString.getAllText();\n\n\n/* Get conditions in different formats. */\n\n// Standard format: Condition Array\n// [ { keyword: 'to', value: 'me', negated: false }, { keyword: 'from', value: 'joe@mixmax.com', negated: true } ]\nsearchString.getConditionArray(); \n\n// Alternate format: Parsed Query\n// { to: ['me'], excludes: { from: ['joe@mixmax.com'] }}\nsearchString.getParsedQuery(); \n\n/* Or get text and conditions back in string format. */\n\n// `to:me -from:joe@mixmax.com foobar1 -foobar2`\nsearchString.toString();\n\n\n/* Mutations exist as well for modifying an existing SearchString structure. */\n\n// `to:me foobar -foobar2`\nsearchString.removeKeyword('from', true).toString()\n\n// `to:me from:jane@mixmax.com foobar1 -foobar2`\nsearchString.addEntry('from', 'jane@mixmax.com', false).toString();\n\n// `from:jane@mixmax.com foobar1 -foobar2`\nsearchString.removeEntry('to', 'me', false).toString();\n\n/* clone operation instantiates a new version by copying over data. */\n\n// `from:jane@mixmax.com foobar1 -foobar2`\nsearchString.clone().toString();\n\n\n```\n\n## Testing\n\nRun tests with `npm test`\n\nor run tests on any changes with `npm run testWatch`\n\n## Building\n\nBuild ES5 compatible code with `npm run babel`\n\nor continually build and watch for changes with `npm run babelWatch`\n\n## Background\n\nSee [this blogpost](https://mixmax.com/blog/search-string-advanced-search-parser) for why this library was built and continues to be supported.\n\nThanks to [search-query-parser](https://github.com/nepsilon/search-query-parser) for inspiration.\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2017 Mixmax, Inc\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmixmaxhq%2Fsearch-string","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmixmaxhq%2Fsearch-string","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmixmaxhq%2Fsearch-string/lists"}