hash-match makes it easier to match window.location.hash with a router like wayfarer.
npm i --save hash-match
var match = ;;// returns "/weeee";// returns "/weeee"
So it's only really interesting if you use it like this:
;// returns whatever the hash is
You can optionally set a prefix:
and if the hash looks like
'#hmm/whatever' then you'll get
'/whatever' in return.
ok but why
For feeding the output of hash-match into a router like wayfarer.
Here's an example:
var hashMatch = ;var router = default: '/' ;routerrouter// Here's where hashMatch does its thing:router;
Now when you navigate to
/wat route will execute.
And if you want you can listen for the
hashchange event to update the router: