Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/aslilac/spirits

Get the spirit of a string, without the whole thing!
https://github.com/aslilac/spirits

fuzzy-matching glob wildcard

Last synced: 3 months ago
JSON representation

Get the spirit of a string, without the whole thing!

Awesome Lists containing this project

README

        

# spirits

[![package version](https://img.shields.io/badge/dynamic/json?color=d0d0d0&label=spirits&prefix=v&query=%24%5B%27dist-tags%27%5D.latest&url=https%3A%2F%2Fregistry.npmjs.com%2Fspirits)](https://npmjs.com/package/spirits)
[![main](https://github.com/aslilac/spirits/workflows/main/badge.svg)](https://github.com/aslilac/spirits/actions)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)

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.)

## Usage

- [Documentation](https://spirits.vercel.app)

Example:

```JavaScript
import Spirit from "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!");
```