JSPM

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

Resolves a callback only once and memoizes the result

Package Exports

  • resolve-once-cb
  • resolve-once-cb/dist/cjs/index.cjs

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (resolve-once-cb) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

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