Skip to main content

stubTrue()

stubTrue(): true

Returns true.

DEPRECATED

Use an inline arrow function () => true instead.


Returns: trueโ€‹

true.


Sinceโ€‹

2.0.0


Also known asโ€‹

T (Ramda) ยท stubTrue (Lodash, es-toolkit) ยท โŒ (Remeda, Radashi, Effect, Modern Dash, Antfu)


Exampleโ€‹

// โŒ Deprecated approach
stubTrue(); // => true

// โœ… Recommended approach
(() => true)(); // => true

How it works?โ€‹

Returns true. Deprecated: Use () => true directly.

Native Equivalentโ€‹

// โŒ stubTrue
// โœ… () => true

Use Casesโ€‹

Return true ๐Ÿ“Œโ€‹

Return true as default.

const alwaysTrue = () => true;

Enable by defaultโ€‹

Default to enabled state.

const isEnabled = config.feature ?? true;