@pdftron/webviewer-react-toolkit
Version:
A React component library for integrating with PDFTron WebViewer API.
20 lines (19 loc) • 756 B
JavaScript
/**
* Returns a futurable from a futurable or a lazy futurable. If lazy, will call
* to convert to futurable. Use this at evaluation time only, as any lazy
* futurables will be called at this point.
* @param futurableOrLazy A `Futurable` or a `LazyFuturable`.
*/
export function futureableOrLazyToFuturable(futurableOrLazy) {
return futurableOrLazy instanceof Function ? futurableOrLazy() : futurableOrLazy;
}
/**
* If the MemoizedPromise is done, will turn into Promise, otherwise will turn
* into lazy Promise
* @param memoizedPromise The memoized promise to convert.
*/
export function memoizedPromiseToFuturableOrLazy(memoizedPromise) {
if (memoizedPromise.done)
return memoizedPromise.get();
return memoizedPromise.get;
}