File tree Expand file tree Collapse file tree 1 file changed +10
-18
lines changed Expand file tree Collapse file tree 1 file changed +10
-18
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
2
cycle.js
3
- 2012-08 -19
3
+ 2013-02 -19
4
4
5
5
Public Domain.
6
6
@@ -50,20 +50,15 @@ if (typeof JSON.decycle !== 'function') {
50
50
name , // Property name
51
51
nu ; // The new object or array
52
52
53
- switch ( typeof value ) {
54
- case 'object' :
53
+ // typeof null === 'object', so go on if this value is really an object but not
54
+ // one of the weird builtin objects.
55
55
56
- // typeof null === 'object', so get out if this value is not really an object.
57
- // Also get out if it is a weird builtin object.
58
-
59
- if ( value === null ||
60
- value instanceof Boolean ||
61
- value instanceof Date ||
62
- value instanceof Number ||
63
- value instanceof RegExp ||
64
- value instanceof String ) {
65
- return value ;
66
- }
56
+ if ( typeof value === 'object' && value !== null &&
57
+ ! ( value instanceof Boolean ) &&
58
+ ! ( value instanceof Date ) &&
59
+ ! ( value instanceof Number ) &&
60
+ ! ( value instanceof RegExp ) &&
61
+ ! ( value instanceof String ) ) {
67
62
68
63
// If the value is an object or array, look to see if we have already
69
64
// encountered it. If so, return a $ref/path object. This is a hard way,
@@ -100,11 +95,8 @@ if (typeof JSON.decycle !== 'function') {
100
95
}
101
96
}
102
97
return nu ;
103
- case 'number' :
104
- case 'string' :
105
- case 'boolean' :
106
- return value ;
107
98
}
99
+ return value ;
108
100
} ( object , '$' ) ) ;
109
101
} ;
110
102
}
You can’t perform that action at this time.
0 commit comments