summaryrefslogtreecommitdiff
path: root/runtime/js/11_workers.js
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2021-07-03 16:58:08 +0200
committerGitHub <noreply@github.com>2021-07-03 16:58:08 +0200
commit6137c8046d2d1bf4145a72aa634270c7aaf23341 (patch)
tree85428d5bb447b7e17323b4d6187e7b4124d17d68 /runtime/js/11_workers.js
parentd4de477ef903e2e47c6427e14f0fe543106b1297 (diff)
refactor: use primordials in runtime/, part1 (#11241)
Diffstat (limited to 'runtime/js/11_workers.js')
-rw-r--r--runtime/js/11_workers.js23
1 files changed, 17 insertions, 6 deletions
diff --git a/runtime/js/11_workers.js b/runtime/js/11_workers.js
index 7267bec38..602046a14 100644
--- a/runtime/js/11_workers.js
+++ b/runtime/js/11_workers.js
@@ -3,7 +3,17 @@
((window) => {
const core = window.Deno.core;
+ const {
+ ArrayIsArray,
+ ArrayPrototypeMap,
+ Error,
+ Uint8Array,
+ StringPrototypeStartsWith,
+ String,
+ SymbolIterator,
+ } = window.__bootstrap.primordials;
const webidl = window.__bootstrap.webidl;
+ const { URL } = window.__bootstrap.url;
const { Window } = window.__bootstrap.globalInterfaces;
const { getLocationHref } = window.__bootstrap.location;
const { log, pathFromURL } = window.__bootstrap.util;
@@ -75,13 +85,13 @@
`Expected 'array' or 'boolean' for ${permission} permission, "${value}" received`,
);
}
- } else if (!Array.isArray(value) && typeof value !== "boolean") {
+ } else if (!ArrayIsArray(value) && typeof value !== "boolean") {
throw new Error(
`Expected 'array' or 'boolean' for ${permission} permission, ${typeof value} received`,
);
//Casts URLs to absolute routes
- } else if (Array.isArray(value)) {
- value = value.map((route) => {
+ } else if (ArrayIsArray(value)) {
+ value = ArrayPrototypeMap(value, (route) => {
if (route instanceof URL) {
route = pathFromURL(route);
}
@@ -174,8 +184,9 @@
const sourceCode = core.decode(new Uint8Array());
if (
- specifier.startsWith("./") || specifier.startsWith("../") ||
- specifier.startsWith("/") || type == "classic"
+ StringPrototypeStartsWith(specifier, "./") ||
+ StringPrototypeStartsWith(specifier, "../") ||
+ StringPrototypeStartsWith(specifier, "/") || type == "classic"
) {
const baseUrl = getLocationHref();
if (baseUrl != null) {
@@ -289,7 +300,7 @@
if (
webidl.type(transferOrOptions) === "Object" &&
transferOrOptions !== undefined &&
- transferOrOptions[Symbol.iterator] !== undefined
+ transferOrOptions[SymbolIterator] !== undefined
) {
const transfer = webidl.converters["sequence<object>"](
transferOrOptions,