๐Ÿš€ Socket Launch Week ๐Ÿš€ Day 5: Introducing Socket Fix.Learn More โ†’
Socket
Sign inDemoInstall
Socket

callbag-types

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

callbag-types

Types for ๐Ÿ‘œ Callbags

0.0.2
latest
Source
npm
Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
ย 
Created
Source

/**

  •                   โš ๏ธ  DO NOT USE! โš ๏ธ
    
  • From what I can tell, Flow does not allow enough fine control
  • over polymorphism to realistically tame the possible typings
  • of callbags. If someone can figure it out, PRs very, very welcome.
  • This library provides types for ๐Ÿ‘œ Callbags according to the spec.
  • Spec: https://github.com/callbag/callbag
  • Original Typing work: http://blog.krawaller.se/posts/explaining-callbags-via-typescript-definitions/
  • Installation
  • npm install --save-dev callbag-types
  • Usage
  • import type { START, SourceInitiator } from 'callbag-types'
  • @flow */

export type START = 0 export type DATA = 1 export type END = 2

/**

  • Quoth the spec:
  • "A callbag is terminated when the first argument is 2 and the second
  • argument is either undefined (signalling termination due to success)
  • or any truthy value (signalling termination due to failure)." */ export type SourceTalkback = ((DATA, T) => void) & ((END, error?: any) => void)

export type SinkTalkback = (( START, SourceTalkback | SourceInitiator ) => void) & SourceTalkback

/**

  • Quoth the spec:
  • "When a source is greeted and given a sink as payload, the sink MUST
  • be greeted back with a callbag payload that is either the source
  • itself or another callbag (known as the 'talkback'). In other
  • words, greets are mutual. Reciprocal greeting is called a handshake." */ export type SourceInitiator = (START, SinkTalkback) => void

export type SinkConnector = ( source: SourceInitiator ) => ?SourceInitiator

export type SourceFactory = (...args: any[]) => SourceInitiator

export type Operator = (...args: any[]) => SinkConnector

export type Callbag = | SourceTalkback<> | SinkTalkback<> | SourceFactory<> | SourceInitiator<> | SinkConnector<*>

FAQs

Package last updated on 13 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts