New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

pipe-peek

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

pipe-peek

Peek into a functional pipeline to see intermediate results without interfering with the flow.

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

pipe-peek

Peek into a functional pipeline to see intermediate results without interfering with the flow.

Installation

yarn add pipe-peek

or if you prefer npm:

npm install --save pipe-peek

Usage

const peek = require(`pipe-peek`);
// or if you use ES6 module syntax:
import peek from 'pipe-peek';

const { add, multiply, pipe, subtract } = require(`lodash/fp`);

const fahrenheitToCelsius = pipe(
  subtract(32),
  multiply(5 / 9)
);

const celsiusToKelvin = add(273.15);

let fahrenheitToKelvin = pipe(
  fahrenheitToCelsius,
  peek, // Should console.log the temperature in Celsius
  celsiusToKelvin
);

fahrenheitToKelvin(32); // outputs 0 to the log
// => 273.15

You can also import the function peekWith by name. It differs from peek in that it expects a function as an argument and calls that function instead of console.log on the intermediate result.

Let's redefine fahrenheitToKelvin to demonstrate:

const { peekWith } = require(`pipe-peek`);
// or
import { peekWith } from 'pipe-peek';

fahrenheitToKelvin = pipe(
  fahrenheitToCelsius,
  peekWith(console.info), // Outputs temp in Celsius using console.info instead of console.log
  celsiusToKelvin
);

fahrenheitToKelvin = pipe(
  fahrenheitToCelsius,
  peekWith(celsius =>
    console.log(`The temperature in Celsius is ${celsius}`),
  ),
  celsiusToKelvin
);

TODO:

  • Improve README
  • Add ESLint
  • Add tests (?)

FAQs

Package last updated on 06 Apr 2017

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