fp-future
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

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);
});

Readme

Keywords

none

Package Sidebar

Install

npm i fp-future

Weekly Downloads

2,118

Version

1.0.1

License

MIT

Unpacked Size

4.7 kB

Total Files

4

Last publish

Collaborators

  • menduz