UNPKG

@worker-tools/json-fetch

Version:

A drop-in replacements for fetch, Request, and Response with first class support for JSON objects.

22 lines 881 B
// This could be it's own module... /** * Like `URL`, but accepts a `params` argument that is added to the search parameters/query string. */ export class SearchParamsURL extends URL { constructor(url, params, base) { super(url, base); const iterable = Array.isArray(params) || params instanceof URLSearchParams ? params : typeof params === 'string' ? new URLSearchParams(params) : Object.entries(params !== null && params !== void 0 ? params : {}); for (const [k, v] of iterable) this.searchParams.append(k, '' + v); } } export { SearchParamsURL as SearchURL, SearchParamsURL as ParamsURL, }; /** @deprecated Use SearchParamsURL instead */ export const urlWithParams = (...args) => { return new SearchParamsURL(...args).href; }; //# sourceMappingURL=search-params-url.js.map