npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@sullux/fp-light-tap

v0.0.2

Published

A lightweight functional library for functional composition and object composition.

Downloads

10

Readme

home

fp-light-tap

npm i @sullux/fp-light-tap
source
test

A tap is a function that wraps a side-effect such that the return value of the tap is always the same as the input value.

tap

tap<T>((aside: any) => T): (T) => T

Aliases: aside, dispatch

Creates a function that calls the wrapped function but always returns the original argument. The return value of the wrapped function is ignored. NOTE: if the return value of the wrapped function is thennable, tap will return a promise that awaits the thennable and resolves to the original value.

const { tap } = require('@sullux/fp-light-tap')
const { strictEqual } = require('assert')

describe('tap', () => {
  it('should call the wrapped function', () => {
    let mutable
    tap(v => { mutable = v })(42)
    strictEqual(mutable, 42)
  })
  it('should return the input value', () =>
    strictEqual(tap(() => 7)(42), 42))
  it('should return a promise resolving to the input value', () =>
    tap(v => Promise.resolve(7))(42)
      .then(v => strictEqual(v, 42)))
})

Or a somewhat practical example of an s3Bucket implementation with a putObject function:

const { curry } = require('@sullux/fp-light-curry')
const { tap } = require('@sullux/fp-light-tap')
const { pipe } = require('@sullux/fp-light-pipe')

const s3 = new (require('aws-sdk')).S3

const putObjectParams = curry((bucket, { key, data }) => ({
  Bucket: bucket,
  Key: key,
  Data: JSON.stringify(data),
}))

const putObject = params => 
  s3.putObject(params).promise()

const s3Bucket = (bucket) => ({
  putObject: pipe(
    putObjectParams(bucket),
    tap(console.log),
    putObject,
    tap(console.log),
  ),
})