SkillAgentSearch skills...

Lector

A library for contextual computations in Javascript

Install / Use

/learn @davazp/Lector
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

lector

Build Status npm version

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

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

Introduction to readers

Using lector with React and Redux

Overview

You define readers by chaining them with other readers

import { ask, coroutine } from "lector";

const getVersion = ask.chain(context => context.version);

const f = coroutine(function*() {
  const version = yield getVersion;

  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 .chain, which will be called with the return value of the previous reader.

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

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

f().run({version: 2})
View on GitHub
GitHub Stars11
CategoryDevelopment
Updated3y ago
Forks1

Languages

JavaScript

Security Score

80/100

Audited on Jan 28, 2023

No findings