How to use the clamp function from ramda

Find comprehensive JavaScript ramda.clamp code examples handpicked from public code repositorys.

1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
 * @param {Number} maximum number
 * @param {Number} value to be clamped
 * @return {Number} Returns the clamped value
 * @example
 *
 *      R.clamp(1, 10, -1) // => 1
 *      R.clamp(1, 10, 11) // => 10
 *      R.clamp(1, 10, 4)  // => 4
 */
var clamp = _curry3(function clamp(min, max, value) {
fork icon0
star icon0
watch icon0

+ 53 other calls in file

1415
1416
1417
1418
1419
1420
1421
1422
1423
* @param {Number} maximum The upper limit of the clamp (inclusive)
* @param {Number} value Value to be clamped
* @return {Number} Returns `minimum` when `val < minimum`, `maximum` when `val > maximum`, returns `val` otherwise
* @example
*
*      R.clamp(1, 10, -5) // => 1
*      R.clamp(1, 10, 15) // => 10
*      R.clamp(1, 10, 4)  // => 4
*/
fork icon0
star icon0
watch icon2

+ 11 other calls in file

8
9
10
11
12
13
14
15
16
17
18
19
const transactionBytes = (inputs, outputs) =>
  Coin.TX_EMPTY_SIZE + inputs.reduce((a, c) => a + Coin.inputBytes(c), 0) + outputs.reduce((a, c) => a + Coin.outputBytes(c), 0);


const effectiveBalance = curry((feePerByte, inputs, outputs = [{}]) =>
  foldCoins(inputs).map(v =>
    clamp(0, Infinity, v - transactionBytes(inputs, outputs) * feePerByte))
);


// findTarget :: [Coin] -> Number -> [Coin] -> String -> Selection
const findTarget = (targets, feePerByte, coins, changeAddress) => {
fork icon0
star icon0
watch icon0

Other functions in ramda

Sorted by popularity

function icon

ramda.clone is the most popular function in ramda (30311 examples)