🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

callback.flow

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

callback.flow

callback interface definition for use with flow code bases

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

callback.flow

travis package downloads styled with prettier

Just Callback<x, a> interface definition for use with flow projects that interface with nodejs callback based APIs. Callback<x, a> is a function that can be used to report success or failure of the async operation:

If operation is succeeds callback must be invoked with two arguments first of type either null|void and second of type a - callback(null, value)

If operation is fails callback must be invoked with single argument of type x - callback(error)

Please note that success type paramater is optional and defaults to void there for callbacks that don't pass data back can be typed as Callback<string> and also be invoked as callback() to report success and callback('Oops') to report failure.

Usage

import type { Callback } from "callback.flow"

export const readAsync = (
  address: string,
  callback: Callback<Error, string>
): void => {
  if (isValid(address)) {
    // ....
    callback(null, content)
  } else {
    callback(new Error("Invalid Address"))
  }
}

Install

npm install callback.flow

Keywords

callback.flow

FAQs

Package last updated on 10 Jan 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