mirror of
https://github.com/swc-project/swc.git
synced 2024-12-20 20:22:26 +03:00
bbaf619f63
swc_bundler: - [x] Fix wrapped esms. (denoland/deno#9307) - [x] Make test secure.
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
// Loaded from https://deno.land/x/ramda@v0.27.2/source/unless.js
|
|
|
|
|
|
import _curry3 from './internal/_curry3.js';
|
|
|
|
|
|
/**
|
|
* Tests the final argument by passing it to the given predicate function. If
|
|
* the predicate is not satisfied, the function will return the result of
|
|
* calling the `whenFalseFn` function with the same argument. If the predicate
|
|
* is satisfied, the argument is returned as is.
|
|
*
|
|
* @func
|
|
* @memberOf R
|
|
* @since v0.18.0
|
|
* @category Logic
|
|
* @sig (a -> Boolean) -> (a -> a) -> a -> a
|
|
* @param {Function} pred A predicate function
|
|
* @param {Function} whenFalseFn A function to invoke when the `pred` evaluates
|
|
* to a falsy value.
|
|
* @param {*} x An object to test with the `pred` function and
|
|
* pass to `whenFalseFn` if necessary.
|
|
* @return {*} Either `x` or the result of applying `x` to `whenFalseFn`.
|
|
* @see R.ifElse, R.when, R.cond
|
|
* @example
|
|
*
|
|
* let safeInc = R.unless(R.isNil, R.inc);
|
|
* safeInc(null); //=> null
|
|
* safeInc(1); //=> 2
|
|
*/
|
|
var unless = _curry3(function unless(pred, whenFalseFn, x) {
|
|
return pred(x) ? x : whenFalseFn(x);
|
|
});
|
|
export default unless;
|