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

jsf-mock

v0.1.2

Published

Mock implementation for jsf.js

Downloads

20

Readme

jsf.mock.js Build Status

When it comes to TDD, jsf.js needs to be mocked somehow.

Quickstart

Just include jsf.mock.js and you are good to go.

Mocked methods:

  • jsf.ajax.addOnEvent adds the given function as a normal event handler to a local array
  • jsf.ajax.addOnError adds the given function as an error handler to the local array

Helper methods:

  • jsf.ajax.fire([type], eventData, [name]) fires an event with the given data. If no type is provided, only the non error handlers will be used. If type === 'error' only the error handlers will be used. Finally if a name is provided handlers will be filtered based on their name.
  • jsf.ajax.hadlersSize([query]) returns the size of the available non error handlers if no query is given. If error is given as a query then returns the number of the error handlers. In any other case it returns the handlers with a name equal to the given query.
  • jsf.ajax.clearHandlers([query]) clears all the existing non error handlers available. If query === error it clears the error handlers. In any other case it clears the handlers with a name equal to the given query.

Here is an exaple of how to use it

var errorHandler = function () {};

jsf.ajax.addOnEvent(function () {});
jsf.ajax.addOnError(errorHandler);
jsf.ajax.addOnError(function anotherErrorHandler() {});

jsf.ajax.fire({}); //only the anonymous handler will be used
jsf.ajax.fire('error', {}); //only the error handlers will be used
jsf.ajax.fire('error', {}, 'anotherErrorHandler'); // only the anotherErrorHandler will be used

Developing

Assuming that you have node installed, you can gulp tdd in order to watch for file changes and run the tests. Before you commit make sure you run the default gulp task.

Finally you can use gulp to to a release with gulp release [--major|minor]. If no major or minor will be given the version will get bumped as a patch.

References