Initial commit
This commit is contained in:
commit
78f8d225ee
21173 changed files with 2907774 additions and 0 deletions
28
node_modules/next/dist/esm/server/lib/lazy-result.js
generated
vendored
Normal file
28
node_modules/next/dist/esm/server/lib/lazy-result.js
generated
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* Calls the given async function only when the returned promise-like object is
|
||||
* awaited. Afterwards, it provides the resolved value synchronously as `value`
|
||||
* property.
|
||||
*/ export function createLazyResult(fn) {
|
||||
let pendingResult;
|
||||
const result = {
|
||||
then (onfulfilled, onrejected) {
|
||||
if (!pendingResult) {
|
||||
pendingResult = fn();
|
||||
}
|
||||
pendingResult.then((value)=>{
|
||||
result.value = value;
|
||||
}).catch(()=>{
|
||||
// The externally awaited result will be rejected via `onrejected`. We
|
||||
// don't need to handle it here. But we do want to avoid an unhandled
|
||||
// rejection.
|
||||
});
|
||||
return pendingResult.then(onfulfilled, onrejected);
|
||||
}
|
||||
};
|
||||
return result;
|
||||
}
|
||||
export function isResolvedLazyResult(result) {
|
||||
return result.hasOwnProperty('value');
|
||||
}
|
||||
|
||||
//# sourceMappingURL=lazy-result.js.map
|
||||
Loading…
Add table
Add a link
Reference in a new issue