Socket
Socket
Sign inDemoInstall

@jasonsbarr/concurrency

Package Overview
Dependencies
3
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @jasonsbarr/concurrency

Handling concurrency the functional way


Version published
Maintainers
1
Created

Readme

Source

@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

Keywords

FAQs

Last updated on 02 Aug 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc