1- var equalObjects = require ( './equals' ) . default ;
2- var decode = require ( './decode' ) . default ;
3- var ParseError = require ( './ParseError' ) . default ;
4- var ParsePolygon = require ( './ParsePolygon' ) . default ;
5- var ParseGeoPoint = require ( './ParseGeoPoint' ) . default ;
1+ const equalObjects = require ( './equals' ) . default ;
2+ const decode = require ( './decode' ) . default ;
3+ const ParseError = require ( './ParseError' ) . default ;
4+ const ParsePolygon = require ( './ParsePolygon' ) . default ;
5+ const ParseGeoPoint = require ( './ParseGeoPoint' ) . default ;
66
77/**
88 * contains -- Determines if an object is contained in a list with special handling for Parse pointers.
@@ -49,7 +49,7 @@ function matchesQuery(className, object, objects, query) {
4949 q = query . toJSON ( ) . where ;
5050 }
5151 obj . className = className ;
52- for ( var field in q ) {
52+ for ( const field in q ) {
5353 if ( ! matchesKeyConstraints ( className , obj , objects , field , q [ field ] ) ) {
5454 return false ;
5555 }
@@ -78,12 +78,12 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
7878 }
7979 if ( key . indexOf ( '.' ) >= 0 ) {
8080 // Key references a subobject
81- var keyComponents = key . split ( '.' ) ;
82- var subObjectKey = keyComponents [ 0 ] ;
83- var keyRemainder = keyComponents . slice ( 1 ) . join ( '.' ) ;
81+ const keyComponents = key . split ( '.' ) ;
82+ const subObjectKey = keyComponents [ 0 ] ;
83+ const keyRemainder = keyComponents . slice ( 1 ) . join ( '.' ) ;
8484 return matchesKeyConstraints ( className , object [ subObjectKey ] || { } , objects , keyRemainder , constraints ) ;
8585 }
86- var i ;
86+ let i ;
8787 if ( key === '$or' ) {
8888 for ( i = 0 ; i < constraints . length ; i ++ ) {
8989 if ( matchesQuery ( className , object , objects , constraints [ i ] ) ) {
@@ -122,7 +122,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
122122 }
123123 return object [ key ] === constraints ;
124124 }
125- var compareTo ;
125+ let compareTo ;
126126 if ( constraints . __type ) {
127127 if ( constraints . __type === 'Pointer' ) {
128128 return equalObjectsGeneric ( object [ key ] , constraints , function ( obj , ptr ) {
@@ -132,7 +132,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
132132 return equalObjectsGeneric ( decode ( object [ key ] ) , decode ( constraints ) , equalObjects ) ;
133133 }
134134 // More complex cases
135- for ( var condition in constraints ) {
135+ for ( const condition in constraints ) {
136136 compareTo = constraints [ condition ] ;
137137 if ( compareTo . __type ) {
138138 compareTo = decode ( compareTo ) ;
@@ -202,9 +202,9 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
202202 return compareTo . test ( object [ key ] ) ;
203203 }
204204 // JS doesn't support perl-style escaping
205- var expString = '' ;
206- var escapeEnd = - 2 ;
207- var escapeStart = compareTo . indexOf ( '\\Q' ) ;
205+ let expString = '' ;
206+ let escapeEnd = - 2 ;
207+ let escapeStart = compareTo . indexOf ( '\\Q' ) ;
208208 while ( escapeStart > - 1 ) {
209209 // Add the unescaped portion
210210 expString += compareTo . substring ( escapeEnd + 2 , escapeStart ) ;
@@ -219,30 +219,32 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
219219 let modifiers = constraints . $options || '' ;
220220 modifiers = modifiers . replace ( 'x' , '' ) . replace ( 's' , '' )
221221 // Parse Server / Mongo support x and s modifiers but JS RegExp doesn't
222- var exp = new RegExp ( expString , modifiers ) ;
222+ const exp = new RegExp ( expString , modifiers ) ;
223223 if ( ! exp . test ( object [ key ] ) ) {
224224 return false ;
225225 }
226226 break ;
227227 }
228- case '$nearSphere' :
228+ case '$nearSphere' : {
229229 if ( ! compareTo || ! object [ key ] ) {
230230 return false ;
231231 }
232- var distance = compareTo . radiansTo ( object [ key ] ) ;
233- var max = constraints . $maxDistance || Infinity ;
232+ const distance = compareTo . radiansTo ( object [ key ] ) ;
233+ const max = constraints . $maxDistance || Infinity ;
234234 return distance <= max ;
235- case '$within' :
235+ }
236+ case '$within' : {
236237 if ( ! compareTo || ! object [ key ] ) {
237238 return false ;
238239 }
239- var southWest = compareTo . $box [ 0 ] ;
240- var northEast = compareTo . $box [ 1 ] ;
240+ const southWest = compareTo . $box [ 0 ] ;
241+ const northEast = compareTo . $box [ 1 ] ;
241242 if ( southWest . latitude > northEast . latitude || southWest . longitude > northEast . longitude ) {
242243 // Invalid box, crosses the date line
243244 return false ;
244245 }
245246 return object [ key ] . latitude > southWest . latitude && object [ key ] . latitude < northEast . latitude && object [ key ] . longitude > southWest . longitude && object [ key ] . longitude < northEast . longitude ;
247+ }
246248 case '$options' :
247249 // Not a query type, but a way to add options to $regex. Ignore and
248250 // avoid the default
@@ -346,7 +348,7 @@ function validateQuery(query: any) {
346348 } ) ;
347349}
348350
349- var OfflineQuery = {
351+ const OfflineQuery = {
350352 matchesQuery : matchesQuery ,
351353 validateQuery : validateQuery ,
352354} ;
0 commit comments