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

memofetch

v1.1.1

Published

Node.js Fetch API with Memoization

Readme

memoFetch

fetch API with memoization

Install

npm i memofetch

Usage

GET

import { memoFetch, setExpirationTime, setMaxMemo } from 'memoFetch';

(async () => {
  await setMaxMemo(10);
  await setExpirationTime(5000);

  const { data } = await memoFetch(
    'https://naveropenapi.apigw.ntruss.com/map-geocode/v2/geocode?query=' +
      encodeURIComponent('양천구'),
    {
      filter: ({ addresses }) => {
        return {
          x: addresses[0].x,
          y: addresses[0].y,
        };
      },
      headers: {
        'X-NCP-APIGW-API-KEY-ID': 'sample',
        'X-NCP-APIGW-API-KEY': 'sample',
      },
    },
  );

  console.log(data);
})();

Save in JSON format

{
  "memo": {
    "gBWWpZc5vilNlknBafd7yqi+nAo=": {
      "value": {
        "headers": {
          "server": "nginx",
          "date": "Sun, 19 Jan 2020 14:24:55 GMT",
          "content-type": "application/json;charset=UTF-8",
          "content-length": "867",
          "connection": "close",
          "x-ncp-trace-id": "36d31ckp3edpj38phnccqmcoph"
        },
        "type": "object",
        "data": {
          "x": "129.3112381",
          "y": "35.5396493"
        }
      },
      "time": 1579443896001
    }
  }
}

Data structure of the return value

const { headers, type, data } = await memoFetch(...);
  • headers : Headers of the response
  • type : Type of the return data ["string" | "object"]
  • data : Data

POST

(async () => {
  await setMaxMemo(10);
  await setExpirationTime(5000);
  const { data } = await memoFetch('https://postman-echo.com/post', {
    headers: {
      'Content-Type': 'application/json',
    },

    method: 'POST',
    body: { b: 4 },
  });

  console.log(data);
})();

APIs

memoFetch

import { memoFetch, setExpirationTime, setMaxMemo } from 'memofetch';

const main = async () => {
  await setMaxMemo(30);
  await setExpirationTime(5000);

  const { data } = await memoFetch(
    'https://postman-echo.com/get?foo1=bar1&foo2=bar2',
  );

  console.log(data);
};

Options

The second argument can be an option value.

import { memoFetch, setExpirationTime, setMaxMemo } from 'memofetch';

const main = async () => {
  const { data } = await memoFetch('url...', {
    headers: {
      id: 1,
    },
    filter: v => v,
    method: 'POST',
    body: { name: 'youngjae' },
    useMemo: true,
  });

  console.log(data);
};
  • agent : a Instance of http.Agent | boolean (Default : http.globalAgent)
  • headers : Headers of the request (Default : null)
  • method : HTTP request methods (Default : GET)
  • filter : Filter Function for Response Data (Default : v => v)
  • body : HTTP Message Body (Default : '')
  • useMemo : if useMemo is true, memoFetch works in memoization mode. (Default : true)

setConfigPath

Set the path where memo data will be saved.

  • Default : process.cwd()
import { setConfigPath } from 'memoFetch';

setConfigPath('./config/memo.json');

setExpirationTime

Set the expiration time for memo data.

  • Unit : ms
  • Default : 5000
import { setExpirationTime } from 'memoFetch';

setExpirationTime(3600 * 1000); // set to 1hr

setMaxMemo

When the size of the memo data becomes larger than the set value, everything is initialized.

  • Default : 10
import { setMaxMemo } from 'memoFetch';

setMaxMemo(50);