JavaScript Utilities
A library of constants and functions that should work in any
- typescript
- ecmascript
- javascript
The intention is that the library should not depend upon any node-module that doesn't work in at least these environments:
- Enonic XP serverside code
- Modern browser
- Newest LTS version of Node
It should work in at least these frameworks:
Examples
DSL
import {storage} from '@enonic/js-utils';
const and = storage.query.dsl.and;
const bool = storage.query.dsl.bool;
const fulltext = storage.query.dsl.fulltext;
const ngram = storage.query.dsl.ngram;
const stemmed = storage.query.dsl.stemmed;
const fields = 'url^1.2,title^1.1,text';
const searchString = 'fun video';
const operator = 'OR';
const query = bool(and(
fulltext(fields, searchString, operator),
stemmed(fields, searchString, operator, 'no', 0.9),
stemmed(fields, searchString, operator, 'en', 0.8),
ngram(fields, searchString, operator, 0.7)
));
console.debug(JSON.stringify(query, null, 4));
Filter
import {addQueryFilter} from '@enonic/js-utils';
const filters = addQueryFilter({
filter: {
exists: {
field: 'required'
}
}
});
Release
git tag vX.Y.Z
git push origin vX.Y.Z
This will trigger release & publish on NPM.