mirror of
https://github.com/directus/directus.git
synced 2026-01-30 06:58:09 -05:00
* Document and structure utils / compositions * Fix tests * Ignore tests in sonar cloud? * Please sonar don't use my test files
isEmpty / notEmpty
Checks if the given value is null or undefined. Can be used in place of a simple "truthy" check:
Before: if (value) { ... }
After: `if (notEmpty(value)) { ... }
Usage
const a = undefined;
const b = null;
const c = 'test';
const d = 42;
const e = [];
const f = {};
isEmpty(a); // true
isEmpty(b); // true
isEmpty(c); // false
isEmpty(d); // false
isEmpty(e); // false
isEmpty(f); // false
notEmpty(a); // false
notEmpty(b); // false
notEmpty(c); // true
notEmpty(d); // true
notEmpty(e); // true
notEmpty(f); // true