2
2
3
3
const Buffer = require ( 'buffer' ) . Buffer ;
4
4
const {
5
- SafeSet,
5
+ ArrayPrototype,
6
+ FunctionPrototype,
6
7
Object,
7
8
ObjectPrototype,
8
- FunctionPrototype,
9
- ArrayPrototype
9
+ SafeSet,
10
10
} = primordials ;
11
11
12
12
const kSerializedError = 0 ;
13
13
const kSerializedObject = 1 ;
14
14
const kInspectedError = 2 ;
15
15
16
- const GetPrototypeOf = Object . getPrototypeOf ;
17
- const GetOwnPropertyDescriptor = Object . getOwnPropertyDescriptor ;
18
- const GetOwnPropertyNames = Object . getOwnPropertyNames ;
19
- const DefineProperty = Object . defineProperty ;
20
- const Assign = Object . assign ;
21
- const ObjectPrototypeToString =
22
- FunctionPrototype . call . bind ( ObjectPrototype . toString ) ;
23
- const ForEach = FunctionPrototype . call . bind ( ArrayPrototype . forEach ) ;
24
- const Call = FunctionPrototype . call . bind ( FunctionPrototype . call ) ;
25
-
26
16
const errors = {
27
17
Error, TypeError, RangeError, URIError, SyntaxError, ReferenceError, EvalError
28
18
} ;
@@ -32,17 +22,18 @@ function TryGetAllProperties(object, target = object) {
32
22
const all = Object . create ( null ) ;
33
23
if ( object === null )
34
24
return all ;
35
- Assign ( all , TryGetAllProperties ( GetPrototypeOf ( object ) , target ) ) ;
36
- const keys = GetOwnPropertyNames ( object ) ;
37
- ForEach ( keys , ( key ) => {
25
+ Object . assign ( all ,
26
+ TryGetAllProperties ( Object . getPrototypeOf ( object ) , target ) ) ;
27
+ const keys = Object . getOwnPropertyNames ( object ) ;
28
+ ArrayPrototype . forEach ( keys , ( key ) => {
38
29
let descriptor ;
39
30
try {
40
- descriptor = GetOwnPropertyDescriptor ( object , key ) ;
31
+ descriptor = Object . getOwnPropertyDescriptor ( object , key ) ;
41
32
} catch { return ; }
42
33
const getter = descriptor . get ;
43
34
if ( getter && key !== '__proto__' ) {
44
35
try {
45
- descriptor . value = Call ( getter , target ) ;
36
+ descriptor . value = FunctionPrototype . call ( getter , target ) ;
46
37
} catch { }
47
38
}
48
39
if ( 'value' in descriptor && typeof descriptor . value !== 'function' ) {
@@ -59,10 +50,10 @@ function GetConstructors(object) {
59
50
60
51
for ( var current = object ;
61
52
current !== null ;
62
- current = GetPrototypeOf ( current ) ) {
63
- const desc = GetOwnPropertyDescriptor ( current , 'constructor' ) ;
53
+ current = Object . getPrototypeOf ( current ) ) {
54
+ const desc = Object . getOwnPropertyDescriptor ( current , 'constructor' ) ;
64
55
if ( desc && desc . value ) {
65
- DefineProperty ( constructors , constructors . length , {
56
+ Object . defineProperty ( constructors , constructors . length , {
66
57
value : desc . value , enumerable : true
67
58
} ) ;
68
59
}
@@ -72,7 +63,7 @@ function GetConstructors(object) {
72
63
}
73
64
74
65
function GetName ( object ) {
75
- const desc = GetOwnPropertyDescriptor ( object , 'name' ) ;
66
+ const desc = Object . getOwnPropertyDescriptor ( object , 'name' ) ;
76
67
return desc && desc . value ;
77
68
}
78
69
@@ -89,7 +80,7 @@ function serializeError(error) {
89
80
if ( ! serialize ) serialize = require ( 'v8' ) . serialize ;
90
81
try {
91
82
if ( typeof error === 'object' &&
92
- ObjectPrototypeToString ( error ) === '[object Error]' ) {
83
+ ObjectPrototype . toString ( error ) === '[object Error]' ) {
93
84
const constructors = GetConstructors ( error ) ;
94
85
for ( var i = 0 ; i < constructors . length ; i ++ ) {
95
86
const name = GetName ( constructors [ i ] ) ;
0 commit comments