JSPM

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

Match against Wildcard values (works in browser)

Package Exports

  • wildcard-utils

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 (wildcard-utils) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

wildcard-utils

Work with wildcard values by matching, searching, and filtering values that match a given wildcard pattern.

Installation

yarn add wildcard-utils

or

npm install --save wildcard-utils

Flow Coverage

Proudly built with 100% Flow Coverage and exported .flow.js files so your flow projects will benefit!

We strongly recommend you look over the types in the source. This will give you an idea of how the various pieces of the package work.

Examples

This package provides extreme flexibility for searching values for wildcard matches. While the example below is simple, you are encouraged to take a look at the examples folders for examples of the more advanced functionality that is available.

Simple String Example

A simple example using simple string matching against a given wildcard pattern.

import { Wildcard } from 'wildcard-utils';

const system_wildcard = new Wildcard().case(false).pattern('system*');

const isSystemType = type => system_wildcard.match(type);

isSystemType('SYSTEM_OFFLINE');
// true

isSystemType('NETWORK_OFFLINE');
// false

More Examples

More examples can be seen and tested by checking out the examples folders

Exports

There are two ways you can use this package. If you simply wish to use the simplistic pattern generator that is used to build the RegExp values, you can import from wildcard-utils/to-pattern. For the full-featured version, import the Wildcard class directly.

Wildcard Class

import Wildcard from 'wildcard-utils';
const WC = new Wildcard();

Pattern Generator

import toWildcardPattern from 'wildcard-utils/to-pattern';

const pattern = toWildcardPattern(['ONE*TWO*THREE', 'FOUR*FIVE*SIX'], {
  logic: 'or',
  flags: 'i',
});