@yuheiy/simple-url-dispatcher

0.2.1 • Public • Published

Simple URL Dispatcher

The dispatcher to divide methods of client-side JavaScript according to URL.

Installation

$ npm install @yuheiy/simple-url-dispatcher --save

Usage

var Dispatcher = require('@yuheiy/simple-url-dispatcher');
var dispatcher = new Dispatcher();

dispatcher.route('*', function () {
  console.log('run on all pages');
});

dispatcher.route('/', '/index.html', function () {
  console.log('index');
});

dispatcher.route('/about', function () {
  console.log('about');
});

dispatcher.route('/user/:id', function (params) {
  console.log('user', params.id);
});

// run url methods
dispatcher.run();

Readme

Keywords

none

Package Sidebar

Install

npm i @yuheiy/simple-url-dispatcher

Weekly Downloads

1

Version

0.2.1

License

MIT

Last publish

Collaborators

  • yuheiy