From f2432a47616979780e7ca76a935e5f05c4ee31b5 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 ad58fa662b5..31de4137f0a 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,