| 145 | } |
| 146 | |
| 147 | function createDictionary(dataOrField: any, fieldPathValue?: any, moreFieldsAndValues?: any) { |
| 148 | const data = NSMutableDictionary.alloc().init(); |
| 149 | |
| 150 | const assignKeyValue = (key, val) => { |
| 151 | // check the map for weak object |
| 152 | if (typeof key === 'string' && key.includes('FIRFieldPath')) { |
| 153 | const ref = fp_refs.get(key)?.get?.(); |
| 154 | if (ref) { |
| 155 | data.setObjectForKey(serializeItems(val), ref); |
| 156 | return; |
| 157 | } |
| 158 | } |
| 159 | data.setObjectForKey(serializeItems(val), key instanceof FieldPath ? key.native : key); |
| 160 | }; |
| 161 | if (!fieldPathValue && !moreFieldsAndValues) { |
| 162 | Object.entries(dataOrField).forEach((item) => assignKeyValue(item[0], item[1])); |
| 163 | } else { |
| 164 | assignKeyValue(dataOrField, fieldPathValue); |
| 165 | if (Array.isArray(moreFieldsAndValues)) { |
| 166 | Object.entries(Object.fromEntries(moreFieldsAndValues)).forEach(([key, value]) => assignKeyValue(key, value)); |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | return data; |
| 171 | } |
| 172 | |
| 173 | export class Transaction implements ITransaction { |
| 174 | _native: FIRTransaction; |