Skip to content

Commit 922433d

Browse files
committed
Add spec annotations for LiveMap access API
Spec IDs from [1] [1] ably/specification#341
1 parent 38e5804 commit 922433d

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/plugins/objects/livemap.ts

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

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

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

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

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

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

359+
/** @spec RTLM12, RTLM12a */
355360
*keys<TKey extends keyof T & string>(): IterableIterator<TKey> {
356361
for (const [key] of this.entries<TKey>()) {
357-
yield key;
362+
yield key; // RTLM12b
358363
}
359364
}
360365

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

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

953+
/** @spec RTLM14 */
947954
private _isMapEntryTombstoned(entry: LiveMapEntry): boolean {
948955
if (entry.tombstone === true) {
949-
return true;
956+
return true; // RTLM14a
950957
}
951958

952959
// data always exists for non-tombstoned entries
@@ -960,6 +967,6 @@ export class LiveMap<T extends API.LiveMapType> extends LiveObject<LiveMapData,
960967
}
961968
}
962969

963-
return false;
970+
return false; // RTLM14b
964971
}
965972
}

0 commit comments

Comments
 (0)