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

cudcache

v1.4.2

Published

Store CUD requests for your Progressive Web App. When the user regains internet connection, fire them off with cudcache.

Downloads

3

Readme

cudcache

cudcache is a quick and simple JavaScript library for caching POST, PUT, and DELETE requests made when your app is offline. cudcache makes it easier to provide a comprehensive PWA experience for your users. cudcache relies on localforage for storage.

How to use cudcache

CUD provides a set of methods that wrap your post, delete, and put requests. Before sending the request, CUD tests the quality of the user's internet connection. If that test fails, CUD stores the request and associated data and sets an interval to re-check whether the user has regained connection. If so, all requests are processed atomically, i.e. if one fails they all fail. After successfully completing CUD clears the cache and the interval.

The Request Object

The request object is a parcel of data that enables CUD to make that request or pocket it for later. That request object will look something like this:

const requestObj = {
  url: 'https://example.com/createEvent',
  data: {
    title: 'Oh great another event',
    author: 'Anon'
  },
  headers: [{ name: 'Accept', value: 'application/json' }]
}

Not too painful! Then, just call cudcache.post(requestObj), cudcache.put(requestObj), or cudcache.del(requestObj). cudcache will take care of the rest.

You can call cudcache.init(options) with an options object as well. Options available at the moment for configuring your instance of cudcache:

Property name | Property type | Notes ------------- | ------------- | ----- networkTimeout | Integer | A number in milliseconds that will set the threshold to wait for network response before caching request. Defaults to 4000. testConnectionURL | String | URL to test for network connectivity. Defaults to 'https://api.coinranking.com/v1/public/coins'. unloadRequestsFailure | Function | Callback that executes if CUD tried to unload cached requests but failed. unloadRequestsSuccess | Function | Callback that executes if CUD tried to unload cached requests and succeeded. checkConnectionInterval | Integer | Number in milliseconds that dictates how long CUD should wait before trying to unload cached requests again. Defaults to 10000. batchCachedRequests | Boolean | Flag to designate whether cached requests should process atomically or not. Defaults to true.