Socket
Socket
Sign inDemoInstall

pipeable

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    pipeable

This package help you to execute functions and pipe the result of that function has first parameter of the next function. Something like pipe operator on Erlang, Elixir or others functional programming languages.


Version published
Maintainers
1
Created

Readme

Source

Pipeable

This package help you to execute functions and pipe the result of that function has first parameter of the next function. Something like pipe operator on Erlang, Elixir or others functional programming languages.

This is a very little library, that all this is a currying function.

After do some benchmark y create the same functionality using classes, because classes are more fast.

With functions x 20,242 ops/sec ±6.54% (70 runs sampled)
With Classes x 381,338 ops/sec ±5.22% (70 runs sampled)

New sintax for the class

var _pipe = require('pipeable').default

var result = _pipe([1,2,3])
  .pipe(function(value) {
    return value.map(function(item) {
      return item + item
    })
  })
  .result() // return => [2,4,6]

Example using the old function pipe

var _pipe = require('pipeable').Pipeable

var arrayPiped = _pipe([1,2,3]) // return a Pipe function that carry the array [1,2,3]

var arrayMaped = arrayPiped(function(value) {
  return value.map(function(item) {
    return item + item
  })
}) // return a Pipe function that carry the result of the map

arrayMaped() // return the value of the currying => [2,4,6]
Can be used chaining functions
_pipe([1,2,3])(function(value) {
  return value.map(function(item) {
    return item + item
  })
})() // return the value of the currying => [2,4,6]

Keywords

FAQs

Last updated on 16 Nov 2015

Did you know?

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

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc