1.1.2 • Published 8 years ago

path-dispatcher v1.1.2

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

path-dispatcher

Build Status Dependency Status Devdependency Status GitHub version License

Static url dispatcher

npm i path-dispatcher

Usage

import pathDispatcher from 'path-dispatcher';

const dispatcher = pathDispatcher({
  '/': () => {},
  '/page': [() => {}, otherFunc],
  ['/other.html']() {}
}, { rootPath: '/root/path' });

dispatcher.route('/page.html', pageFunc);

dispatcher.dispatch();

API

create dispatcher

pathDispatcher(routes = {}, config = { rootPath: '' })

route

dispatcher.route(pathName, funcOrFuncs)
@param {String}
@param {Function|Function[]} funcOrFuncs

dispatch

dispatcher.dispatch(currentPathName)
@param {String} [currentPathName = location.pathname || '']

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

MIT

© sugarshin