limon
The pluggable JavaScript lexer. Limon = Lemon. 🍋
Examples
This is not finished yet, but go to examples directory and look deeply there. 🎉
We have few initial examples:
- advanced - making the lexer to not be "on per character basis", by overwriting the
.tokenize
method using plugin. - semver - tokenize semver string or alike
- simple - tokenize simple string (for example:
a > (b + 2)
) - csv - tokenize CSV string, and partially parsing
- more upcoming... going to port the PostCSS Tokenizer
And finally, after all, benchmarking.
Install
npm i limon --save
Usage
For more use-cases see the tests
const limon = const prevNext = limon var tokens = limonconsole// =>// [ [ 'letter', 'a', 0 ],// [ 'whitespace', ' ', 1 ],// [ 'symbol', '>', 2 ],// [ 'whitespace', ' ', 3 ],// [ 'symbol', '(', 4 ],// [ 'letter', 'b', 5 ],// [ 'whitespace', ' ', 6 ],// [ 'symbol', '+', 7 ],// [ 'whitespace', ' ', 8 ],// [ 'digit', '2', 9 ],// [ 'symbol', ')', 10 ] ]
Limon
Initialize
Limon
withinput
andoptions
. Both are completely optional. You can pass plugins and tokens tooptions
.
Params
input
{String}: String value to tokenize, or if object it is assumedoptions
.options
{Object}: Optional options, use it to pass plugins or tokens.
Example
var Limon = Limonvar lexer = 'foo bar' // or pass only optionsvar limon = foo: 'bar' var tokens = limon
Related
- lazy-arrayify: We are lazy, also lazy-cached and browserify-ready - just arrayify, falsey values… more | homepage
- lazy-cache: Cache requires to be lazy-loaded when needed. | homepage
- lazy-utils: Most of the used mostly everywhere utils: extend-shallow, isobject, is-extendable (used in… more | homepage
- limon-prev-next: Plugin for limon pluggable lexer that adds
prev
andnext
methods. | homepage - postjson: Transforming JSON with plugins. | homepage
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.