Emojideas
Text-to-emoji suggestion library with a Lunr and emojilib backend. Suggestions are based on emoji name and keywords.
Usage
Install the library:
npm install --save emojideas
yarn add emojideas
Require the module, create an instance, and call the suggest
function on some text:
const Emojideas = require('emojideas');
const e = new Emojideas();
e.suggest('aerial tramway');
Results are ordered based on the score calculated by Lunr.
Options
The constructor accepts several options.
option | description |
---|
fuzzy | level of fuzzyness to apply to all Lunr queries (default: 0 ) |
nameBoost | weight applied to emoji name relative to keywords when ordering results (default: 3 ) |
formatOutput | function passed each Lunr result to format output (default: el => el.ref ) |
require('emojilib')['🚡'];
const f = new Emojideas({ fuzzy: 1 });
f.suggest('trumway');
const g = new Emojideas({ nameBoost: 0 });
g.suggest('aerial tramway');
const h = new Emojideas({ formatOutput: el => [el.ref, el.score] });
h.suggest('aerial tramway');
Lunr
All queries are passed directly to the Lunr backend, and can therefore use the Lunr syntax, except when the fuzzy
option has been set.
require('emojilib')['🚊'];
const e = new Emojideas();
e.suggest('tram');
e.suggest('tram*');
e.suggest('aerial tram*');
e.suggest('tram* -tram');
CLI
A command line search implementation based on Commander is included.
Install the library globally:
npm install -g emojideas
yarn global add emojideas
Run a query:
emojideas aerial tramway
To see available options:
emojideas --help