From 4b6d74583fbdd2d24c31b0ab809fc07950fa7533 Mon Sep 17 00:00:00 2001 From: Ethan Resnick Date: Sat, 9 Sep 2023 22:31:59 -0400 Subject: [PATCH] fix type definitions `entries()` was typed as returning an iterator, but it actually returns an iterable. (If it returned an iterator, you could call `map.entries().next()`, but that's a runtime error.) Meanwhile, `keys()` and `values()` do return iterators, which makes their types correct but their behavior a bit inconsistent with `entries()`. I'm not sure if that inconsistency is an issue, but addressing it would require a breaking change, so I stuck to just fixing the types in this PR. --- lru.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lru.d.ts b/lru.d.ts index 8672c72..3dcf879 100644 --- a/lru.d.ts +++ b/lru.d.ts @@ -61,7 +61,7 @@ export class LRUMap { values() : Iterator; // Returns an iterator over all entries, starting with the oldest. - entries() : Iterator<[K,V]>; + entries() : Iterable<[K,V]>; // Returns an iterator over all entries, starting with the oldest. [Symbol.iterator]() : Iterator<[K,V]>;