steal-fuzzy-normalize
v1.0.0
Published
[](https://travis-ci.org/stealjs/steal-fuzzy-normalize) [](http://badge.fury.io/js/steal-fuzzy-normaliz
Readme
steal-fuzzy-normalize
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 --saveExamples
Getting a match from an array.
var normalize = require("steal-fuzzy-normalize");
var possibilities = [
"[email protected]#home/home",
"[email protected]#orders/orders",
"[email protected]#cart/cart"
];
var match = normalize("orders/", possibilities);
assert.equal(match, "[email protected]#orders/orders"); // WorksGetting 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 = {
"[email protected]#home/home": {page:"home"},
"[email protected]#orders/orders": {page:"orders"},
"[email protected]#cart/cart": {page:"cart"}
};
var match = normalize("orders/", possibilities);
assert.equal(match.page, "orders"); // Works