UNPKG

2.24 kBTypeScriptView Raw
1import { URL } from "../index";
2import { implementation as URLImpl } from "./URL-impl";
3
4/**
5 * Checks whether `obj` is a `URL` object with an implementation
6 * provided by this package.
7 */
8export function is(obj: unknown): obj is URL;
9
10/**
11 * Checks whether `obj` is a `URLImpl` WebIDL2JS implementation object
12 * provided by this package.
13 */
14export function isImpl(obj: unknown): obj is URLImpl;
15
16/**
17 * Converts the `URL` wrapper into a `URLImpl` object.
18 *
19 * @throws {TypeError} If `obj` is not a `URL` wrapper instance provided by this package.
20 */
21export function convert(globalObject: object, obj: unknown, { context }?: { context: string }): URLImpl;
22
23/**
24 * Creates a new `URL` instance.
25 *
26 * @throws {Error} If the `globalObject` doesn't have a WebIDL2JS constructor
27 * registry or a `URL` constructor provided by this package
28 * in the WebIDL2JS constructor registry.
29 */
30export function create(globalObject: object, constructorArgs: readonly [url: string, base?: string]): URL;
31
32/**
33 * Calls `create()` and returns the internal `URLImpl`.
34 *
35 * @throws {Error} If the `globalObject` doesn't have a WebIDL2JS constructor
36 * registry or a `URL` constructor provided by this package
37 * in the WebIDL2JS constructor registry.
38 */
39export function createImpl(globalObject: object, constructorArgs: readonly [url: string, base?: string]): URLImpl;
40
41/**
42 * Initializes the `URL` instance, called by `create()`.
43 *
44 * Useful when manually sub-classing a non-constructable wrapper object.
45 */
46export function setup<T extends URL>(
47 obj: T,
48 globalObject: object,
49 constructorArgs: readonly [url: string, base?: string],
50): T;
51
52/**
53 * Creates a new `URL` object without runing the constructor steps.
54 *
55 * Useful when implementing specifications that initialize objects
56 * in different ways than their constructors do.
57 */
58declare function _new(globalObject: object, newTarget?: new(url: string, base?: string) => URL): URLImpl;
59export { _new as new };
60
61/**
62 * Installs the `URL` constructor onto the `globalObject`.
63 *
64 * @throws {Error} If the target `globalObject` doesn't have an `Error` constructor.
65 */
66export function install(globalObject: object, globalNames: readonly string[]): void;