Skip to content

Commit

Permalink
Use object with null prototype for settings
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanHahn committed Apr 28, 2024
1 parent cd7d79f commit 790d083
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ var setPrototypeOf = require('setprototypeof')
* @private
*/

var hasOwnProperty = Object.prototype.hasOwnProperty
var slice = Array.prototype.slice;

/**
Expand Down Expand Up @@ -63,7 +62,7 @@ app.init = function init() {

this.cache = {};
this.engines = {};
this.settings = {};
this.settings = Object.create(null);

this.defaultConfiguration();

Expand Down Expand Up @@ -353,17 +352,7 @@ app.param = function param(name, fn) {
app.set = function set(setting, val) {
if (arguments.length === 1) {
// app.get(setting)
var settings = this.settings

while (settings && settings !== Object.prototype) {
if (hasOwnProperty.call(settings, setting)) {
return settings[setting]
}

settings = Object.getPrototypeOf(settings)
}

return undefined
return this.settings[setting];
}

debug('set "%s" to %o', setting, val);
Expand Down

0 comments on commit 790d083

Please sign in to comment.