JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4405973
  • Score
    100M100P100Q203458F
  • License MIT

Simple wildcard matching

Package Exports

  • matcher

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (matcher) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

matcher Build Status

Simple wildcard matching

Useful when you want to accept loose string input and regexes/globs are too convoluted.

Install

$ npm install --save matcher

Usage

const matcher = require('matcher');

matcher(['foo', 'bar', 'moo'], ['*oo', '!foo']);
//=> ['moo']

matcher(['foo', 'bar', 'moo'], ['!*oo']);
//=> ['bar']

matcher.isMatch('uni*', 'unicorn');
//=> true

matcher.isMatch('*corn', 'unicorn');
//=> true

matcher.isMatch('un*rn', 'unicorn');
//=> true

matcher.isMatch('!unicorn', 'rainbow');
//=> true

matcher.isMatch('foo b* b*', 'foo bar baz');
//=> true

matcher.isMatch('uni\\*', 'unicorn');
//=> false

API

matcher(inputs, patterns)

Accepts an array of input's and pattern's.

Returns an array of of inputs filtered based on the patterns.

matcher.isMatch(input, pattern)

Returns a boolean of whether the input matches the pattern.

input

Type: string

String to match.

pattern

Type: string

Use * to match zero or more characters. A pattern starting with ! will be negated.

  • multimatch - Extends minimatch.match() with support for multiple patterns

License

MIT © Sindre Sorhus