From c3ef5a541cf5c19184347c4e32f683aa060d5953 Mon Sep 17 00:00:00 2001 From: orakili Date: Fri, 1 Apr 2022 12:17:28 +0900 Subject: [PATCH] fix: prevent adding keys with undefined values to the yar object in lazy mode --- lib/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 72ffbb7..38f3b08 100755 --- a/lib/index.js +++ b/lib/index.js @@ -149,8 +149,10 @@ internals.Yar = class { if (this._store._lazyKeys) { this._isLazy = true; // Default to lazy mode if previously set for (const key of this._store._lazyKeys) { - this[key] = this._store[key]; - delete this._store[key]; + if (key in this._store) { + this[key] = this._store[key]; + delete this._store[key]; + } } } }