From d6a2210beacac5d2fc9f58dfeeddbb2a6cc1f3be Mon Sep 17 00:00:00 2001 From: Ivan Kalinin Date: Wed, 10 Jul 2024 13:13:40 +0200 Subject: [PATCH] Fix `Stream.take(n)` not returning immediately after the last item --- package.json | 2 +- src/stream.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a77cd74d..7fe9002e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "everscale-inpage-provider", - "version": "0.3.65", + "version": "0.3.66", "description": "Web3-like interface to the Everscale blockchain", "repository": "https://github.com/broxus/everscale-inpage-provider", "main": "dist/index.js", diff --git a/src/stream.ts b/src/stream.ts index 526a3c53..a0121036 100644 --- a/src/stream.ts +++ b/src/stream.ts @@ -726,7 +726,8 @@ class StreamImpl implements Stream { this.extractor(event, (item) => { if (state.index < n) { ++state.index; - return handler(item); + // NOTE: Execute the handler and ensure that `false` is returned right after the Nth call + return handler(item) && state.index < n; } else { return false; }