Files
directus/src/utils/is-empty
Rijk van Zanten 68c625ec79 Document and structure utils / compositions (#168)
* Document and structure utils / compositions

* Fix tests

* Ignore tests in sonar cloud?

* Please sonar don't use my test files
2020-03-12 12:31:36 -04:00
..

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