diff --git a/HISTORY.md b/HISTORY.md index 3fceb4f8..f1860a7d 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -2,6 +2,7 @@ unreleased ========== * deps: qs@6.11.0 + * perf: remove unnecessary object clone 1.20.0 / 2022-04-02 =================== diff --git a/index.js b/index.js index 93c3a1ff..bb24d739 100644 --- a/index.js +++ b/index.js @@ -91,16 +91,15 @@ Object.defineProperty(exports, 'urlencoded', { */ function bodyParser (options) { - var opts = {} - - // exclude type option - if (options) { - for (var prop in options) { - if (prop !== 'type') { - opts[prop] = options[prop] - } + // use default type for parsers + var opts = Object.create(options || null, { + type: { + configurable: true, + enumerable: true, + value: undefined, + writable: true } - } + }) var _urlencoded = exports.urlencoded(opts) var _json = exports.json(opts)