UNPKG

3.36 kBTypeScriptView Raw
1import { URLSearchParams } from "../index";
2import { implementation as URLSearchParamsImpl } from "./URLSearchParams-impl";
3
4/**
5 * Checks whether `obj` is a `URLSearchParams` object with an implementation
6 * provided by this package.
7 */
8export function is(obj: unknown): obj is URLSearchParams;
9
10/**
11 * Checks whether `obj` is a `URLSearchParamsImpl` WebIDL2JS implementation object
12 * provided by this package.
13 */
14export function isImpl(obj: unknown): obj is URLSearchParamsImpl;
15
16/**
17 * Converts the `URLSearchParams` wrapper into a `URLSearchParamsImpl` object.
18 *
19 * @throws {TypeError} If `obj` is not a `URLSearchParams` wrapper instance provided by this package.
20 */
21export function convert(globalObject: object, obj: unknown, { context }?: { context: string }): URLSearchParamsImpl;
22
23export function createDefaultIterator<TIteratorKind extends "key" | "value" | "key+value">(
24 globalObject: object,
25 target: URLSearchParamsImpl,
26 kind: TIteratorKind,
27): IterableIterator<TIteratorKind extends "key" | "value" ? string : [name: string, value: string]>;
28
29/**
30 * Creates a new `URLSearchParams` instance.
31 *
32 * @throws {Error} If the `globalObject` doesn't have a WebIDL2JS constructor
33 * registry or a `URLSearchParams` constructor provided by this package
34 * in the WebIDL2JS constructor registry.
35 */
36export function create(
37 globalObject: object,
38 constructorArgs?: readonly [
39 init: ReadonlyArray<[name: string, value: string]> | { readonly [name: string]: string } | string,
40 ],
41 privateData?: { doNotStripQMark?: boolean | undefined },
42): URLSearchParams;
43
44/**
45 * Calls `create()` and returns the internal `URLSearchParamsImpl`.
46 *
47 * @throws {Error} If the `globalObject` doesn't have a WebIDL2JS constructor
48 * registry or a `URLSearchParams` constructor provided by this package
49 * in the WebIDL2JS constructor registry.
50 */
51export function createImpl(
52 globalObject: object,
53 constructorArgs?: readonly [
54 init: ReadonlyArray<[name: string, value: string]> | { readonly [name: string]: string } | string,
55 ],
56 privateData?: { doNotStripQMark?: boolean | undefined },
57): URLSearchParamsImpl;
58
59/**
60 * Initializes the `URLSearchParams` instance, called by `create()`.
61 *
62 * Useful when manually sub-classing a non-constructable wrapper object.
63 */
64export function setup<T extends URLSearchParams>(
65 obj: T,
66 globalObject: object,
67 constructorArgs?: readonly [
68 init: ReadonlyArray<[name: string, value: string]> | { readonly [name: string]: string } | string,
69 ],
70 privateData?: { doNotStripQMark?: boolean | undefined },
71): T;
72
73/**
74 * Creates a new `URLSearchParams` object without runing the constructor steps.
75 *
76 * Useful when implementing specifications that initialize objects
77 * in different ways than their constructors do.
78 */
79declare function _new(
80 globalObject: object,
81 newTarget?: new(
82 init: ReadonlyArray<[name: string, value: string]> | { readonly [name: string]: string } | string,
83 ) => URLSearchParams,
84): URLSearchParamsImpl;
85export { _new as new };
86
87/**
88 * Installs the `URLSearchParams` constructor onto the `globalObject`.
89 *
90 * @throws {Error} If the target `globalObject` doesn't have an `Error` constructor.
91 */
92export function install(globalObject: object, globalNames: readonly string[]): void;