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:
Vse Mozhet Byt 2018-11-24 00:39:32 +02:00
parent 14707b681d
commit f2432a4761

View File

@ -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,