Huge News!Announcing our $40M Series B led by Abstract Ventures.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 - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

2

package.json
{
"name": "callbag-types",
"version": "0.0.1",
"version": "0.0.2",
"description": "Types for 👜 Callbags",

@@ -5,0 +5,0 @@ "main": "README.js",

@@ -1,6 +0,27 @@

// @flow
/**
* *****************************************************************
* *****************************************************************
* ⚠️ 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
*/
// Plagiarized from http://blog.krawaller.se/posts/explaining-callbags-via-typescript-definitions/
// and added generics.
export type START = 0

@@ -10,17 +31,31 @@ export type DATA = 1

export type SourceTalkback = ((request: DATA) => void) &
((terminate: END) => void)
/**
* 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<T> = ((DATA, T) => void) &
((END, error?: any) => void)
export type SinkTalkback<T> = ((
start: START,
sourceTalkback: SourceTalkback
START,
SourceTalkback<T> | SourceInitiator<T>
) => void) &
((deliver: DATA, data: T) => void) &
((terminate: END, error?: any) => void)
SourceTalkback<T>
export type SourceInitiator<T> = (type: START, payload: SinkTalkback<T>) => void
/**
* 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<T> = (START, SinkTalkback<T>) => void
export type SinkConnector<T> = (
source: SourceInitiator<T>
) => SourceInitiator<T> | void
) => ?SourceInitiator<T>

@@ -32,3 +67,3 @@ export type SourceFactory<T> = (...args: any[]) => SourceInitiator<T>

export type Callbag =
| SourceTalkback
| SourceTalkback<*>
| SinkTalkback<*>

@@ -35,0 +70,0 @@ | SourceFactory<*>

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc