From 53e76225a5c03d6692fd1e75d90c90f0ea825af7 Mon Sep 17 00:00:00 2001 From: Tino Vyatkin Date: Sun, 13 Oct 2019 09:31:32 -0400 Subject: [PATCH] use rest params --- lib/request.js | 9 ++++----- lib/response.js | 10 ++++------ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/lib/request.js b/lib/request.js index 3a5e92db5..b49d6404c 100644 --- a/lib/request.js +++ b/lib/request.js @@ -622,15 +622,14 @@ module.exports = { * * this.is('html'); // => false * - * @param {String|Array} types... + * @param {String|String[]} [type] + * @param {String[]} [types] * @return {String|false|null} * @api public */ - is(types) { - if (!types) return typeis(this.req); - if (!Array.isArray(types)) types = [].slice.call(arguments); - return typeis(this.req, types); + is(type, ...types) { + return typeis(this.req, type, ...types); }, /** diff --git a/lib/response.js b/lib/response.js index 6d1d11e76..b8477c24a 100644 --- a/lib/response.js +++ b/lib/response.js @@ -389,16 +389,14 @@ module.exports = { * Check whether the response is one of the listed types. * Pretty much the same as `this.request.is()`. * - * @param {String|Array} types... + * @param {String|String[]} [type] + * @param {String[]} [types] * @return {String|false} * @api public */ - is(types) { - const type = this.type; - if (!types) return type || false; - if (!Array.isArray(types)) types = [].slice.call(arguments); - return typeis(type, types); + is(type, ...types) { + return typeis(this.type, type, ...types); }, /**