🚀 Socket Launch Week Day 4:Socket MCP Adds Org Alerts, Threat Feed Review, and Package Inspection.Learn more
Sign In

@webileapps/async-memoizer

Package Overview
Dependencies
Maintainers
3
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@webileapps/async-memoizer

A memoizer for asynchronous functions that memoizes the results of the resolved promise for future use.

latest
npmnpm
Version
0.1.0
Version published
Weekly downloads
2
-66.67%
Maintainers
3
Weekly downloads
 
Created
Source

Introduction

This is a memoizer for asynchronous functions that return a promise.

Usage


import asyncMemoizer from "@webileapps/async-memoizer";

async function getUserFromSomewhere(id: string) {
    return Promise.resolve({ id, name: "John" });
}

const function memoizedGetUserFromSomewhere = asyncMemoizer(getUserFromSomewhere);

const [ result1, result2 ] = await Promise.all([memoizedGetUserFromSomewhere("1"), memoizedGetUserFromSomewhere("2")]);

const [ result3, result4 ] = await Promise.all([memoizedGetUserFromSomewhere("1"), memoizedGetUserFromSomewhere("2")]);

// In the above case, the second calls to getUserFromSomewhere will be skipped as the results are memoized

Keywords

memoizer

FAQs

Package last updated on 02 Jul 2022

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