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:
985 bytes
|
Line | |
---|
1 | var _curry2 =
|
---|
2 | /*#__PURE__*/
|
---|
3 | require("./internal/_curry2.js");
|
---|
4 | /**
|
---|
5 | * Returns the second argument if it is not `null`, `undefined` or `NaN`;
|
---|
6 | * otherwise the first argument is returned.
|
---|
7 | *
|
---|
8 | * @func
|
---|
9 | * @memberOf R
|
---|
10 | * @since v0.10.0
|
---|
11 | * @category Logic
|
---|
12 | * @sig a -> b -> a | b
|
---|
13 | * @param {a} default The default value.
|
---|
14 | * @param {b} val `val` will be returned instead of `default` unless `val` is `null`, `undefined` or `NaN`.
|
---|
15 | * @return {*} The second value if it is not `null`, `undefined` or `NaN`, otherwise the default value
|
---|
16 | * @example
|
---|
17 | *
|
---|
18 | * const defaultTo42 = R.defaultTo(42);
|
---|
19 | *
|
---|
20 | * defaultTo42(null); //=> 42
|
---|
21 | * defaultTo42(undefined); //=> 42
|
---|
22 | * defaultTo42(false); //=> false
|
---|
23 | * defaultTo42('Ramda'); //=> 'Ramda'
|
---|
24 | * // parseInt('string') results in NaN
|
---|
25 | * defaultTo42(parseInt('string')); //=> 42
|
---|
26 | */
|
---|
27 |
|
---|
28 |
|
---|
29 | var defaultTo =
|
---|
30 | /*#__PURE__*/
|
---|
31 | _curry2(function defaultTo(d, v) {
|
---|
32 | return v == null || v !== v ? d : v;
|
---|
33 | });
|
---|
34 |
|
---|
35 | module.exports = defaultTo; |
---|
Note:
See
TracBrowser
for help on using the repository browser.