Socket
Book a DemoInstallSign in
Socket

vedrani-fetch-coalesce

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vedrani-fetch-coalesce

Coalesces multiple calls to fetch() for the same URL into a single network request.

1.1.0
latest
Source
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

fetch-coalesce

fetch-coalesce is a decorator that coalesces multiple equivalent fetch() calls into a single network request.

Install

$> npm install fetch-coalesce --save

Example

import coalesce from 'fetch-coalesce';

const fetch = coalesce({ methods: ['GET', 'HEAD'] })(window.fetch);

fetch('/foo/bar');
fetch('/foo/bar');
// Only one network request is made.

Usage

import coalesce from 'fetch-coalesce';

coalesce(config) => decorator(fetch) => decorated

  • Function that accepts configuration and returns a fetch decorator Function.
  • Parameters
    • (Object) config [optional]:
      • (String[]) config.methods [optional]: HTTP methods (GET, PUT, POST, etc.) that should be coalesced. By default, all idempotent methods are coalesced.
  • Returns
    • (Function): A fetch decorator Function:
      • Parameters
        • (Function) fetch: The fetch Function to decorate. Should pretty much always be window.fetch.
      • Returns
        • (Function): The decorated fetch Function. Call it just like you would call fetch().

Keywords

fetch

FAQs

Package last updated on 19 Oct 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.