0.4.2
Matching core. Built using the JavaScript API using a Matcher or from a String in a Matchbox.
(errorFirstCallback?)
callback after matching finishes
Generates the matcher (ffm) for the given Rule(s).
(...Rule)
Rule(s) to match against.
ffm
:
a new matcher
const _ = require('lodash');
const ff = require('fluentflow');
const $ = ff.RuleBuilder;
const ffm = ff.Matcher(
$(
(o, p, c, pc, match, f) => match(o == 42)
).followedBy(
(o, p, c, pc, match, f) => match(o == 9000)
).then(
(objs, next) => next(
console.log(objs)
)
)
);
// match some objects
_.range(9001).forEach((obj) => ffm(obj)); // prints [42, 9000]
Generates the isolated matcher (ffm) for the given Rule(s).
ffm
:
an isolated
ffm
const _ = require('lodash');
const ffm = require('fluentflow').Matchbox(`
[
$(
(o, p, c, pc, match, forget) => match(o == 42)
).followedBy(
(o, p, c, pc, match, forget) => match(o == 9000)
).then(
(objs, next) => next(
console.log(objs)
)
)
]
`);
// match some objects
_.range(9001).forEach((obj) => ffm(obj)); // prints [42, 9000]
Checks if an Object matches.
Type: Function
(Object)
the object to check
(Object)
the previous object
(Object)
the matching context
(Object)
the matching context from the previous state
(match)
match callback, true if matches false otherwise
(forget)
forget callback, forget all states including objects passed as arguments
(thenCallback)
match callback
Builds Rule.
(checkerCallback)
first checker
RuleBuilder
:
continue
const rule = require('fluentflow').RuleBuilder(
(o, p, c, pc, match, forget) => match(o === 42)
).followedBy(
(o, p, c, pc, match, forget) => match(o === 9000)
).then(
(objs, next) => next(
console.log(objs)
)
); // prints [42, 9000]
Add a new checker.
(checkerCallback)
next checker
RuleBuilder
:
continue
Finishes and builds the chain.
(thenCallback?)
run if rule matches
Rule
:
finish
Signal the end of a thenCallback.
Signal the intent to forget an object. Must be called before next.
(...Object)
the object(s) to forget
Signal the result of a matching operation.
(Boolean?)
true if matched, false otherwise. Default if omitted: false.