From ce2aa807f5a4894a07ddf65b930286aa7e21b42f Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Sat, 24 Nov 2018 00:39:32 +0200 Subject: [PATCH] lib: simplify own keys retrieval This replacement can save us a function call, two array spreadings, and an array concatenation. PR-URL: https://github.com/nodejs/node/pull/24582 Refs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/ownKeys#Description Reviewed-By: Anna Henningsen Reviewed-By: Gus Caplan Reviewed-By: Colin Ihrig --- lib/internal/safe_globals.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/internal/safe_globals.js b/lib/internal/safe_globals.js index ad58fa662b53ef..31de4137f0ad53 100644 --- a/lib/internal/safe_globals.js +++ b/lib/internal/safe_globals.js @@ -1,9 +1,7 @@ 'use strict'; const copyProps = (unsafe, safe) => { - for (const key of [...Object.getOwnPropertyNames(unsafe), - ...Object.getOwnPropertySymbols(unsafe) - ]) { + for (const key of Reflect.ownKeys(unsafe)) { if (!Object.getOwnPropertyDescriptor(safe, key)) { Object.defineProperty( safe,