JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 19
  • Score
    100M100P100Q60059F
  • License MIT

Resolves a callback only once and memoizes the result

Package Exports

  • resolve-once-cb
  • resolve-once-cb/package.json

Readme

resolve-once-cb

Resolves a promise only once and memoizes the result.

Usage

const { callbackify } = require('util');
const resolveOnce = require('resolve-once-cb');
const { MongoClient } = require('mongodb');

const connection = resolveOnce((cb) => callbackify(MongoClient.connect)('mongodb://localhost:27017/database', cb) );
connection((err, db1) => { })
connection((err, db2) => { })
// db1 === db2