mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 10:33:54 +00:00
runtime arg check URLSearchParams
(#1390)
This commit is contained in:
parent
9909e8a759
commit
7d0e1050d3
3 changed files with 73 additions and 3 deletions
14
js/util.ts
14
js/util.ts
|
@ -137,3 +137,17 @@ export function isTypedArray(x: unknown): x is TypedArray {
|
|||
export function isObject(o: unknown): o is object {
|
||||
return o != null && typeof o === "object";
|
||||
}
|
||||
|
||||
// @internal
|
||||
export function requiredArguments(
|
||||
name: string,
|
||||
length: number,
|
||||
required: number
|
||||
): void {
|
||||
if (length < required) {
|
||||
const errMsg = `${name} requires at least ${required} argument${
|
||||
required === 1 ? "" : "s"
|
||||
}, but only ${length} present`;
|
||||
throw new TypeError(errMsg);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue