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';
|
'use strict';
|
||||||
|
|
||||||
const copyProps = (unsafe, safe) => {
|
const copyProps = (unsafe, safe) => {
|
||||||
for (const key of [...Object.getOwnPropertyNames(unsafe),
|
for (const key of Reflect.ownKeys(unsafe)) {
|
||||||
...Object.getOwnPropertySymbols(unsafe)
|
|
||||||
]) {
|
|
||||||
if (!Object.getOwnPropertyDescriptor(safe, key)) {
|
if (!Object.getOwnPropertyDescriptor(safe, key)) {
|
||||||
Object.defineProperty(
|
Object.defineProperty(
|
||||||
safe,
|
safe,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user