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 <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
14707b681d
commit
f2432a4761
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user