0.5.2 • Published 2 years ago

resolve-once-map v0.5.2

Weekly downloads
2
License
MIT
Repository
github
Last release
2 years ago

resolve-once-map

Resolves a promise only once and memoizes the result in a map.

Usage

const resolveOnceMap = require('resolve-once-map');
const { MongoClient } = require('mongodb');

const connection = resolveOnceMap((url) => MongoClient.connect(url));
const db1 = await connection('mongodb://localhost:27017/database');
const db2 = await connection('mongodb://localhost:27017/database');
// db1 === db2

const db3 = await connection('mongodb://localhost:27017/database2');
// db1 !== db3
0.5.2

2 years ago

0.5.1

2 years ago

0.5.0

4 years ago

0.4.0

4 years ago

0.3.0

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago