prefixnote
Annotate strings with simple, embedded prefix expressions.
Used by yogini.
Install
$ npm install --save prefixnote
Basic Usage
var prefixnote =
Given a trivial expression of {a}
, testing the expression with the data { a: true }
will return a match result.
prefixnote // { expression: 'a', args: [], options: {} })
Testing the same expression with { a:false }
will return null
since the expression does not evaluate to true for the given data.
prefixnote // null
It accepts any static boolean expression.
prefixnote // { expression: 'a && b', args: [], options: {} })prefixnote // nullprefixnote // null
If multiple expressions are embedded, it returns the first one that evaluates to true (like an or
expression).
prefixnote // { expression: 'a', args: [], options: {} })prefixnote // { expression: 'b', args: [], options: {} })
Arguments and Options
Expressions can contain arbitrary arguments (values) or options (key-value pairs).
prefixnote // { expression: 'a', args: [], options: { one: 'uno', two: 'dos', three: 'tres' } })prefixnote // { expression: 'a', args: ['hi'], options: {} })prefixnote // { expression: 'b', args: ['bye'], options: {} })
Other Usage
Use prefixnotes as smart file filters (used by yogini).
prefixnote
Parse prefixnotes and then do whatever you want with them.
prefixnote /*{ original: '{a}{b}test', value: 'test', expressions: [ { expression: 'a', args: [], options: {} }, { expression: 'b', args: [], options: {} } ]}*/
License
ISC © Raine Revere