@@ -20,7 +20,11 @@ import { GeoPoint } from '../api/geo_point';
20
20
import { Timestamp } from '../api/timestamp' ;
21
21
import { DatabaseId } from '../core/database_info' ;
22
22
import { assert , fail } from '../util/assert' ;
23
- import { primitiveComparator } from '../util/misc' ;
23
+ import {
24
+ numericComparator ,
25
+ numericEquals ,
26
+ primitiveComparator
27
+ } from '../util/misc' ;
24
28
import { DocumentKey } from './document_key' ;
25
29
import { FieldMask } from './mutation' ;
26
30
import { FieldPath } from './path' ;
@@ -244,40 +248,6 @@ export abstract class NumberValue extends FieldValue {
244
248
}
245
249
}
246
250
247
- /** Utility function to compare doubles (using Firestore semantics for NaN). */
248
- function numericComparator ( left : number , right : number ) : number {
249
- if ( left < right ) {
250
- return - 1 ;
251
- } else if ( left > right ) {
252
- return 1 ;
253
- } else if ( left === right ) {
254
- return 0 ;
255
- } else {
256
- // one or both are NaN.
257
- if ( isNaN ( left ) ) {
258
- return isNaN ( right ) ? 0 : - 1 ;
259
- } else {
260
- return 1 ;
261
- }
262
- }
263
- }
264
-
265
- /**
266
- * Utility function to check numbers for equality using Firestore semantics
267
- * (NaN === NaN, -0.0 !== 0.0).
268
- */
269
- function numericEquals ( left : number , right : number ) : boolean {
270
- // Implemented based on Object.is() polyfill from
271
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
272
- if ( left === right ) {
273
- // +0 != -0
274
- return left !== 0 || 1 / left === 1 / right ;
275
- } else {
276
- // NaN == NaN
277
- return left !== left && right !== right ;
278
- }
279
- }
280
-
281
251
export class IntegerValue extends NumberValue {
282
252
isEqual ( other : FieldValue ) : boolean {
283
253
// NOTE: DoubleValue and IntegerValue instances may compareTo() the same,
0 commit comments