Skip to content

Commit f199e94

Browse files
committed
perf: remove unnecessary object clone
1 parent 0123e12 commit f199e94

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

HISTORY.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ unreleased
22
==========
33

44
5+
* perf: remove unnecessary object clone
56

67
1.20.0 / 2022-04-02
78
===================

index.js

+8-9
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,15 @@ Object.defineProperty(exports, 'urlencoded', {
9191
*/
9292

9393
function bodyParser (options) {
94-
var opts = {}
95-
96-
// exclude type option
97-
if (options) {
98-
for (var prop in options) {
99-
if (prop !== 'type') {
100-
opts[prop] = options[prop]
101-
}
94+
// use default type for parsers
95+
var opts = Object.create(options || null, {
96+
type: {
97+
configurable: true,
98+
enumerable: true,
99+
value: undefined,
100+
writable: true
102101
}
103-
}
102+
})
104103

105104
var _urlencoded = exports.urlencoded(opts)
106105
var _json = exports.json(opts)

0 commit comments

Comments
 (0)