File tree Expand file tree Collapse file tree 1 file changed +7
-14
lines changed
packages/firestore/test/unit/util Expand file tree Collapse file tree 1 file changed +7
-14
lines changed Original file line number Diff line number Diff line change @@ -92,40 +92,33 @@ class StringGenerator {
92
92
} else {
93
93
this . rnd = seedOrRnd ;
94
94
this . surrogatePairProbability = StringGenerator . validateProbability (
95
- 'surrogate pair' ,
96
95
surrogatePairProbability !
97
96
) ;
98
- this . maxLength = StringGenerator . validateLength (
99
- 'maximum string' ,
100
- maxLength !
101
- ) ;
97
+ this . maxLength = StringGenerator . validateLength ( maxLength ! ) ;
102
98
}
103
99
}
104
100
105
- private static validateProbability (
106
- name : string ,
107
- probability : number
108
- ) : number {
101
+ private static validateProbability ( probability : number ) : number {
109
102
if ( ! Number . isFinite ( probability ) ) {
110
103
throw new Error (
111
- `invalid ${ name } probability: ${ probability } (must be between 0.0 and 1.0, inclusive)`
104
+ `invalid surrogate pair probability: ${ probability } (must be between 0.0 and 1.0, inclusive)`
112
105
) ;
113
106
} else if ( probability < 0.0 ) {
114
107
throw new Error (
115
- `invalid ${ name } probability: ${ probability } (must be greater than or equal to zero)`
108
+ `invalid surrogate pair probability: ${ probability } (must be greater than or equal to zero)`
116
109
) ;
117
110
} else if ( probability > 1.0 ) {
118
111
throw new Error (
119
- `invalid ${ name } probability: ${ probability } (must be less than or equal to 1)`
112
+ `invalid surrogate pair probability: ${ probability } (must be less than or equal to 1)`
120
113
) ;
121
114
}
122
115
return probability ;
123
116
}
124
117
125
- private static validateLength ( name : string , length : number ) : number {
118
+ private static validateLength ( length : number ) : number {
126
119
if ( length < 0 ) {
127
120
throw new Error (
128
- `invalid ${ name } length: ${ length } (must be greater than or equal to zero)`
121
+ `invalid maximum string length: ${ length } (must be greater than or equal to zero)`
129
122
) ;
130
123
}
131
124
return length ;
You can’t perform that action at this time.
0 commit comments