Skip to content

Latest commit

 

History

History
26 lines (22 loc) · 722 Bytes

README.md

File metadata and controls

26 lines (22 loc) · 722 Bytes

pattern

Easy handling of JavaScript regular expressions.

install & import

npm install @essentialib/pattern
const Pattern = require("@essentialib/pattern");

example

// same as /-?(\d+)/
const isInteger = Pattern(_ => _
    .maybe('-')  
    .capture(g1 => g1
        .digit().oneOrMore()
    )
);

console.log(isInteger.test('-34'));  // true

See the wiki for more information