mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 19:08:15 +00:00
refactor: use primordials in runtime/, part1 (#11241)
This commit is contained in:
parent
d4de477ef9
commit
6137c8046d
8 changed files with 82 additions and 31 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue