We can search across existing code to both find examples of places where this proposal could have potentially helped, and also gauge how common it is.
If code is passing in a literal array to Promise.all this can be a good sign (low false positives) that the code is waiting for a static set of promises, as opposed to a variables length array of homogenous results.
Here's a SourceGraph query for [...] = await Promise.all([...]): https://sourcegraph.com/search?q=context:global+%28lang:JavaScript+or+lang:TypeScript%29++-file:test+-file:node_modules+%5B...%5D+%3D+await+Promise.all%28%5B...%5D%29&patternType=structural&sm=1&groupBy=repo
Some selected examples from the results:
https://github.com/mozilla/pdf.js/blob/ccb72073b0bef9e9809e3230c3cede34f41dc757/web/pdf_document_properties.js#L122-L138
// existing:
const [
fileName,
fileSize,
creationDate,
modificationDate,
pageSize,
isLinearized,
] = await Promise.all([
this._fileNameLookup(),
this.#parseFileSize(contentLength),
this.#parseDate(info.CreationDate),
this.#parseDate(info.ModDate),
this.pdfDocument.getPage(currentPageNumber).then(pdfPage => {
return this.#parsePageSize(getPageSizeInches(pdfPage), pagesRotation);
}),
this.#parseLinearization(info.IsLinearized),
]);
// potentially with proposal:
const {
fileName,
fileSize,
creationDate,
modificationDate,
pageSize,
isLinearized,
} = await Promise.all({
fileName : this._fileNameLookup(),
fileSize: this.#parseFileSize(contentLength),
creationDate: this.#parseDate(info.CreationDate),
modificationDate: this.#parseDate(info.ModDate),
pageSize: this.pdfDocument.getPage(currentPageNumber).then(pdfPage => {
return this.#parsePageSize(getPageSizeInches(pdfPage), pagesRotation);
}),
isLinearized: this.#parseLinearization(info.IsLinearized),
});
https://github.com/jupyterlab/jupyterlab/blob/ef485f16c67e6d1f2e83334d6813f94d626c39e5/packages/terminal/src/widget.ts#L604-L611
// current
const [xterm_, fitAddon_, renderer_, weblinksAddon_] = await Promise.all([
import('xterm'),
import('xterm-addon-fit'),
supportWebGL
? import('xterm-addon-webgl')
: import('xterm-addon-canvas'),
import('xterm-addon-web-links')
]);
// potentially with proposal:
const {xterm_, fitAddon_, renderer_, weblinksAddon_} = await Promise.all({
xterm_ : import('xterm'),
fitAddon_: import('xterm-addon-fit'),
renderer_: supportWebGL
? import('xterm-addon-webgl')
: import('xterm-addon-canvas'),
weblinksAddon_: import('xterm-addon-web-links')
});
https://github.com/NodeBB/NodeBB/blob/8744e4121eca1d2fc30226e05418c0f3e90a5522/src/groups/index.js#L123-L132
// current:
const [groupData, members, pending, invited, isMember, isPending, isInvited, isOwner] = await Promise.all([
Groups.getGroupData(groupName),
Groups.getOwnersAndMembers(groupName, options.uid, 0, stop),
Groups.getPending(groupName),
Groups.getInvites(groupName),
Groups.isMember(options.uid, groupName),
Groups.isPending(options.uid, groupName),
Groups.isInvited(options.uid, groupName),
Groups.ownership.isOwner(options.uid, groupName),
]);
// potentially with proposal:
const {groupData, members, pending, invited, isMember, isPending, isInvited, isOwner} = await Promise.all({
groupData: Groups.getGroupData(groupName),
members: Groups.getOwnersAndMembers(groupName, options.uid, 0, stop),
pending: Groups.getPending(groupName),
invited: Groups.getInvites(groupName),
isMember: Groups.isMember(options.uid, groupName),
isPending: Groups.isPending(options.uid, groupName),
isInvited: Groups.isInvited(options.uid, groupName),
isOwner: Groups.ownership.isOwner(options.uid, groupName),
});
We can search across existing code to both find examples of places where this proposal could have potentially helped, and also gauge how common it is.
If code is passing in a literal array to
Promise.allthis can be a good sign (low false positives) that the code is waiting for a static set of promises, as opposed to a variables length array of homogenous results.Here's a SourceGraph query for
[...] = await Promise.all([...]): https://sourcegraph.com/search?q=context:global+%28lang:JavaScript+or+lang:TypeScript%29++-file:test+-file:node_modules+%5B...%5D+%3D+await+Promise.all%28%5B...%5D%29&patternType=structural&sm=1&groupBy=repoSome selected examples from the results:
https://github.com/mozilla/pdf.js/blob/ccb72073b0bef9e9809e3230c3cede34f41dc757/web/pdf_document_properties.js#L122-L138
https://github.com/jupyterlab/jupyterlab/blob/ef485f16c67e6d1f2e83334d6813f94d626c39e5/packages/terminal/src/widget.ts#L604-L611
https://github.com/NodeBB/NodeBB/blob/8744e4121eca1d2fc30226e05418c0f3e90a5522/src/groups/index.js#L123-L132