source: node_modules/ramda-adjunct/src/isBlank.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 1.1 KB
RevLine 
[d24f17c]1import { isEmpty, isNil, anyPass, test } from 'ramda';
2
3import isFalse from './isFalse';
4/**
5 * Returns `true` if the given value is its type's empty value, `false`, `undefined`
6 * as well as strings containing only whitespace characters; `false` otherwise.
7 *
8 * @func isBlank
9 * @memberOf RA
10 * @since {@link https://char0n.github.io/ramda-adjunct/3.1.0|v3.1.0}
11 * @category Type
12 * @sig * -> Boolean
13 * @param {*} val The value to test
14 * @return {boolean}
15 * @see {@link https://blog.appsignal.com/2018/09/11/differences-between-nil-empty-blank-and-present.html|Differences Between #nil?, #empty?, #blank?, and #present?}
16 * @example
17 *
18 * RA.isBlank(''); //=> true
19 * RA.isBlank(' '); //=> true
20 * RA.isBlank('\t\n'); //=> true
21 * RA.isBlank({}); //=> true
22 * RA.isBlank(null); //=> true
23 * RA.isBlank(undefined); //=> true
24 * RA.isBlank([]); //=> true
25 * RA.isBlank(false); //=> true
26 * RA.isBlank('value'); //=> false
27 * RA.isBlank({ foo: 'foo' }); //=> false
28 * RA.isBlank([1, 2, 3]); //=> false
29 * RA.isBlank(true); //=> false
30 */
31const isBlank = anyPass([isFalse, isNil, isEmpty, test(/^\s+$/gm)]);
32
33export default isBlank;
Note: See TracBrowser for help on using the repository browser.