Skip to content

Commit

Permalink
lib: simplify own keys retrieval
Browse files Browse the repository at this point in the history
This replacement can save us a function call, two array spreadings,
and an array concatenation.

PR-URL: #24582
Refs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/ownKeys#Description
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
vsemozhetbyt authored and BethGriggs committed Feb 11, 2019
1 parent 9daf175 commit ce2aa80
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions lib/internal/safe_globals.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down

0 comments on commit ce2aa80

Please sign in to comment.