$ cnpm install promise-share
Creates a getter function for a promise result
Helps to avoid UnhandledPromiseRejectionWarning. If you need to export a result as a promise, use this function to wrap the promise. When you'll need the result of the promise, run the function.
<pnpm|yarn|npm> add promise-share
'use strict'
const promiseShare = require('promise-share')
const file = promiseShare(readFileAsync())
console.log(await file())
//> file content
Copyright 2013 - present © cnpmjs.org | Home |