1- import encode from ' ./encode' ;
2- import CoreManager from ' ./CoreManager' ;
3- import ParseFile from ' ./ParseFile' ;
4- import ParseRelation from ' ./ParseRelation' ;
5- import TaskQueue from ' ./TaskQueue' ;
6- import { RelationOp } from ' ./ParseOp' ;
7- import type { Op } from ' ./ParseOp' ;
8- import type ParseObject from ' ./ParseObject' ;
1+ import encode from " ./encode" ;
2+ import CoreManager from " ./CoreManager" ;
3+ import ParseFile from " ./ParseFile" ;
4+ import ParseRelation from " ./ParseRelation" ;
5+ import TaskQueue from " ./TaskQueue" ;
6+ import { RelationOp } from " ./ParseOp" ;
7+ import type { Op } from " ./ParseOp" ;
8+ import type ParseObject from " ./ParseObject" ;
99
1010export type AttributeMap = Record < string , any > ;
1111export type OpsMap = Record < string , Op > ;
@@ -29,9 +29,12 @@ export function defaultState(): State {
2929 } ;
3030}
3131
32- export function setServerData ( serverData : AttributeMap , attributes : AttributeMap ) {
32+ export function setServerData (
33+ serverData : AttributeMap ,
34+ attributes : AttributeMap
35+ ) {
3336 for ( const attr in attributes ) {
34- if ( typeof attributes [ attr ] !== ' undefined' ) {
37+ if ( typeof attributes [ attr ] !== " undefined" ) {
3538 serverData [ attr ] = attributes [ attr ] ;
3639 } else {
3740 delete serverData [ attr ] ;
@@ -86,7 +89,11 @@ export function estimateAttribute(
8689 if ( pendingOps [ i ] [ attr ] ) {
8790 if ( pendingOps [ i ] [ attr ] instanceof RelationOp ) {
8891 if ( object . id ) {
89- value = ( pendingOps [ i ] [ attr ] as RelationOp ) . applyTo ( value , object , attr ) ;
92+ value = ( pendingOps [ i ] [ attr ] as RelationOp ) . applyTo (
93+ value ,
94+ object ,
95+ attr
96+ ) ;
9097 }
9198 } else {
9299 value = pendingOps [ i ] [ attr ] . applyTo ( value ) ;
@@ -110,12 +117,16 @@ export function estimateAttributes(
110117 for ( attr in pendingOps [ i ] ) {
111118 if ( pendingOps [ i ] [ attr ] instanceof RelationOp ) {
112119 if ( object . id ) {
113- data [ attr ] = ( pendingOps [ i ] [ attr ] as RelationOp ) . applyTo ( data [ attr ] , object , attr ) ;
120+ data [ attr ] = ( pendingOps [ i ] [ attr ] as RelationOp ) . applyTo (
121+ data [ attr ] ,
122+ object ,
123+ attr
124+ ) ;
114125 }
115126 } else {
116- if ( attr . includes ( '.' ) ) {
127+ if ( attr . includes ( "." ) ) {
117128 // similar to nestedSet function
118- const fields = attr . split ( '.' ) ;
129+ const fields = attr . split ( "." ) ;
119130 const last = fields [ fields . length - 1 ] ;
120131 let object = data ;
121132 for ( let i = 0 ; i < fields . length - 1 ; i ++ ) {
@@ -157,7 +168,7 @@ export function estimateAttributes(
157168 * @param value The value to assign. If it's an `undefined` then the key is deleted.
158169 */
159170function nestedSet ( obj , key , value ) {
160- const paths = key . split ( '.' ) ;
171+ const paths = key . split ( "." ) ;
161172 for ( let i = 0 ; i < paths . length - 1 ; i ++ ) {
162173 const path = paths [ i ] ;
163174 if ( ! ( path in obj ) ) {
@@ -170,7 +181,7 @@ function nestedSet(obj, key, value) {
170181 }
171182 obj = obj [ path ] ;
172183 }
173- if ( typeof value === ' undefined' ) {
184+ if ( typeof value === " undefined" ) {
174185 delete obj [ paths [ paths . length - 1 ] ] ;
175186 } else {
176187 obj [ paths [ paths . length - 1 ] ] = value ;
@@ -188,7 +199,7 @@ export function commitServerChanges(
188199 nestedSet ( serverData , attr , val ) ;
189200 if (
190201 val &&
191- typeof val === ' object' &&
202+ typeof val === " object" &&
192203 ! ( val instanceof ParseObject ) &&
193204 ! ( val instanceof ParseFile ) &&
194205 ! ( val instanceof ParseRelation )
0 commit comments