@dra2020/baseclient 1.0.150 → 1.0.151

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3299,7 +3299,7 @@ class MultiBlockMapping {
3299
3299
  return this.entries.length ? this.entries[0].bm[blockid] : undefined;
3300
3300
  }
3301
3301
  rev(geoid) {
3302
- for (let i = 0; i < this.entries.length; i++) {
3302
+ for (let i = this.entries.length - 1; i >= 0; i--) {
3303
3303
  let e = this.entries[i];
3304
3304
  if (!e.rbm)
3305
3305
  e.rbm = reverseBlockMapping(e.bm);
@@ -3313,13 +3313,19 @@ class MultiBlockMapping {
3313
3313
  if (this.entries.length)
3314
3314
  Object.keys(this.entries[0].bm).forEach(blockid => cb(blockid));
3315
3315
  }
3316
- // Just walks first map
3316
+ // Walk maps in reverse order, careful to not invoke on same geoid
3317
3317
  forEachRev(cb) {
3318
- for (let i = 0; i < this.entries.length; i++) {
3318
+ let seen = new Set();
3319
+ for (let i = this.entries.length - 1; i >= 0; i--) {
3319
3320
  let e = this.entries[i];
3320
3321
  if (!e.rbm)
3321
3322
  e.rbm = reverseBlockMapping(e.bm);
3322
- Object.keys(e.rbm).forEach(geoid => cb(geoid, e.rbm[geoid]));
3323
+ Object.keys(e.rbm).forEach(geoid => {
3324
+ if (!seen.has(geoid)) {
3325
+ seen.add(geoid);
3326
+ cb(geoid, e.rbm[geoid]);
3327
+ }
3328
+ });
3323
3329
  }
3324
3330
  }
3325
3331
  }