🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

drainpipe

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

drainpipe

utility for piping a value through a chain of functions

0.1.4
latest
Source
npm
Version published
Maintainers
1
Created
Source

drainpipe

Build Status

utility for piping a value through a chain of functions

vv(23)
  (v => v * 2)
  (v => v + 2)
  (v => console.log(v))
// =>
48

api

vv(x)

Takes in a value and starts a chain.

vv(x)(fn[, arg1[, arg2[, ...]]])

Takes in a function and optional extra arguments, calls the function with the current value in the drainpipe chain and stores its result as the new value in the drainpipe chain.

function add(a, b) {
  return a + b
}

vv(23)
  (add, 1)
  (add, 3)
  (v => console.log(v)) // 27

vv(x)()

Returns the current value in the drainpipe chain

var x = vv(23)
  (v => v * 2)
  (v => v + 2)
  ()

console.log(x) // 48

install

You can use this library as the npm package drainpipe:

npm i drainpipe
# or
yarn add drainpipe

It can be used in both es-module-aware and commonjs bundlers/environments.

// es module
import vv from 'drainpipe'

// commonjs
const vv = require('drainpipe')

It can also be used a <script>:

<script
  crossorigin
  src="https://unpkg.com/drainpipe/dist/umd/drainpipe.js"
></script>

<script>
  vv(23)(v => console.log(v))
</script>

Keywords

chain

FAQs

Package last updated on 27 May 2020

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