MCPcopy Create free account
hub / github.com/rollup/plugins / isTruthy

Function isTruthy

packages/commonjs/src/ast-utils.js:44–50  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

42}
43
44export function isTruthy(node) {
45 if (!node) return false;
46 if (node.type === 'Literal') return !!node.value;
47 if (node.type === 'ParenthesizedExpression') return isTruthy(node.expression);
48 if (node.operator in operators) return operators[node.operator](node);
49 return null;
50}
51
52export function isFalsy(node) {
53 return not(isTruthy(node));

Callers 5

enterFunction · 0.90
ast-utils.jsFile · 0.85
isFalsyFunction · 0.85
getDefineCompiledEsmTypeFunction · 0.85
hasDefineEsmPropertyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected