steal-fuzzy-normalize

1.0.0 • Public • Published

steal-fuzzy-normalize

Build Status npm version

steal-fuzzy-normalize is a module that tries its hardest to normalize a module identifier given the normal steal rules. It's imperfect, but if you give it a list of possible matches it might just work.

Install

npm install steal-fuzzy-normalize --save

Examples

Getting a match from an array.

var normalize = require("steal-fuzzy-normalize");

var possibilities = [
	"app@1.0.0#home/home",
	"app@1.0.0#orders/orders",
	"app@1.0.0#cart/cart"
];

var match = normalize("orders/", possibilities);

assert.equal(match, "app@1.0.0#orders/orders"); // Works

Getting a match from an object. This allows you to get metadata for a particular match (useful for bundle manifests).

var normalize = require("steal-fuzzy-normalize");

var possibilities = {
	"app@1.0.0#home/home": {page:"home"},
	"app@1.0.0#orders/orders": {page:"orders"},
	"app@1.0.0#cart/cart": {page:"cart"}
};

var match = normalize("orders/", possibilities);

assert.equal(match.page, "orders"); // Works

Dependents (2)

Package Sidebar

Install

npm i steal-fuzzy-normalize

Weekly Downloads

1

Version

1.0.0

License

ISC

Last publish

Collaborators

  • matthewp