Skip to content

Commit 332a22d

Browse files
committed
fixup! module: allow module.register from workers
1 parent a33afea commit 332a22d

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

lib/internal/modules/esm/hooks.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const {
55
ArrayPrototypeMap,
66
ArrayPrototypePush,
77
ArrayPrototypePushApply,
8-
ArrayPrototypeReduce,
8+
ArrayPrototypeSome,
99
AtomicsLoad,
1010
AtomicsWait,
1111
AtomicsWaitAsync,
@@ -167,13 +167,11 @@ class Hooks {
167167
* @returns {any | Promise<any>} User data, ignored unless it's a promise, in which case it will be awaited.
168168
*/
169169
addCustomLoader(url, exports, data) {
170-
const alreadyKnown = ArrayPrototypeReduce(
171-
ArrayPrototypeMap(['initialize', 'resolve', 'load'], (hookName) => {
172-
if (this.#chains[hookName]) {
173-
const res2 = ArrayPrototypeFilter(this.#chains[hookName], (el) => el.url === url);
174-
return res2.length;
175-
}
176-
}), (acc, val) => acc || (val === 1), false);
170+
const alreadyKnown = ArrayPrototypeSome(ArrayPrototypeMap(['initialize', 'resolve', 'load'], (hookName) => {
171+
if (this.#chains[hookName]) {
172+
return ArrayPrototypeFilter(this.#chains[hookName], (el) => el.url === url).length === 1;
173+
}
174+
}), (el) => el);
177175

178176
if (alreadyKnown) {
179177
return undefined;

0 commit comments

Comments
 (0)