https://github.com/stealjs/steal-fuzzy-normalize
Try to normalize a module identifier given a set of possible module names. Match to the closest result possible.
https://github.com/stealjs/steal-fuzzy-normalize
Last synced: 3 months ago
JSON representation
Try to normalize a module identifier given a set of possible module names. Match to the closest result possible.
- Host: GitHub
- URL: https://github.com/stealjs/steal-fuzzy-normalize
- Owner: stealjs
- Created: 2017-08-10T14:41:03.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2020-05-23T12:21:47.000Z (about 5 years ago)
- Last Synced: 2025-02-21T04:36:31.072Z (3 months ago)
- Language: JavaScript
- Size: 15.6 KB
- Stars: 1
- Watchers: 10
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# steal-fuzzy-normalize
[](https://travis-ci.org/stealjs/steal-fuzzy-normalize)
[](http://badge.fury.io/js/steal-fuzzy-normalize)
[](https://greenkeeper.io/)**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.
```js
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"); // Works
```Getting a match from an object. This allows you to get metadata for a particular match (useful for bundle manifests).
```js
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
```