Public
Edited
May 1, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Uri = require("https://unpkg.com/urijs@1.19.11/src/URI.js")
Insert cell
function sumParamsUri(href) {
const uri = new Uri(href);
const queryObject = Uri.parseQuery(uri.search());
return +queryObject[1] + +queryObject[2] + +queryObject[3];
}
Insert cell
Insert cell
function sumParamsUrl(href) {
const url = new URL(href);
const queryObject = url.searchParams;
return +queryObject.get("1") + +queryObject.get("2") + +queryObject.get("3");
}
Insert cell
Insert cell
totalUsingUri = {
const t0 = performance.now();
const total = testurls
.map((url) => sumParamsUri(url))
.reduce((a, c) => a + c);
const runtime = performance.now() - t0;
return { runtime, total };
}
Insert cell
totalUsingUrl = {
const t0 = performance.now();
const total = testurls
.map((url) => sumParamsUrl(url))
.reduce((a, c) => a + c);
const runtime = performance.now() - t0;
return { runtime, total };
}
Insert cell
Insert cell
Insert cell
Insert cell
url = new URL("https://dummy.tileserver.com/tileset/{z}/{y}/{x}.mvt")
Insert cell
url.href
Insert cell
decodeURIComponent(url.href)
Insert cell
Insert cell
relativeURL = new URL(
"tileset/path/to/tile.gltf",
"https://example.com/tilesets/"
)
Insert cell
relativeURL.href
Insert cell
relativeUri = new Uri(
"/tileset/path/to/tile.gltf",
"https://www.example.com/tilesets/"
)
Insert cell
relativeUri.toString()
Insert cell
relativeUri2 = new Uri("./tileset/path/to/tile.gltf").absoluteTo(
"https://example.com/tilesets"
)
Insert cell
relativeUri2.toString()
Insert cell
blankUri = new Uri()
Insert cell
blankUri.toString()
Insert cell
location.href
Insert cell
example = new Uri("https://example.com").authority()
Insert cell
wwwExample = new Uri("https://www.example.com").authority()
Insert cell
Insert cell
Insert cell
search.get("notDefined")
Insert cell
{
const tileUri = new Uri("https://example.com/tileserver/{z}/{x}/{y}.json");
return tileUri.toString();
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more