unional / async-fp

Asynchronous Functional Programming Utilities
2 stars 1 forks source link
async context dependency fp functional functional-programming promise typescript

async-fp repository

GitHub NodeJS Codecov

async-fp

NPM version NPM downloads Bundle size

A collection of utilities for asynchronous functional programming.

@unional/async-context

NPM version NPM downloads Bundle size

Secure, type safe, asynchronous context for functional programming.

Introduction Video

import { AsyncContext } from '@unional/async-context'

const context = new AsyncContext(async () => ({ config: 'async value' }))

await context.get() //=> { config: 'async value' }

@unional/gizmo

NPM version NPM downloads Bundle size

@unional/gizmo is a library to create gizmo: an object with static or dynamic dependencies, with an optional start function.

import { define, incubate } from '@unional/gizmo'

const gizmo = define({
  async create() { return { foo: { blow() { /* ..snap.. */ } } } }
})

const gizmoWithStart = define({
  async create() {
    return [
      { foo2: { blow() { /* ..snap.. */ } } },
      () => { /* ..snap.. */ }
    ]
  }
})

const gizmoWithAsyncStart = define({
  async create() {
    return  [
      { foo3: { blow() { /* ..snap.. */ } } },
      async () => { /* ..snap.. */ }
    ]
  }
})

const obj = await incubate().with(gizmo).create()
obj.foo.blow()