UNPKG

872 BJavaScriptView Raw
1var _curry3 =
2/*#__PURE__*/
3require("./internal/_curry3");
4/**
5 * Takes a predicate, a transformation function, and an initial value,
6 * and returns a value of the same type as the initial value.
7 * It does so by applying the transformation until the predicate is satisfied,
8 * at which point it returns the satisfactory value.
9 *
10 * @func
11 * @memberOf R
12 * @since v0.20.0
13 * @category Logic
14 * @sig (a -> Boolean) -> (a -> a) -> a -> a
15 * @param {Function} pred A predicate function
16 * @param {Function} fn The iterator function
17 * @param {*} init Initial value
18 * @return {*} Final value that satisfies predicate
19 * @example
20 *
21 * R.until(R.gt(R.__, 100), R.multiply(2))(1) // => 128
22 */
23
24
25var until =
26/*#__PURE__*/
27_curry3(function until(pred, fn, init) {
28 var val = init;
29
30 while (!pred(val)) {
31 val = fn(val);
32 }
33
34 return val;
35});
36
37module.exports = until;
\No newline at end of file