Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 16829b2
Showing
3 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# mcflurry | ||
|
||
destructuring an object in function arguments is fun and v flexible, but it | ||
means you can't build up the arguments over time using `curry()` and v sad. | ||
|
||
so mcflurry lets you do this | ||
|
||
```js | ||
const mcflurry = require('mcflurry') | ||
const objectLog = mcflurry(console.log) | ||
objectLog({a: 22})({b: 47})({c: 'dog', a: 1})() //=> {a:22, b:47, c:'dog'} | ||
``` | ||
|
||
yes unfortunately it can't magically know when the function is fully satisfied, | ||
the only way to do that would be to supply a list of the keys that needed to be | ||
present separately as strings. that seemed more gross. | ||
|
||
ruby has `method(:lol).parameters` which would allow you to do it there, but not | ||
in js in any way i could think of | ||
|
||
so i've opted for calling it with no arguments when you're done | ||
|
||
anyway thanks everybody bye |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = mcflurry | ||
mcflurry.default = mcflurry | ||
|
||
function mcflurry(fn, object = {}) { | ||
return function(next) { | ||
const current = Object.assign({}, object, next) | ||
return next ? mcflurry(fn, current) : fn(current) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "mcflurry", | ||
"version": "0.0.74", | ||
"description": "build composeable functions using objects for keyword arguments", | ||
"main": "index.js", | ||
"repository": "git@gitlab.com:chee/mcflurry", | ||
"author": "chee <chee@snake.dog>", | ||
"license": "MIT" | ||
} |