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

fk

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

fk

A tiny curry library.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

fk

A tiny curry library.

Curry: fk()

A special kind of function currying.

If fewer than the expected number of arguments are supplied, then the function is partialled and re-curried.

If the exact number of arguments are supplied, then the curried function is applied with all the appropriate arguments and the result returned.

If more that the expected number of arguments are supplied, then the curried function is applied with the number of arguments it expects. The result of which is then expected to be a function and is applied the rest of the arguments.

Accepts an optional expected argument count - defaults to function.length.

@param f :: Function
@param _n :: Optional Nat

Example:

var f = fk(function (a, b) {
  return fk(function (c, d) {
    return [a, b, c, d]
  })
})

[1, 2, 3, 4]
= f(1, 2, 3, 4)
= f(1)(2, 3, 4)
= f(1, 2)(3, 4)
= f(1, 2, 3)(4)
= f(1, 2)(3)(4)
= f(1)(2, 3)(4)
= f(1)(2)(3, 4)
= f(1)(2)(3)(4)

Varargs: fk.vargs(f)

Convert a function that accepts an array to a variadic function.

Given a function f, produce a function that when applied, apply f with an array of all the arguments supplied.

@param f :: [*] -> a
@returns :: (...) -> a

Variadic Apply: fk.vapply(f, args)

Apply a function given an array of arguments.

@param f :: (...) -> a
@param args :: [*]
@returns a

Partial Apply: fk.papply(f, args)

Given a function f, and an array of arguments args; produce a function that when applied with nargs will apply f with the args prepended to nargs.

@param f :: (...) -> a
@param args :: [*]
@returns :: (...) -> a

Keywords

JavaScript

FAQs

Package last updated on 15 Oct 2014

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