0.0.5 • Published 7 years ago
real-ssql v0.0.5
Super simple query language for matching strings.
Grammar
not-operator: NOT
binary-operator: AND OR
text: any non-empty string which is neither not-operator nor binary-operator and doesnt contain parens
expression: (expression) not-operator expression text expression binary-operator expression
Usage
const ssql = require('real-ssql');
let query = ssql.parse('(hello OR world) AND (bar OR baz)');
ssql.match(query, 'world'); //false
ssql.match(query, 'hello'); //false
ssql.match(query, 'hello world'); //false
ssql.match(query, 'world hello'); //false
ssql.match(query, 'world bar hello'); //true
ssql.match(query, 'world baz'); //true
ssql.match(query, 'hello baz'); //true
ssql.match(query, 'hello bar'); //true
Also you can specify your own representation of operators:
let query = parse('(hello или world) и (bar или baz)', {
and: 'и',
or: 'или',
not: 'не'
});
ssql.match(query, 'hello world'); //false
ssql.match(query, 'world baz'); //true
ES5 version
This may be needed, for example, in a project created with react-create-app
.
import ssql from 'real-ssql/es5';