Skip to content

Releases: ealmansi/set-interval-async

v3.0.3

31 Dec 21:26
Compare
Choose a tag to compare

What's Changed

v3.0.2

08 Aug 15:22
Compare
Choose a tag to compare

What's Changed

  • fix: issue when importing from typescript with default resolution by @ealmansi in #43

v3.0.1

07 Aug 13:05
Compare
Choose a tag to compare

What's Changed

  • Fixed various issues around package distribution (in CommonJs, ES Modules, bundlers, browsers).
  • Improved documentation.
  • Types are included directly in the package, since the library is now implemented in Typescript.

Breaking Changes

  • "Legacy" flavour/strategy removed.

Full Changelog: v2.0.3...v3.0.1

Relese Notes: v2.0.3

24 Apr 08:03
Compare
Choose a tag to compare

Bug fixes:

  • Fixes error "Expected an instance of SetIntervalAsyncTimer" while calling clearIntervalAsync with a valid timer.

Relese Notes: v2.0.0

29 Mar 14:19
Compare
Choose a tag to compare

Breaking changes

Error handling

Errors thrown by the handler function passed in to setIntervalAsync are no longer hidden (swallowed). This will allow users of this library to more easily detect and handle failure within their handlers, which will now raise an UnhandledPromiseRejectionWarning if not handled by the application itself. If you wish to fall back to the previous behaviour, you may simply wrap your handlers in the following way:

setIntervalAsync(async () => {
  try {
    await handler();  // the previous handler function which could potentially fail
  } catch (err) {
    console.error(err);
  }
}, someInterval);

// or similarly,

setIntervalAsync(() => {
  return Promise.resolve(handler()).catch((err) => console.error(err));
}, someInterval);

Bug fixes

Awaiting clearIntervalAsync

While clearIntervalAsync was still correctly clearing the execution interval, a bug in version v1.x.x was causing the promise returned by the function to be resolved prematurely before the interval was fully stopped. This bug has now been fixed, which means the following code should work as expected:

it('should test something', async () => {
  const timer = setIntervalAsync(...);
  // Some assertions.
  await clearIntervalAsync(timer);
  // At this point, the interval has been cleared and all executions
  // are guaranteed to have fully finished.
});