0.2.3 • Published 9 years ago

jsr-pattern v0.2.3

Weekly downloads
11
License
-
Repository
github
Last release
9 years ago

Table of Contents

Pattern Module

Pattern matching library that compiles string patterns to regular expressions.

Supports the following types of operation:

  • GLOB: redis style glob match.
  • REGEXP: Javascript regular expression match.

The caveat is that when specifiying patterns with escape sequences (literal character match), unlike redis two backslashes are required as it is not possible to correctly get a single backslash in a javascript string due to it being treated as a string escape character.

Component of the jsr library.

Requires node and npm.

Install

npm i jsr-pattern

API

Glob style:

var Pattern = require('jsr-pattern')
  , ptn = new Pattern();
console.log(ptn.filter('*o*', ['one', 'two', 'three']));

Regular expression style:

var Pattern = require('jsr-pattern')
  , ptn = new Pattern(Pattern.REGEXP);
console.log(ptn.filter('.*o.*', ['one', 'two', 'three']));

See the tests for more examples.

Developer

Test

Tests are not included in the package, clone the repository:

npm test

Documentation

To generate all documentation:

npm run docs

Readme

To build the readme file from the partial definitions (requires mdp):

npm run readme

License

Everything is MIT. Read the license if you feel inclined.

Generated by mdp(1).