| 361 | * @returns whether the keys are the same and the values are shallow equal. |
| 362 | */ |
| 363 | export const shallowEqualStringMap = ( |
| 364 | map1: { [k: string]: any } | undefined, |
| 365 | map2: { [k: string]: any } | undefined |
| 366 | ): boolean => { |
| 367 | map1 ??= {}; |
| 368 | map2 ??= {}; |
| 369 | |
| 370 | if (map1 === map2) { |
| 371 | return true; |
| 372 | } |
| 373 | |
| 374 | const keys1 = Object.keys(map1); |
| 375 | |
| 376 | if (keys1.length !== Object.keys(map2).length) { |
| 377 | return false; |
| 378 | } |
| 379 | |
| 380 | for (const k1 of keys1) { |
| 381 | if (!(k1 in map2)) { |
| 382 | return false; |
| 383 | } |
| 384 | if (map1[k1] !== map2[k1]) { |
| 385 | return false; |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | return true; |
| 390 | }; |
| 391 | |
| 392 | /** |
| 393 | * Checks input for usable number. Not NaN and not Infinite. |