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

@partially-applied/flip

v1.0.0

Published

flip all arguments

Downloads

1

Readme

flip :: (a -> b -> c ...... x -> y -> z) -> (z -> y -> x ...... c -> b -> a)

###Install

npm install @partially-applied/flip

###Usage


flip = require '@partially-applied/flip'

f = (a,b,c) -> (a + b)*c # generic functions

opposite = flip f

f 1,2,3 # (1 + 2)*3 = 9

opposite 1,2,3 # (3 + 2)*1 = 5

# curried by default 

flip f,1,2,3 # (3 + 2)*1 = 5

only-a = opposite 1 # [Function]

only-a-b = only-a 2 # [Function]

only-a-b 3 # (3 + 2)*1 = 5

Why

  1. Ramda flip only flips the first two arguments.

  2. flip was written to bring another API change to Ramda. Ramda compose composes a function from right to left.


_ = require 'ramda'

f = _.curry (x,y) -> x + y

g = _.curry (x,y) -> x*y

h = _.compose (f 1),(g 2) # h = (x) -> 2*x + 1

h 5 # 11

flip = require '@partially-applied/flip'


j = (flip _.compose) (f 1),(g 2) # j = (x) -> (1 + x)*2 

j 5  # 12

why would we need to shift the order of compose ?

good question, it is to assist in using livescript do syntax:


_ = require 'ramda'

flip = requre '@partially-applied/flip'

compose = flip _.compose

add = _.curry (x,y) -> x + y

multiply = _.curry (x,y) -> x*y

h = compose do
    add 1
    multiply 2
    add 2
    multiply 4
    add 3


h # h = (x) -> ((1 + x)*2 + 2)*4 + 3

For more information about why use compose or ramda I suggest reading Chapter 5:Coding by Compose