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

@wezz/fetchmanager

v1.0.11

Published

A script that improves a javascript fetch requests with request throttling, managing querystring parameters and delayed request start

Downloads

198

Readme

Fetch Manager

This is a script to ease the use of making fetch requests. It features the ability to stop consequetive requests, delay a request and parse querystrings from JSON.

Installation

npm install @wezz/fetchmanager

Usage

Initialize Fetch Manager

import { FetchManager } from '@wezz/fetchmanager';
// On document ready
const response = fetchManager.Fetch({
    "url": "urlhere"
});
const data = response.json();

Options

When doing a fetch request you should define a options object that looks like this:

{
    "key": "unique request key",
    "url": "https://requesturl.com"
    "querystring": { "querystringkey": "querystringvalue" },
    "requestdelay": 0,
    "cache": false,
    "fetchoptions": null,
    "json": true
}

Note that the option fetchoptions is passed down directly to fetch. Click here for the fetch options documentation

Key

If a key is set then the "signal" will be stored and if another request is being sent with an identical key, the current request will be aborted. So if you're doing requests related to a users input (typing in an input field) and sending a request per input, this would stop all the old requests and only deliver the last request made as to stop race conditions.

Url

This is the URL you wish to fetch, without parameters

Querystring

This can be empty, an object that will be parsed to a querystring, or just a string.

Request delay

This delays a request with the specified amount of miliseconds.

Cache

If this is enabled then any request will be cached in either local or session storage. Session storage is default. You can either send in a boolean, or you can send in an object like this

{ permanent: true, cachekey: 'myCacheKey' }

If permanent is set to true it will be stored in local storage.

JSON

The JSON options will add the header "Content-Type": application/json and it is enabled by default. If another content type header has been specified it will not override it.

Set this to false if you need to fetch any mimetype that is not json.

Fetch options

Fetch options is standard fetch opions. Read more about fetch options on MDN.

Development & Demo

Clone this repo Run npm install

To run the interactive demo, run npm run demo

Breaking changes

In the Version 1 release the response is no longer automatically parsed to JSON. Consumers of the package will get the regular response object back just as if they had used the native fetch function.