f-matches: Composable version of Lodash.matches()
An utility used by Lebab for complex matching of AST nodes.
The package exports 4 curried functions:
matches :: Pattern -> Obj -> (Bool|Obj)
extract :: Name -> Pattern -> Obj -> (Bool|Obj)
extractAny :: Name -> Obj -> (Bool|Obj)
matchesLength :: Pattern -> Array -> (Bool|Obj)
For details, just read the source, it's really small.
Alternatively, read how Lebab uses this for patterns in syntax trees.
Example
; // Function for matching string literalconst isStringLiteral = ; // Function for matching: <local> = require(<source>)const isRequireDeclarator = ; // Function for matching: var <local> = require(<source>)const isRequire = ; // Transform require() call to ES6 import statement.estraverse;