Closed yvt closed 5 months ago
The getFilesByCount method returns fewer rows if the actual count is not a multiple of the page limit (10).
getFilesByCount
When a fetched paginated result contains less than pageLimit, keepLooping is set to false here:
pageLimit
keepLooping
false
https://github.com/PinataCloud/Pinata-SDK/blob/949a2f99330318975cbb7c61c35a0253ba5f339b/src/commands/data/getFilesByCount/getFilesByCount.ts#L34-L37
...which causes next() to resolve with { done: true, ... }, terminating the async iterator:
next()
{ done: true, ... }
https://github.com/PinataCloud/Pinata-SDK/blob/949a2f99330318975cbb7c61c35a0253ba5f339b/src/commands/data/getFilesByCount/getFilesByCount.ts#L45-L54
In this case, the returned value is treated as a generator return value, which is just thrown away by a for await...of loop. (A for await...of loop only iterates over yielded values.)
value
for await...of
Hey there! Thank you for this feedback! We are currently rewriting the SDK and will take this into consideration
The
getFilesByCount
method returns fewer rows if the actual count is not a multiple of the page limit (10).When a fetched paginated result contains less than
pageLimit
,keepLooping
is set tofalse
here:https://github.com/PinataCloud/Pinata-SDK/blob/949a2f99330318975cbb7c61c35a0253ba5f339b/src/commands/data/getFilesByCount/getFilesByCount.ts#L34-L37
...which causes
next()
to resolve with{ done: true, ... }
, terminating the async iterator:https://github.com/PinataCloud/Pinata-SDK/blob/949a2f99330318975cbb7c61c35a0253ba5f339b/src/commands/data/getFilesByCount/getFilesByCount.ts#L45-L54
In this case, the returned
value
is treated as a generator return value, which is just thrown away by afor await...of
loop. (Afor await...of
loop only iterates over yielded values.)