npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

coordinate

v0.1.0

Published

A router based on the hapijs call module targeted at the browser

Downloads

10

Readme

coordinate

A router for client-side (browser) JS applications.

Features:

  • implements the routing strategy from HapiJS (uses call under the covers)
  • emits events instead of calling callbacks of function handlers when a route is hit
  • supports using the url hash or the HTML5 history API

Build Status Coverage Status NPM version Dependency Status

NPM

Contributing

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:

  • Please do your best to ensure the code coverage does not drop. If new unit tests are required to maintain the same level of coverage, please include those in your pull request.
  • Please follow the same coding/formatting practices that have been established in the module.

Installation

npm install coordinate

Usage

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.path);        // the raw path
	console.log(data.queryString); // the raw query string is on the url
	console.log(data.queryPath);   // the parsed query string object
	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 });

API

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 query string values, the context that was passed, and an array of the history of previous paths hit.

License

The MIT License (MIT)