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

jabiru

v2.1.0

Published

Simple script to manage JSONP calls

Downloads

19

Readme

jabiru

Build Status

Simple script to manage JSONP calls.

Install

Add the distribution file to your project.

<script src="/scripts/jabiru.min.js"></script>

You can also install it as a node module.

npm install jabiru --save

Using bower to install packages in your project?

bower install jabiru --save

Use

If you need to do a cross domain call jaribu will help you. You just need to call its get() method with the url and the function you need to manage the response in a configuration object.

jabiru.get({
    url: 'http://api.github.com/users/jeremenichelli',
    success: function(response) {
        // do something with the response
    }
});

Failure

Now in v2.0.0 you can also control failure cases adding an optional fail method.

jabiru.get({
    url: 'http://api.github.com/users/jeremenichelli',
    success: function(response) {
        console.log(response.name);
    },
    fail: function() {
        console.log('Oops!');
    }
});

Query string

APIs have different query structure, for example Github's one uses ?callback to name its jsonp method but if the api you're trying to reach needs another syntax you can use the query method to change it.

jabiru.query('?jsonp');

Callback dynamic name

Every time a request is done through jabiru a temporary function is created, by default that method name is jabiruCallback, but you can modify that using the naming function.

jabiru.naming('myMethod');

Every time you change the name of the method the internal call counter will be set to 0 again. Also this name will be contained in the module namespace for security, in this example jabiru.myMethod0 for the first call.

If you want it to be globally available you can call jabiru.toGlobal() before starting to use the script, but window.MyMethod0 will be available for any script while the call is being made.

Once you call jabiru.toGlobal() you can't revert to the namespace state.

Chaining

You can stick all this configuration together like this:

jabiru.toGlobal()
    .naming('githubAPI')
    .query('?callback')
    .get({
        url: 'https://api.github.com/users/jeremenichelli',
        success: function(response) {
            console.log(response.name);
        }
    });

Remember you don't have to set the name and the query string every time. For the rest of the calls you just have to use the get method.

Browser support and size

The last version of jabiru weighs only 503 bytes minified and gzipped and it works in Chrome, Firefox, Safari, Microsoft Edge, Internet Explorer 9, 10, and 11. From version 2.0.0 the support for Internet Explorer 8 was dropped.

If you want this library to work in Internet Explorer 8 you can use v1.1.0.

Contribute

If you find a bug or something that should be added as a feature let me know here.