
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
A router for client-side (browser) JS applications.
Features:
This module makes use of a Makefile
for building/testing purposes. After obtaining a copy of the repo, run the following commands to make sure everything is in working condition before you start your work:
make install
make test
Before committing a change to your fork/branch, run the following commands to make sure nothing is broken:
make test
make test-cov
Don't forget to bump the version in the package.json
using the semver spec as a guide for which part to bump. Submit a pull request when your work is complete.
Notes:
npm install coordinate
This module assumes that you are using browserify to bundle your client-side code.
To use the router, require it in and initialize it like so:
var router = require('coordinate').getInstance(),
routes = [ '/', '/users', '/users/{userId}' ];
router.on('change', function(data) {
console.log(data.route); // the string route that was hit
console.log(data.params); // an object that contains any path parameters
console.log(data.context); // context data that was passed to the router.go method
console.log(data.history); // an Array of strings that contain the past paths that were navigated to
});
router.initialize({ routes: routes });
The following methods are available on the router
instance:
initialize(options:Object)
Initializes the routes. This method must be called before any of the other methods.
options
An object that contains the information needed to configure the router.
routes
A collection of valid routes.
Required.
root
The root path that all routes are appended to. For example, if the root is set to '/api', and there is a route '/users', then the expected full path would either be '/api/users' or '/api/#/users' depending on whether it is using the URL hash or HTML5 history API.
Defaults to '/'
isCaseSensitive
A flag that denotes whether the provided route paths should be considered case sensitive or not.
Defaults to false
useHash
A flag that denotes whether or not to use the hash for route paths, or to use the HTML5 history API.
Defaults to false
go(path:String, context:Object)
Looks up the route associated to the path, changes the hash or url in the browser, and emits a change event with the route that was hit, the path parameters, the context that was passed, and an array of the history of previous paths hit.
The MIT License (MIT)
FAQs
A router based on the hapijs call module targeted at the browser
We found that coordinate demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.