@monstermann/fn
Version:
A utility library for TypeScript.
26 lines (24 loc) • 485 B
JavaScript
import { dfdlT } from "@monstermann/dfdl";
//#region src/function/isTruthy.ts
/**
* `isTruthy(target)`
*
* Checks if a value is truthy (not false, 0, "", null, or undefined).
*
* ```ts
* isTruthy("hello"); // true
* isTruthy(1); // true
* isTruthy(false); // false
* isTruthy(""); // false
* ```
*
* ```ts
* pipe("hello", isTruthy()); // true
* pipe(false, isTruthy()); // false
* ```
*/
const isTruthy = dfdlT((target) => {
return !!target;
}, 1);
//#endregion
export { isTruthy };