source: node_modules/ramda/es/until.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 855 bytes
RevLine 
[d24f17c]1import _curry3 from "./internal/_curry3.js";
2/**
3 * Takes a predicate, a transformation function, and an initial value,
4 * and returns a value of the same type as the initial value.
5 * It does so by applying the transformation until the predicate is satisfied,
6 * at which point it returns the satisfactory value.
7 *
8 * @func
9 * @memberOf R
10 * @since v0.20.0
11 * @category Logic
12 * @sig (a -> Boolean) -> (a -> a) -> a -> a
13 * @param {Function} pred A predicate function
14 * @param {Function} fn The iterator function
15 * @param {*} init Initial value
16 * @return {*} Final value that satisfies predicate
17 * @example
18 *
19 * R.until(R.gt(R.__, 100), R.multiply(2))(1) // => 128
20 */
21
22var until =
23/*#__PURE__*/
24_curry3(function until(pred, fn, init) {
25 var val = init;
26
27 while (!pred(val)) {
28 val = fn(val);
29 }
30
31 return val;
32});
33
34export default until;
Note: See TracBrowser for help on using the repository browser.