mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 15:24:46 -05:00
Issue/2170 (#2175)
* Consistency using requiredArguments method Replaced tuple length check in Headers class with requiredArguments method. * Consistency using requiredArguments method Replaced tuple length check in UrlSearchParams class with requiredArguments method. * fmt
This commit is contained in:
parent
f77b112797
commit
6cded14bdf
2 changed files with 10 additions and 10 deletions
|
@ -57,11 +57,11 @@ class HeadersBase {
|
|||
// If header does not contain exactly two items,
|
||||
// then throw a TypeError.
|
||||
// ref: https://fetch.spec.whatwg.org/#concept-headers-fill
|
||||
if (tuple.length !== 2) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'Headers'; Each header pair must be an iterable [name, value] tuple"
|
||||
);
|
||||
}
|
||||
requiredArguments(
|
||||
"Headers.constructor tuple array argument",
|
||||
tuple.length,
|
||||
2
|
||||
);
|
||||
|
||||
const [name, value] = this._normalizeParams(tuple[0], tuple[1]);
|
||||
this._validateName(name);
|
||||
|
|
|
@ -27,11 +27,11 @@ export class URLSearchParams {
|
|||
// Overload: sequence<sequence<USVString>>
|
||||
for (const tuple of init) {
|
||||
// If pair does not contain exactly two items, then throw a TypeError.
|
||||
if (tuple.length !== 2) {
|
||||
const errMsg =
|
||||
"Each query pair must be an iterable [name, value] tuple";
|
||||
throw new TypeError(errMsg);
|
||||
}
|
||||
requiredArguments(
|
||||
"URLSearchParams.constructor tuple array argument",
|
||||
tuple.length,
|
||||
2
|
||||
);
|
||||
this.append(tuple[0], tuple[1]);
|
||||
}
|
||||
} else if (Object(init) === init) {
|
||||
|
|
Loading…
Reference in a new issue