Skip to content

Releases: ggoodman/context

v2.1.0

18 Mar 19:07

Choose a tag to compare

Changed

  • Adjust use of private fields to use private Symbol properties as a performance optimization for targets that don't yet support private fields.

v2.0.0

17 Feb 14:22

Choose a tag to compare

Added

    • Major API redesign for simplicity, portability and tree-shakeability.

v1.1.2

10 Nov 15:15

Choose a tag to compare

Fixed

  • Fixed issue where an .onDidCancel handler registered on an already-cancelled Context was being invoked without the expected cancellation reason. (#3)

v1.1.1

09 Jun 14:53

Choose a tag to compare

Fixed

  • Fixed an illegal invocation when using the default implementation of the setTimeout and clearTimeout functions.

    Previously, these functions were being called with the options object as the receiver instead of globalThis. This change calls these functions in a way that their receivers will be globalThis.

v1.1.0

08 Jun 17:00

Choose a tag to compare

Added

  • Added support for treating a Context as a PromiseLike<never>.

    This is useful, for example, when you want to use a Context with a timeout to 'race' another Promise-returning operation, like an http request.

    (async () => {
      const { context } = Background.withTimeout(2000);
      const resPromise = fetch('https://foo.bar').then(res => res.json());
    
      // This will throw an Error that will either be true for isCancellationError or isDeadlineExceededError.
      const res = await Promise.race([ context, resPromise ]);
    })();
  • Add support for converting a Context to an AbortSignal in environments that support these using asAbortSignal.

    This feature allows easy interoperability with APIs that support AbortSignals as a mechanism to propagate cancellation.

    For example, with fetch, adding a timeout could be as easy as:

    (async () => {
      const { context } = Background.withTimeout(2000);
      const signal = asAbortSignal(context);
    
      const res = await fetch('https://foo.bar', { signal });
      const data = await res.json();
    })();

v1.0.0

27 Apr 20:58

Choose a tag to compare

Added

  • Added a copy of the MIT license
  • Added keywords to package.json and future work to README.md
  • Added automated test runs using GitHub Actions

v0.0.1

27 Apr 20:44

Choose a tag to compare

Added

  • Initial release.