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 🙏

© 2026 – Pkg Stats / Ryan Hefner

httptoast

v1.0.6

Published

An xmlhttplibrary

Downloads

13

Readme

Toast

Toast is a library designed to simplify making XMLHttpRequests. I've found myself including jquery just for ajax many times and thats a huge amount of overhead. I wanted to create a library that simplifies making these requests while still being lightweight and simple.

Usage

Using Toast is really easy.

Step 1: Download the javascript file for Toast here: Minified Release UnMinified Version Step 2: Include the javascript file list under the dist folder in your webpage.

<script src="dist/toast-1.0.1.min.js"></script>

Step 3: Make requests. You can make calls to toast either listing your parameters in a comma separated way, or using an options JSON object. Here are some sample ones:

npm

You can also use npm to get Toast.

npm install -g httptoast

Then, after Toast has been installed you can easily copy the client side script to your current directory by running the following:

toasthere

2 Minute Tutorial

Make a basic request


// Response is plain text
// Errors are logged to console.error because the second parameter is the failure callback
// url, success, fail
Toast.get("sample.html",alert, console.error);

// Response is parsed into json form 'sample.json'
// Errors are logged to console.error
//  url, success, fail
Toast.getJSON("sample.json",alert, console.error);

You can also give your options in an object


//plain text
Toast.get({
    url:"sample.html",
    success:alert,
    fail:console.error
});

//json
Toast.getJSON({
    url:"sample.json",
    success:alert,
    fail:console.error
});

The Unique Feature of Toast: Magic String Callbacks

One of Toast's coolest features is it's ability to use strings as a callback. This is really useful if you want only want a short callback. Toast's string callbacks user a 'magic' keyword data in them. See below an example of Toast's magic string callbacks.

//  The magic variable data holds the contents of sample.html or the error message.

Toast.get("sample.html",
    "console.log(data)",
    "console.error(data)"
);
// data is only accessible within the scope of the callback
console.log(data);
// data is undefined

// Example using object parameter instead of comma delimited
Toast.get({
    url:"sample.html",
    callback:"console.log(data)",
    fail:"console.error(data)"
});

Magic callbacks are a great way to implement one liner callbacks. Never Dynamically Concatenate Strings into Callbacks

Post requests post the parameters as JSON contained within the post body

Toast.post({
    url:"test.php",
    params:{
        "param1":true
    },
    success:alert,
    fail:console.error
});
// posts to test.php with a body of {"param1":true}

Cross Origin Requests

Enabling cross origin requests is really easy with toast. After including the latest release of toast, simply set the attribute crossOrigin to true.

/*
    Cross origin requests don't work!
*/
Toast.crossOrigin = true;
/*
    Cross origin requests here work
*/

Additional Debugging

Some debug messages are disabled by default, you can enable the extra messages like this:

Toast.debug = true;

Mascot

The current mascot is taken from an image labeled for reuse with modification by Deviant Art user One-Sided-Pancake http://one-sided-pancake.deviantart.com/

Contact

If anyone has any issues with this library please do not hesitate to open an issue on Github! Furthermore, if you have a feature suggestion do the same. For any other questions please open an issue on this repository.

MIT License

Copyright (c) 2016 Luke Wood

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.