main
Last change
on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
984 bytes
|
Line | |
---|
1 | var curryN =
|
---|
2 | /*#__PURE__*/
|
---|
3 | require("./curryN.js");
|
---|
4 |
|
---|
5 | var _curry1 =
|
---|
6 | /*#__PURE__*/
|
---|
7 | require("./internal/_curry1.js");
|
---|
8 | /**
|
---|
9 | * Creates a thunk out of a function. A thunk delays a calculation until
|
---|
10 | * its result is needed, providing lazy evaluation of arguments.
|
---|
11 | *
|
---|
12 | * @func
|
---|
13 | * @memberOf R
|
---|
14 | * @since v0.26.0
|
---|
15 | * @category Function
|
---|
16 | * @sig ((a, b, ..., j) -> k) -> (a, b, ..., j) -> (() -> k)
|
---|
17 | * @param {Function} fn A function to wrap in a thunk
|
---|
18 | * @return {Function} Expects arguments for `fn` and returns a new function
|
---|
19 | * that, when called, applies those arguments to `fn`.
|
---|
20 | * @see R.partial, R.partialRight
|
---|
21 | * @example
|
---|
22 | *
|
---|
23 | * R.thunkify(R.identity)(42)(); //=> 42
|
---|
24 | * R.thunkify((a, b) => a + b)(25, 17)(); //=> 42
|
---|
25 | */
|
---|
26 |
|
---|
27 |
|
---|
28 | var thunkify =
|
---|
29 | /*#__PURE__*/
|
---|
30 | _curry1(function thunkify(fn) {
|
---|
31 | return curryN(fn.length, function createThunk() {
|
---|
32 | var fnArgs = arguments;
|
---|
33 | return function invokeThunk() {
|
---|
34 | return fn.apply(this, fnArgs);
|
---|
35 | };
|
---|
36 | });
|
---|
37 | });
|
---|
38 |
|
---|
39 | module.exports = thunkify; |
---|
Note:
See
TracBrowser
for help on using the repository browser.