Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

async-reader

davazp7MITdeprecated0.1.0

This package has been deprecated

Contextual asynchronous library for Javascript

reader, monad, context, coroutine, promises

readme

async-reader

Build Status

async-reader is a library to deal with asynchronous readers: computations with access to some read-only context.

This is package is experimental and it is under active development. Expect backward-incompatible changes

Introduction

You define readers by chaining them with other readers:

const {ask} = require('async-reader')

const getVersion = ask.then(context => context.version)

function f () {
  return getVersion.then(version=>{
    if (version === 1){
      console.log('hello')
    } else {
      console.log('bye')
    }

    return version
  })
}

the ask reader is a built-in reader that just returns the whole context. You can define a derived reader by calling .then, which will be called with the return value of the previuos reader.

If you return a Promise or another Reader, the resolved value of those will be passed to the next reader.

Finallhy, you can provide the context to the function at the top of your stack:

f().run({version: 2})

Installation

You can install this package with

npm install async-reader

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

Unreleased

0.1.0 - 2017-11-33

Added

  • First version of the library. Basic Reader class and methods
  • Implement Reader.coroutine function
  • Add helper method prop to get a property of a reader