Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102313124
AwaitDependenciesInitFragment.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Feb 19, 09:58
Size
1 KB
Mime Type
text/x-c++
Expires
Fri, Feb 21, 09:58 (2 d)
Engine
blob
Format
Raw Data
Handle
24329009
Attached To
rOACCT Open Access Compliance Check Tool (OACCT)
AwaitDependenciesInitFragment.js
View Options
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict"
;
const
InitFragment
=
require
(
"../InitFragment"
);
const
RuntimeGlobals
=
require
(
"../RuntimeGlobals"
);
/** @typedef {import("webpack-sources").Source} Source */
/** @typedef {import("../Generator").GenerateContext} GenerateContext */
class
AwaitDependenciesInitFragment
extends
InitFragment
{
/**
* @param {Set<string>} promises the promises that should be awaited
*/
constructor
(
promises
)
{
super
(
undefined
,
InitFragment
.
STAGE_ASYNC_DEPENDENCIES
,
0
,
"await-dependencies"
);
this
.
promises
=
promises
;
}
merge
(
other
)
{
const
promises
=
new
Set
(
this
.
promises
);
for
(
const
p
of
other
.
promises
)
{
promises
.
add
(
p
);
}
return
new
AwaitDependenciesInitFragment
(
promises
);
}
/**
* @param {GenerateContext} generateContext context for generate
* @returns {string|Source} the source code that will be included as initialization code
*/
getContent
({
runtimeRequirements
})
{
runtimeRequirements
.
add
(
RuntimeGlobals
.
module
);
const
promises
=
this
.
promises
;
if
(
promises
.
size
===
0
)
{
return
""
;
}
if
(
promises
.
size
===
1
)
{
for
(
const
p
of
promises
)
{
return
`
$
{
p
}
=
await
Promise
.
resolve
(
$
{
p
});
\
n
`
;
}
}
const
sepPromises
=
Array
.
from
(
promises
).
join
(
", "
);
return
`
([
$
{
sepPromises
}]
=
await
Promise
.
all
([
$
{
sepPromises
}]));
\
n
`
;
}
}
module
.
exports
=
AwaitDependenciesInitFragment
;
Event Timeline
Log In to Comment