@most/fluent

0.1.0 • Public • Published

Build Status

EXPERIMENTAL This is an experimental package.

@most/fluent

Use @most/core with a fluent API. @most/fluent wraps a @most/core Stream in a FluentStream type that provides thru and to methods for dot-chaining.

Get it

npm i @most/fluent --save

yarn add @most/fluent

Example

import { change } from `@most/dom-event`
import { map, filter } from `@most/core`
import { fluently } from `@most/fluent`

const changes = change(inputElement)

// Wrap a @most/core stream of change events and fluently
// map change events to their associated input value, and
// retain only non-empty values
const changesFluent = fluently(changes)
  .thru(map(e => e.target.value))
  .thru(filter(value => value.length > 0))

Types

FluentStream

A FluentStream is a Stream with two additional methods that enable fluent (dot-chaining) usage.

type FluentStream<A> = Stream<A> & {
  thru <B> (f: (Stream<A>) => Stream<B>): FluentStream<B>
  apply <B> (f: (Stream<A>) => B): B
}

API

fluently :: Stream a → FluentStream a

Wrap a @most/core Stream in a FluentStream.

FluentStream methods

thru :: FluentStream a ~> (Stream a → Stream b) → FluentStream b

Apply functions fluently to a Stream, wrapping the result in a FluentStream. Use thru when you want to continue dot-chaining other Stream operations.

apply :: FluentStream a ~> (Stream a → b) → b

Apply functions fluently to a Stream, without re-wrapping the result. Use apply to return something other than a Stream.

Readme

Keywords

none

Package Sidebar

Install

npm i @most/fluent

Weekly Downloads

1

Version

0.1.0

License

MIT

Last publish

Collaborators

  • most