@lars_hagemann/tags
v1.0.6
Published
A general tagging library build on typescript
Readme
Tagging system
This package provides a simple way of parsing tags into a programmatically useful form.
Usage
Parse a filter query:
const parser = new TagParser('(abcd & efgh) | (ijkl & mnop)');
const parsed = parser.parse();
/*
parsed = OrTag(
AndTag(Tag('abcd'), Tag('efgh')),
AndTag(Tag('ijkl'), Tag('mnop'))
);
*/You can also provide your own scanner implementation (if you want to change the way that certain lexemes are tokenized):
class MyScanner {
public nextToken(): Token {
// scans && into AND and 'OR' into OR
}
// ...
};
const parser = new TagParser('[abcd && efgh] OR [ijkl && mnop]', MyScanner);
const parsed = parser.parse();See the Samples and the integration tests for example applications of this library.
Tests
Run the unit tests via
npm run test:unitor run the integration tests via
npm run test
- or
npm testYou need docker installed on your systems to run the integration tests.
