rocambole-whitespace
Helpers to manipulate rocambole
WhiteSpace
tokens.
Used mainly by esformatter and its plugins.
API
var ws = ;
setOptions(opts)
setOptions
is just a way to store some constants so later on the
limit
/limitBefore
/limitAfter
you can reference the values by Id.
;
Important: calling this method will override all the options.
limitBefore(token, typeOrValue)
limits the amount of WhiteSpace
before a given token.
// remove all white spaces before `node.startToken`;// add/keep 2 white spaces before `node.startToken`;// will use value stored on `setOptions` for `before.parenthesis`;// values smaller than zero are ignored (this won't change anything);
limitAfter(token, typeOrValue)
limits the amount of WhiteSpace
after a given token.
// remove all white spaces after `node.startToken`;// add/keep 1 white space after `node.startToken`;// will use value stored on `setOptions` for `after.parenthesis`;// values smaller than zero are ignored (this won't change anything);
limit(token, typeOrvalue)
limits the amount of WhiteSpace
around a given token.
// add/keep 1 white space before and after `node.startToken`; // it's just an alias to;;
expectedBefore(type)
reads value stored during setOptions
for a given type
, or returns -1
if
not found.
;
expectedAfter(type)
reads value stored during setOptions
for a given type
, or returns -1
if
not found.
;
Debug
This module uses debug internally. To
make it easier to identify what is wrong we sometimes run the esformatter tests
with a DEBUG
flag, like:
DEBUG=rocambole:ws:* npm test
License
Released under the MIT License