Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hash-brown-router

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hash-brown-router

A client-side router that only cares about the bits after the #

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
179
decreased by-21.49%
Maintainers
1
Weekly downloads
 
Created
Source

A router that is only concerned with single-page apps that want to change state based on the bits of the url after the hash.

To use

var makeRouter = require('hash-brown-router')

var router = makeRouter()

To add routes

router.add('/page/:pageName', function(parameters) {
	console.log(parameters.pageName)
})

Parses express-style route paths, using a fork of path-to-regexp.

Default route

router.setDefault(function(path) {
	console.log("you went to", path, "but that doesn't go anywhere, I guess I'll send you somewhere else")
})

Other

To force the routing library to evaluate the current route once your JavaScript is done loading (probably once the [dom is ready](https://www.npmjs.org/package/domready)), call `router.go()`.

If for some reason you want the router to start ignoring hash change events. you can call `route.stop()`.

License

WTFPL

Keywords

FAQs

Package last updated on 29 Oct 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc