diff options
author | Tomislav Fabeta <tomislav.fabeta@gmail.com> | 2019-04-21 20:40:15 +0100 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-04-21 15:40:15 -0400 |
commit | 6cded14bdf313762956d4d5361cfe8115628b535 (patch) | |
tree | 1daf3a7d86415827242196cbec42efb2c907dca7 /js | |
parent | f77b112797ffd686958928818a1b6acfdda197fe (diff) |
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
Diffstat (limited to 'js')
-rw-r--r-- | js/headers.ts | 10 | ||||
-rw-r--r-- | js/url_search_params.ts | 10 |
2 files changed, 10 insertions, 10 deletions
diff --git a/js/headers.ts b/js/headers.ts index 2f15f14da..e31c0903e 100644 --- a/js/headers.ts +++ b/js/headers.ts @@ -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); diff --git a/js/url_search_params.ts b/js/url_search_params.ts index ac4ac01b1..aef2f2c50 100644 --- a/js/url_search_params.ts +++ b/js/url_search_params.ts @@ -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) { |