Skip to content

mostjs/x-fluent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 apply 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.

About

EXPERIMENTAL: Fluent API adapter for @most/core

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy