@webkitty/searchbox
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -1,2 +0,4 @@ | ||
export { parse }; | ||
declare const KEY_UNDEFINED = "_"; | ||
declare const OP_NOT = "-"; | ||
export { KEY_UNDEFINED, OP_NOT, parse, }; | ||
declare function parse(input: string, opts?: SearchBoxOptions): Formula; | ||
@@ -3,0 +5,0 @@ declare class Formula { |
@@ -10,2 +10,6 @@ "use strict"; | ||
const TYPE_CHAIN_OP_PAIR = [TYPE_OP, TYPE_KEY, TYPE_SEP, TYPE_WORD].join('|'); | ||
const KEY_UNDEFINED = '_'; | ||
exports.KEY_UNDEFINED = KEY_UNDEFINED; | ||
const OP_NOT = '-'; | ||
exports.OP_NOT = OP_NOT; | ||
function parse(input, opts) { | ||
@@ -76,3 +80,3 @@ const keywords = opts ? (opts.keywords || []) : []; | ||
else { | ||
this.append('fulltext', t1.value); | ||
this.append(KEY_UNDEFINED, t1.value); | ||
return 1; | ||
@@ -88,5 +92,3 @@ } | ||
this.handler = handler; | ||
if (!keywords.includes('fulltext')) | ||
keywords.push('fulltext'); | ||
const operators = ['-']; | ||
const operators = [OP_NOT]; | ||
const WS = /[ \t]+/u; | ||
@@ -130,1 +132,2 @@ const OP = new RegExp(`${operators.join('|')}(?=(?:${keywords.join('|')}))`, 'u'); | ||
} | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@webkitty/searchbox", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"author": { | ||
@@ -10,3 +10,8 @@ "name": "stuchl4n3k", | ||
"description": "A search box supporting multiple user-defined keywords.", | ||
"keywords": ["search", "keyword", "lexer", "parser"], | ||
"keywords": [ | ||
"search", | ||
"keyword", | ||
"lexer", | ||
"parser" | ||
], | ||
"license": "MIT", | ||
@@ -25,6 +30,7 @@ "repository": { | ||
"watch": "tsc --watch", | ||
"test": "jest --verbose --passWithNoTests", | ||
"test": "jest", | ||
"test:coverage": "npm run test -- --coverage" | ||
}, | ||
"jest": { | ||
"verbose": true, | ||
"testEnvironment": "node", | ||
@@ -34,2 +40,5 @@ "testMatch": [ | ||
], | ||
"transform": { | ||
"^.+\\.tsx?$": "ts-jest" | ||
}, | ||
"rootDir": "." | ||
@@ -39,10 +48,12 @@ }, | ||
"codecov": "^3.6.1", | ||
"moo": "github:no-context/moo#master" | ||
"moo": "^0.5.1" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^24.0.18", | ||
"@types/moo": "^0.5.0", | ||
"@types/node": "^12.7.5", | ||
"jest": "^24.9.0", | ||
"ts-jest": "^24.1.0", | ||
"typescript": "^3.5.3" | ||
} | ||
} |
<h1 align=center>Searchbox</h1> | ||
<p align=center> | ||
๐น <a href="https://stuchl4n3k.net">stuchl4n3k.net</a> | ๐ป <a href="https://github.com/stuchl4n3k">stuchl4n3k</a> | ๐ฆ <a href="https://twitter.com/stuchl4n3k">@stuchl4n3k</a> | ||
๐ <a href="https://stuchl4n3k.net">stuchl4n3k.net</a> | ๐ป <a href="https://github.com/stuchl4n3k">stuchl4n3k</a> | ๐ฆ <a href="https://twitter.com/stuchl4n3k">@stuchl4n3k</a> | ||
</p> | ||
@@ -9,6 +9,7 @@ | ||
<a href="https://circleci.com/gh/webkitty/searchbox"><img src="https://img.shields.io/circleci/build/github/webkitty/searchbox?style=flat-square"></a> | ||
<a href="https://codecov.io/gh/webkitty/searchbox"><img src="https://img.shields.io/codecov/c/github/webkitty/searchbox?style=flat-square"></a> | ||
<a href="https://github.com/webkitty/searchbox/blob/master/LICENSE"><img src="https://img.shields.io/github/license/webkitty/searchbox?style=flat-square"></a> | ||
</p> | ||
A search box supporting multiple user-defined keywords (filters, variables). | ||
Text input augmented with Lexer magicโจ to support advanced search features. Searchbox supports multiple user-defined keywords (filters, variables) and also _NOT_ operator. | ||
@@ -20,3 +21,2 @@ ## Features | ||
- [x] Supports unicode. | ||
- [ ] Case-sensitivity is configurable. | ||
- [ ] Operators are configurable. | ||
@@ -35,8 +35,8 @@ | ||
// Formula: | ||
// fulltext: [Never,take,from] | ||
// title: [raisins] | ||
// -author: [rabbits] | ||
// _: [Never,take,from] // words not matching any keyword (aka fulltext) | ||
// title: [raisins] // "title" keyword match | ||
// -author: [rabbits] // "author" keyword match with NOT operator ("-") | ||
``` | ||
Please note that only **case-sensitive** keyword matching is currently supported. | ||
Please note that only **case-sensitive** keyword matching is supported. | ||
@@ -43,0 +43,0 @@ ## ๐ License |
@@ -11,4 +11,11 @@ import MooLexer = require('moo'); | ||
export {parse} | ||
const KEY_UNDEFINED = '_'; | ||
const OP_NOT = '-'; | ||
export { | ||
KEY_UNDEFINED, | ||
OP_NOT, | ||
parse, | ||
} | ||
/** | ||
@@ -104,3 +111,3 @@ * Parses a given user input into a structured formula. | ||
} else { | ||
this.append('fulltext', t1.value); | ||
this.append(KEY_UNDEFINED, t1.value); | ||
return 1; | ||
@@ -126,7 +133,4 @@ } | ||
// Fulltext keyword is omnipresent. | ||
if (!keywords.includes('fulltext')) keywords.push('fulltext'); | ||
// Define supported operators. | ||
const operators = ['-']; | ||
const operators = [OP_NOT]; | ||
@@ -133,0 +137,0 @@ // Define our (unicode) vocabulary. |
@@ -9,11 +9,6 @@ /** | ||
* By default no keywords are defined and everything is considered | ||
* a fulltext search. | ||
* "undefined" (aka fulltext) search and will be accessible in the | ||
* result under {@link KEY_UNDEFINED}. | ||
*/ | ||
keywords?: string[], | ||
// @todo: not supported yet in Moo https://github.com/no-context/moo/pull/122 | ||
// /** | ||
// * Whether the keywords search is case-sensitive. | ||
// */ | ||
// caseSensitive?: false, | ||
} | ||
@@ -20,0 +15,0 @@ |
@@ -12,3 +12,3 @@ { | ||
"outDir": "dist", | ||
"sourceMap": false, | ||
"sourceMap": true, | ||
"declaration": true, | ||
@@ -15,0 +15,0 @@ "typeRoots": [ |
Sorry, the diff of this file is not supported yet
GitHub dependency
Supply chain riskContains a dependency which resolves to a GitHub URL. Dependencies fetched from GitHub specifiers are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
0
30895
6
12
574
+ Addedmoo@0.5.2(transitive)
Updatedmoo@^0.5.1