JSPM

fp-future

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2003
  • Score
    100M100P100Q130724F
  • License MIT

Package Exports

  • fp-future

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (fp-future) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

A Future is a placeholder object for a value that may not yet exist

Installation

npm install fp-future

FP Future library

It is useful for blackbox testing without weird injections and other things.

it("executes the callback", async () => {
  const somethingToBeResolved = future();

  entity.onClick(event => {
    somethingToBeResolved.resolve(event);
  });

  const nonce = Math.random();

  setTimeout(() => somethingToBeResolved.reject(new Error("timeout")), 1000);

  entityEngine.triggerClick(nonce);

  const receivedNonce = await somethingToBeResolved;

  expect(receivedNonce).toEq(nonce);
});