Skip to content

Commit 9cb64b7

Browse files
committed
Add spec annotations for LiveMap access API
Spec IDs from [1] [1] ably/specification#341
1 parent d910262 commit 9cb64b7

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

src/plugins/objects/livemap.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,11 @@ export class LiveMap<T extends API.LiveMapType> extends LiveObject<LiveMapData,
320320
return this._getResolvedValueFromObjectData(element.data!) as T[TKey];
321321
}
322322

323+
/** @spec RTLM10, RTLM10a */
323324
size(): number {
324-
this._objects.throwIfInvalidAccessApiConfiguration();
325+
this._objects.throwIfInvalidAccessApiConfiguration(); // RTLM10b, RTLM10c
325326

327+
// RTLM10d
326328
let size = 0;
327329
for (const value of this._dataRef.data.values()) {
328330
if (this._isMapEntryTombstoned(value)) {
@@ -336,30 +338,34 @@ export class LiveMap<T extends API.LiveMapType> extends LiveObject<LiveMapData,
336338
return size;
337339
}
338340

341+
/** @spec RTLM11, RTLM11a */
339342
*entries<TKey extends keyof T & string>(): IterableIterator<[TKey, T[TKey]]> {
340-
this._objects.throwIfInvalidAccessApiConfiguration();
343+
this._objects.throwIfInvalidAccessApiConfiguration(); // RTLM11b, RTLM11c
341344

345+
// RTLM11d
342346
for (const [key, entry] of this._dataRef.data.entries()) {
343347
if (this._isMapEntryTombstoned(entry)) {
344-
// do not return tombstoned entries
348+
// RTLM11d1 - do not return tombstoned entries
345349
continue;
346350
}
347351

348352
// data always exists for non-tombstoned elements
349353
const value = this._getResolvedValueFromObjectData(entry.data!) as T[TKey];
350-
yield [key as TKey, value];
354+
yield [key as TKey, value]; // RTLM11d2
351355
}
352356
}
353357

358+
/** @spec RTLM12, RTLM12a */
354359
*keys<TKey extends keyof T & string>(): IterableIterator<TKey> {
355360
for (const [key] of this.entries<TKey>()) {
356-
yield key;
361+
yield key; // RTLM12b
357362
}
358363
}
359364

365+
/** @spec RTLM13, RTLM13a */
360366
*values<TKey extends keyof T & string>(): IterableIterator<T[TKey]> {
361367
for (const [_, value] of this.entries<TKey>()) {
362-
yield value;
368+
yield value; // RTLM13b
363369
}
364370
}
365371

@@ -943,9 +949,10 @@ export class LiveMap<T extends API.LiveMapType> extends LiveObject<LiveMapData,
943949
return refObject; // RTLM5d2f2
944950
}
945951

952+
/** @spec RTLM14 */
946953
private _isMapEntryTombstoned(entry: LiveMapEntry): boolean {
947954
if (entry.tombstone === true) {
948-
return true;
955+
return true; // RTLM14a
949956
}
950957

951958
// data always exists for non-tombstoned entries
@@ -959,6 +966,6 @@ export class LiveMap<T extends API.LiveMapType> extends LiveObject<LiveMapData,
959966
}
960967
}
961968

962-
return false;
969+
return false; // RTLM14b
963970
}
964971
}

0 commit comments

Comments
 (0)