Skip to content

Commit

Permalink
Consistency using requiredArguments method
Browse files Browse the repository at this point in the history
Replaced tuple length check in UrlSearchParams class with
requiredArguments method.
  • Loading branch information
Tomislav Fabeta committed Apr 21, 2019
1 parent 4526823 commit 60436e9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
2 changes: 1 addition & 1 deletion js/headers.ts
Expand Up @@ -57,7 +57,7 @@ class HeadersBase {
// If header does not contain exactly two items,
// then throw a TypeError.
// ref: https://fetch.spec.whatwg.org/#concept-headers-fill
requiredArguments("Headers.constructor tuple argument", tuple.length, 2);
requiredArguments("Headers.constructor tuple array argument", tuple.length, 2);

const [name, value] = this._normalizeParams(tuple[0], tuple[1]);
this._validateName(name);
Expand Down
6 changes: 1 addition & 5 deletions js/url_search_params.ts
Expand Up @@ -27,11 +27,7 @@ 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) {
Expand Down

0 comments on commit 60436e9

Please sign in to comment.