Ruler instances serve for checking directory entries and are usually created and
managed by Walker.
The class declaration is in src/Ruler/index.js.
constructor([options,] ...rule)
options.extended : boolean = true- enable{...}syntax by usingbrace-expansionnpm package;options.optimize : boolean = true;rule- applied toaddmethod.
The package README describes how it works.
add(...definition) : Ruler - method
The definition parameter can be a number, string or array.
A numeric value is an action code for all the rules defined by strings that follow.
Internally, the rules form an inverted tree. A definition like 'a/b' will
be check for a matching rule path - if rule for 'a' exists, the 'b' will be added
as its descendant.
For better readability, you can form definitions as arrays -
add() will flatten those internally.
check(name, [type]) : number - method
Matches all rules descending from current ancestors property against given
name, if type is not given or matches the rule type.
Returns the highest action value from all matching rules or DO_NOTHING.
clone([ancestors]) : Ruler - method
Create an identical copy of the ruler instance, with ancestors property
set to supplied argument - see the
source code for details.
dump([options]) : string - method
Used for debugging. Returns undefined in production environment.
lastMatch : number[][] - property
Gives internal descriptor of all rules matching the most recent check() call.
This value applied to clone() method serves to implement hierarchic rules.
_ancestors : number[][] - property
Array of tuples (action, ruleIndex), set by clone().
Only the rules with ancestor matching a ruleIndex in here, will be used by check().
_lastMatch : number[][] - property
Array of tuples (action, ruleIndex) describing which rules did match during the recent check() run.
This data is available via lastMatch public property.
_nextRuleAction : number - property
Used internally by add*_() methods during rule definitions parsing.
_options : Object - property
Rule parsing options provided to constructor.
_tree : number[][] - property
An inverted tree of rules as tuples (entryType, match, parentIndex, actionCode).
The match member is a RegExp instance or null (matching any directory path).
There are also add_(definition), addPath_(definition) and addRules_(rules, type, action)
methods, which may be of interest only when writing derived classes.