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

laurence

v1.0.0

Published

a simple cache for offline development

Downloads

2

Readme

Laurence

A simple cache for offline development.

in short

  1. install Laurence in your app: import "laurence";
  2. make some network requests using fetch()
  3. disconnect from the internet
  4. make those same network requests again successfully

details

Sometimes you:

  • don’t have internet, but want to work on something that makes network requests.
  • do have internet, but want work without getting distracted.

Laurence works by caching your requests into localStorage and replaying them while your internet is offline. Laurence only caches successful requests, and checks navigator.onLine to determine whether or not you’re connected to the internet.

Laurence works by wrapping fetch(), so you may want to use a fetch polyfill.

installation

In your terminal,

npm install --save-dev laurence

and in your app,

import "whatwg-fetch"; // Make sure any fetch polyfill you use comes first.
import "laurence";     // Please don’t rely on this in prod though. That’s a terrible idea.

some important notes

There’s a lot that you should know about Laurence.

Laurence isn’t for production

Laurence is meant as a development tool, not as a production cache.

I wrote Laurence at an airport in way less time than it should take to build something production-ready, so please don’t use this to actually cache parts of your app. Laurence has no logic for cache invalidation and doesn’t come with all the other niceties that you’d expect from a cache (like TTL or eviction policies).

Laurence stores URLs as plain text in localStorage

This probably isn’t be a big deal, but you’ll want to make sure you’re thoughtful about requests with API keys in them. They’ll sit around in your localStorage until you manually evict them. In the future, cache keys may be hashed which will make this a non-problem.

Laurence caches requests based on URLs and request methods

Meaning GET https://mozilla.org and POST https://mozilla.org are considered to be different. This method should work for most use cases, but it most notably won’t work when your requests rely on headers. Speaking of,

Laurence doesn’t cache headers

This is still something that needs to be implemented. For now, Laurence just caches status, status text, and the actual body (which it reads out and persists as text).