File tree Expand file tree Collapse file tree 1 file changed +1
-31
lines changed Expand file tree Collapse file tree 1 file changed +1
-31
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,6 @@ function build (schema, options) {
15
15
`
16
16
code += `
17
17
${ $asString . toString ( ) }
18
- ${ $asStringSmall . toString ( ) }
19
18
${ $asNumber . toString ( ) }
20
19
${ $asNull . toString ( ) }
21
20
${ $asBoolean . toString ( ) }
@@ -85,36 +84,7 @@ function $asString (str) {
85
84
str = str . toString ( )
86
85
}
87
86
88
- if ( str . length < 42 ) {
89
- return $asStringSmall ( str )
90
- } else {
91
- return JSON . stringify ( str )
92
- }
93
- }
94
-
95
- // magically escape strings for json
96
- // relying on their charCodeAt
97
- // everything below 32 needs JSON.stringify()
98
- // 34 and 92 happens all the time, so we
99
- // have a fast case for them
100
- function $asStringSmall ( str ) {
101
- var result = ''
102
- var last = 0
103
- var l = str . length
104
- var point = 255
105
- for ( var i = 0 ; i < l && point >= 32 ; i ++ ) {
106
- point = str . charCodeAt ( i )
107
- if ( point === 34 || point === 92 ) {
108
- result += str . slice ( last , i ) + '\\' + str [ i ]
109
- last = i + 1
110
- }
111
- }
112
- if ( last === 0 ) {
113
- result = str
114
- } else {
115
- result += str . slice ( last )
116
- }
117
- return point < 32 ? JSON . stringify ( str ) : '"' + result + '"'
87
+ return JSON . stringify ( str )
118
88
}
119
89
120
90
function $asRegExp ( reg ) {
You can’t perform that action at this time.
0 commit comments