Socket
Book a DemoInstallSign in
Socket

bee-line

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bee-line

A simple hash based router which supports query strings

0.1.3
latest
Source
npmnpm
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

bee-line

A Simple hash based router which supports query strings

Documentation

This is a port of the simple-hash-router in ES5 syntax and includes the ability to have query strings.

Your links looks like this:

<a href='#'>Index</a>
<a href='#about'>About</a>
<a href='#page/2'>Page 2</a>

You require the module.

var beeline = require('bee-line');
// or just include it in the head of the html


// Then you attach a your favorite listener to the `beeline`
beeline.register(function (page, params, query) {
    console.log(page);      // Name of the page
    console.log(params);    // Object with parameters
    console.log(query); //  object describing the query params eg: ?name=value&name2=val2 => {name:value, name2:val2}

    // This is where you'd do your magic.
});


// Then you define your routes. They have to be a list because the order
// matters. beeline will trigger on the first matched route.
beeline.addRoutes([
   {'/': 'index-page'},
   {'about': 'about-page'},
   {'page/:id': 'paginated-page'}
]);

// Lastly, you start it. When starting it, it will also trigger the approrpate
// route even though the URL did not change.
beeline.start();

404?

In case you link to an undefined route, it will notify registered functions with a not-found page name.

License

MIT.

Attribution

Original routing developed by Gorm Casper

Keywords

router

FAQs

Package last updated on 11 Feb 2016

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.