-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjs-partial-is-empty-string.js
More file actions
54 lines (49 loc) · 1.79 KB
/
js-partial-is-empty-string.js
File metadata and controls
54 lines (49 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
|----------------------------------------------------------------------------------------------------------------------
| A partial to check whether a string is empty.
|----------------------------------------------------------------------------------------------------------------------
*/
/**
* More information on [JavaScript Open Standards]{@link https://github.com/jsopenstd/jsopenstd}.
*
* @namespace js.partial
* @version 0.0.1
*
* @author Richard King <richrdkng@gmail.com> [GitHub]{@link https://github.com/richrdkng}
* @license [MIT]{@link https://github.com/jsopenstd/js-partial-foreach/blob/master/license.md}
*/
/**
* UMD - [returnExports.js pattern]{@link https://github.com/umdjs/umd/blob/master/templates/returnExports.js}
* For more information and license, check the link below:
* [UMD GitHub Repository]{@link https://github.com/umdjs/umd}
*/
(function(root, factory) {
// AMD
/* istanbul ignore next: ignore coverage test for UMD */
if (typeof define === 'function' && define.amd) {
define([], factory);
// CommonJS
} else if (typeof module === 'object' && module.exports) {
module.exports = factory();
// Browser
} else {
root.js_partial_isEmptyString = factory();
}
}(this, function() {
'use strict';
/**
* Determines whether a string is empty.
* A string is considered empty or blank, when its **.length === 0**, or it **contains only whitespaces**.
*
* @memberOf js.partial
* @function isEmptyString
*
* @param {string} string - The string to check.
*
* @returns {boolean} If the string is empty or blank, it will return true.
*/
return function isEmptyString(string) {
return string.length === 0 ||
/^\s+$/.test(string) === true;
};
}));