Skip to content
Get the spirit of a string, without the whole thing!
TypeScript JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
.eslintrc.yml
.gitattributes
.gitignore
.nowignore
.travis.yml
LICENSE
Readme.md
now.json
package.json
rollup.config.js
tsconfig.json
yarn.lock

Readme.md

string-spirits

package version stability build status

A nice lightweight wildcard implementation written in TypeScript. I know there are already a lot of these, but I had a use case that required to test a string against many wildcards and determine which matched most specifically. I couldn't find one that did that, so I just made my own. (If you would like that same functionality, look at the bestMatch documentation.)

Installation

yarn add string-spirits

You should use Yarn and pnp.

Usage

Example:

import Spirit from 'string-spirits';

const format = new Spirit( 'The weather is * today!' );
const greeting = 'The weather is great today!';

console.log( format.match( greeting )
  ? greeting
  : 'I have no idea what the weather is like because I am just a computer!' );
You can’t perform that action at this time.