22
33const Buffer = require ( 'buffer' ) . Buffer ;
44const {
5- SafeSet,
5+ ArrayPrototype,
6+ FunctionPrototype,
67 Object,
78 ObjectPrototype,
8- FunctionPrototype,
9- ArrayPrototype
9+ SafeSet,
1010} = primordials ;
1111
1212const kSerializedError = 0 ;
1313const kSerializedObject = 1 ;
1414const kInspectedError = 2 ;
1515
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-
2616const errors = {
2717 Error, TypeError, RangeError, URIError, SyntaxError, ReferenceError, EvalError
2818} ;
@@ -32,17 +22,18 @@ function TryGetAllProperties(object, target = object) {
3222 const all = Object . create ( null ) ;
3323 if ( object === null )
3424 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 ) => {
3829 let descriptor ;
3930 try {
40- descriptor = GetOwnPropertyDescriptor ( object , key ) ;
31+ descriptor = Object . getOwnPropertyDescriptor ( object , key ) ;
4132 } catch { return ; }
4233 const getter = descriptor . get ;
4334 if ( getter && key !== '__proto__' ) {
4435 try {
45- descriptor . value = Call ( getter , target ) ;
36+ descriptor . value = FunctionPrototype . call ( getter , target ) ;
4637 } catch { }
4738 }
4839 if ( 'value' in descriptor && typeof descriptor . value !== 'function' ) {
@@ -59,10 +50,10 @@ function GetConstructors(object) {
5950
6051 for ( var current = object ;
6152 current !== null ;
62- current = GetPrototypeOf ( current ) ) {
63- const desc = GetOwnPropertyDescriptor ( current , 'constructor' ) ;
53+ current = Object . getPrototypeOf ( current ) ) {
54+ const desc = Object . getOwnPropertyDescriptor ( current , 'constructor' ) ;
6455 if ( desc && desc . value ) {
65- DefineProperty ( constructors , constructors . length , {
56+ Object . defineProperty ( constructors , constructors . length , {
6657 value : desc . value , enumerable : true
6758 } ) ;
6859 }
@@ -72,7 +63,7 @@ function GetConstructors(object) {
7263}
7364
7465function GetName ( object ) {
75- const desc = GetOwnPropertyDescriptor ( object , 'name' ) ;
66+ const desc = Object . getOwnPropertyDescriptor ( object , 'name' ) ;
7667 return desc && desc . value ;
7768}
7869
@@ -89,7 +80,7 @@ function serializeError(error) {
8980 if ( ! serialize ) serialize = require ( 'v8' ) . serialize ;
9081 try {
9182 if ( typeof error === 'object' &&
92- ObjectPrototypeToString ( error ) === '[object Error]' ) {
83+ ObjectPrototype . toString ( error ) === '[object Error]' ) {
9384 const constructors = GetConstructors ( error ) ;
9485 for ( var i = 0 ; i < constructors . length ; i ++ ) {
9586 const name = GetName ( constructors [ i ] ) ;
0 commit comments