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

chickendinosaur-http

v0.0.5

Published

Front-end, super slim, ajax, xhr, http library with promises.

Downloads

6

Readme

http-js

Front-end, super slim, singleton, , http library with promises. The goal was to have a lightweight http library without having to use jQuery or having too many dependencies of libraries that will never get used anywhere else but still get loaded. Less is more!

Universal module defined to be used with requirejs, commonjs, node, or global scoped if no module loader is used.

  • All files in the dist folder are minified for production use.
  • All files in the src directory are the source code for development use.
  • Packages point at the dist minified code with source maps.
  • nodejs
  • npm install
  • npm install -g gulp

gulp test

Each process is dependent upon the previous. If one fails the build process exits.

  • gulp
  • gulp test (Unit specifications)
  • gulp build (Test, folder clean-ups, minification, source maps, renaming)
  • gulp deploy (Test, build, versioning)

bower: bower install chickendinosaur-http

Uses the es6-promise library which is a smaller subset of the RSVP promise library so please check the documentation of those for more functionality. It's the smallest and most used library that I was able to find at the moment without writing my own.

// Global usage.
var Http = ChickenDinosaur.Http;

// Basic 'GET' with a query parameter.
Http.get('chickenosaurus' {
    id: 'Snow Piercer'
}).then(function(res) {
    // res is the XHR.responseText object which has already parsed by JSON.parse if the response was JSON.
    console.log(res);
}, function(err) {
    // err is the entire XHR object to be able to access anything needed for debugging.
    console.log(err);
});

// Promise chaining
Http.get('chickenosaurus' {
    id: 'Snow Piercer'
})
.then(function(res) {
        // res is the XHR.responseText object which has already parsed by JSON.parse if the response was JSON.
        console.log(res);

        return Http.post('chickenosaurus', {
            name: 'Dylan Riley',
            skills: ['Sand Shredding', 'Skimming'],
            diet: 'Wild Turkey.',
            alias: 'Popcorn Frog'
        });
    },
    function(err) {
        // err is the entire XHR object to be able to access anything needed for debugging.
        console.log(err);
    })
.then(function(res) {
        // res is the XHR.responseText object which has already parsed by JSON.parse if the response was JSON.
        console.log(res);

        return Http.put('chickenosaurus', {
            name: 'Kevin Fincel',
            skills: ['Killing everything in South Dakota', 'Nerdpress'],
            diet: 'Jalepeno infused vodka.',
            alias: 'The Incubationer'
        }, {
            id: '3452EW3453UN5'
        });
    },
    function(err) {
        // err is the entire XHR object to be able to access anything needed for debugging.
        console.log(err);
    })
.then(function(res) {
        // res is the XHR.responseText object which has already parsed by JSON.parse if the response was JSON.
        console.log(res);

        return Http.delete('chickenosaurus', {
            id: '3452EW3453UN5'
        });
    },
    function(err) {
        // err is the entire XHR object to be able to access anything needed for debugging.
        console.log(err);
    })
.then(function(res) {
        // res is the XHR.responseText object which has already parsed by JSON.parse if the response was JSON.
        console.log(res);

        return Http.delete('chickenosaurus', {
            id: '3452EW3453UN5'
        });
    },
    function(err) {
        // err is the entire XHR object to be able to access anything needed for debugging.
        console.log(err);
    });

You could create each Http call seperately like:

	ES6Promise.all([promise1, promise2])
	.then(function(posts){
		// posts is an array of results.
		})
	.catch(function(reason){
		// if any promise fails.
		});

and have a single callback when they all have received a response or error thanks to the promise library which is the reason I went with it due to have needed the extra functionality for resolving multiple things in enterprise projects.