MCPcopy Create free account
hub / github.com/nodejs/node / getMethod

Function getMethod

benchmark/url/url-searchparams-update.js:11–16  ·  view source on GitHub ↗
(url, property)

Source from the content-addressed store, hash-verified

9});
10
11function getMethod(url, property) {
12 if (property === 'pathname') return (x) => url.pathname = `/${x}`;
13 if (property === 'search') return (x) => url.search = `?${x}`;
14 if (property === 'hash') return (x) => url.hash = `#${x}`;
15 throw new Error(`Unsupported property "${property}"`);
16}
17
18function main({ searchParams, property, n }) {
19 const url = new URL('https://nodejs.org');

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected