Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
just-curry-it
Advanced tools
The just-curry-it npm package is a utility for currying functions. Currying is a functional programming technique where a function with multiple arguments is transformed into a sequence of functions each taking a single argument. This package simplifies the process of currying functions in JavaScript.
Basic Currying
This feature allows you to transform a function that takes multiple arguments into a curried function. The curried function can then be called with one argument at a time, or with multiple arguments at once.
const curry = require('just-curry-it');
function add(a, b, c) {
return a + b + c;
}
const curriedAdd = curry(add);
console.log(curriedAdd(1)(2)(3)); // 6
console.log(curriedAdd(1, 2)(3)); // 6
console.log(curriedAdd(1)(2, 3)); // 6
Partial Application
This feature allows for partial application of functions. You can fix some arguments of the function and get a new function that takes the remaining arguments.
const curry = require('just-curry-it');
function multiply(a, b, c) {
return a * b * c;
}
const curriedMultiply = curry(multiply);
const multiplyBy2 = curriedMultiply(2);
console.log(multiplyBy2(3, 4)); // 24
console.log(multiplyBy2(3)(4)); // 24
Lodash is a popular utility library that provides a wide range of functions for common programming tasks, including currying. The `_.curry` method in Lodash offers similar functionality to just-curry-it but comes with the added benefit of a comprehensive suite of other utilities.
Ramda is a functional programming library for JavaScript that emphasizes immutability and side-effect-free functions. It provides a `R.curry` function that offers currying capabilities similar to just-curry-it, but it is part of a larger set of functional programming tools.
The `curry` package is a lightweight utility specifically designed for currying functions. It offers similar functionality to just-curry-it but is focused solely on currying without additional utilities.
Part of a library of zero-dependency npm modules that do just do one thing. Guilt-free utilities for every occasion.
npm install just-curry-it
yarn add just-curry-it
Return a curried function
import curry from 'just-curry-it';
function add(a, b, c) {
return a + b + c;
}
curry(add)(1)(2)(3); // 6
curry(add)(1)(2)(2); // 5
curry(add)(2)(4, 3); // 9
function add(...args) {
return args.reduce((sum, n) => sum + n, 0)
}
var curryAdd4 = curry(add, 4)
curryAdd4(1)(2, 3)(4); // 10
function converter(ratio, input) {
return (input*ratio).toFixed(1);
}
const curriedConverter = curry(converter)
const milesToKm = curriedConverter(1.62);
milesToKm(35); // 56.7
milesToKm(10); // 16.2
FAQs
return a curried function
The npm package just-curry-it receives a total of 278,177 weekly downloads. As such, just-curry-it popularity was classified as popular.
We found that just-curry-it demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.