0.11.0 • Published 9 months ago

@jasonsbarr/concurrency v0.11.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

@jasonsbarr/concurrency

A functional type for handling concurrent and asynchronous operations.

Includes the monadic Future type.

Basic Usage

Import the Future type and use as follows:

import { Future } from "@jasonsbarr/concurrency/lib/Future";

// assume the existence of a handleError function and an addToDom function that appends an HTML string to the DOM
Future.fromPromise(
  fetch("https://jsonplaceholder.typicode.com/posts").then((res) => res.json())
)
  .map((posts) => posts.map((post) => ({ title, body })))
  .map((posts) =>
    posts.reduce(
      (html, post) =>
        (html += `<article class="post">
        <header class="post-header">
            <h1>${post.title}</h1>
        </header>
        <section class="post-body">${post.body}</section>
    </article>`),
      ""
    )
  )
  .fork(
    (err) => handleError(err),
    (posts) => addToDom(posts)
  );

Documentation

Documentation

0.10.0

10 months ago

0.11.0

9 months ago

0.10.1

10 months ago

0.9.4

2 years ago

0.9.3

2 years ago

0.9.2

2 years ago

0.8.0

2 years ago

0.7.1

2 years ago