@webileapps/async-memoizer
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

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

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.1.00latest

Version History

VersionDownloads (Last 7 Days)Published
0.1.00

Package Sidebar

Install

npm i @webileapps/async-memoizer

Weekly Downloads

0

Version

0.1.0

License

ISC

Unpacked Size

5.54 kB

Total Files

4

Last publish

Collaborators

  • rajivnarayana
  • rajivsingaseni
  • durgaprasanna