https://github.com/stereobooster/curry-experiment
https://github.com/stereobooster/curry-experiment
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/stereobooster/curry-experiment
- Owner: stereobooster
- Created: 2020-11-30T22:13:51.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2020-11-30T22:42:27.000Z (over 4 years ago)
- Last Synced: 2025-02-11T14:47:19.233Z (4 months ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Currying reimagined
[Code for blogpost](https://stereobooster.com/posts/currying-reimagined/). This is just an experiment for fun - don't it use in production.
```js
const abc = ({ a, b, c }) => [a, b, c];const curried = curry(abc);
curried({ a: 1 })({ b: 2 })({ c: 3 });
// [1, 2, 3]
curried({ a: 1, b: 2 })({ c: 3 });
// [1, 2, 3]
curried({ a: 1, b: 2, c: 3 });
// [1, 2, 3]// In different order
curried({ c: 3 })({ b: 2 })({ a: 1 });
// [1, 2, 3]
curried({ c: 3, b: 2 })({ a: 1 });
// [1, 2, 3]// ...
```## See also
https://docs-lodash.com/v4/curry/
```js
var abc = function (a, b, c) {
return [a, b, c];
};var curried = _.curry(abc);
curried(1)(2)(3);
// => [1, 2, 3]curried(1, 2)(3);
// => [1, 2, 3]curried(1, 2, 3);
// => [1, 2, 3]// Curried with placeholders.
curried(1)(_, 3)(2);
// => [1, 2, 3]
```https://docs-lodash.com/v4/curry-right/
```js
var abc = function (a, b, c) {
return [a, b, c];
};var curried = _.curryRight(abc);
curried(3)(2)(1);
// => [1, 2, 3]curried(2, 3)(1);
// => [1, 2, 3]curried(1, 2, 3);
// => [1, 2, 3]// Curried with placeholders.
curried(3)(1, _)(2);
// => [1, 2, 3]
```