File tree Expand file tree Collapse file tree 1 file changed +2
-11
lines changed Expand file tree Collapse file tree 1 file changed +2
-11
lines changed Original file line number Diff line number Diff line change 2
2
DevalueError ,
3
3
escaped ,
4
4
get_type ,
5
+ is_plain_object ,
5
6
is_primitive ,
6
7
stringify_string
7
8
} from './utils.js' ;
@@ -10,9 +11,6 @@ const chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$';
10
11
const unsafe_chars = / [ < > \b \f \n \r \t \0 \u2028 \u2029 ] / g;
11
12
const reserved =
12
13
/ ^ (?: d o | i f | i n | f o r | i n t | l e t | n e w | t r y | v a r | b y t e | c a s e | c h a r | e l s e | e n u m | g o t o | l o n g | t h i s | v o i d | w i t h | a w a i t | b r e a k | c a t c h | c l a s s | c o n s t | f i n a l | f l o a t | s h o r t | s u p e r | t h r o w | w h i l e | y i e l d | d e l e t e | d o u b l e | e x p o r t | i m p o r t | n a t i v e | r e t u r n | s w i t c h | t h r o w s | t y p e o f | b o o l e a n | d e f a u l t | e x t e n d s | f i n a l l y | p a c k a g e | p r i v a t e | a b s t r a c t | c o n t i n u e | d e b u g g e r | f u n c t i o n | v o l a t i l e | i n t e r f a c e | p r o t e c t e d | t r a n s i e n t | i m p l e m e n t s | i n s t a n c e o f | s y n c h r o n i z e d ) $ / ;
13
- const object_proto_names = Object . getOwnPropertyNames ( Object . prototype )
14
- . sort ( )
15
- . join ( '\0' ) ;
16
14
17
15
/**
18
16
* Turn a value into the JavaScript that creates an equivalent value
@@ -72,14 +70,7 @@ export function uneval(value) {
72
70
break ;
73
71
74
72
default :
75
- const proto = Object . getPrototypeOf ( thing ) ;
76
-
77
- if (
78
- proto !== Object . prototype &&
79
- proto !== null &&
80
- Object . getOwnPropertyNames ( proto ) . sort ( ) . join ( '\0' ) !==
81
- object_proto_names
82
- ) {
73
+ if ( ! is_plain_object ( thing ) ) {
83
74
throw new DevalueError (
84
75
`Cannot stringify arbitrary non-POJOs` ,
85
76
keys
You can’t perform that action at this time.
0 commit comments