|
1 |
| -<!DOCTYPE html> |
2 |
| -<html lang="en"> |
3 |
| -<head> |
4 |
| - |
5 |
| - <meta charset="utf-8"> |
6 |
| - <title>isEmpty.js - Documentation</title> |
7 |
| - |
8 |
| - |
9 |
| - <script src="scripts/prettify/prettify.js"></script> |
10 |
| - <script src="scripts/prettify/lang-css.js"></script> |
11 |
| - <!--[if lt IE 9]> |
12 |
| - <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> |
13 |
| - <![endif]--> |
14 |
| - <link type="text/css" rel="stylesheet" href="styles/prettify.css"> |
15 |
| - <link type="text/css" rel="stylesheet" href="styles/jsdoc.css"> |
16 |
| -</head> |
17 |
| -<body> |
18 |
| - |
19 |
| -<input type="checkbox" id="nav-trigger" class="nav-trigger" /> |
20 |
| -<label for="nav-trigger" class="navicon-button x"> |
21 |
| - <div class="navicon"></div> |
22 |
| -</label> |
23 |
| - |
24 |
| -<label for="nav-trigger" class="overlay"></label> |
25 |
| - |
26 |
| -<nav> |
27 |
| - |
28 |
| - <input type="text" id="nav-search" placeholder="Search" /> |
29 |
| - |
30 |
| - <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#isEmpty">isEmpty</a></li></ul> |
31 |
| -</nav> |
32 |
| - |
33 |
| -<div id="main"> |
34 |
| - |
35 |
| - <h1 class="page-title">isEmpty.js</h1> |
36 |
| - |
37 |
| - |
38 |
| - |
39 |
| - |
40 |
| - |
41 |
| - |
42 |
| - |
43 |
| - <section> |
44 |
| - <article> |
45 |
| - <pre class="prettyprint source linenums"><code>const debug = require('debug')('isEmpty') |
46 |
| - |
47 |
| -/** |
48 |
| - * @description Check if parameter is empty |
49 |
| - * |
50 |
| - * 'empty' means |
51 |
| - * - an empty string |
52 |
| - * - an empty array |
53 |
| - * - an empty object (**allow `new Proxy({}, {})`**) |
54 |
| - * - null |
55 |
| - * - undefined |
56 |
| - * @param {object} value parameter |
57 |
| - * @returns {boolean} |
58 |
| - */ |
59 |
| -const isEmpty = (value) => { |
60 |
| - debug('value', value) |
61 |
| - debug('typeof value', typeof value) |
62 |
| - debug('Object.keys(value).length', value && Object.keys(value).length) |
63 |
| - debug('Object.getOwnPropertyNames()', value && Object.getOwnPropertyNames(value)) |
64 |
| - debug('value.constructor.name', value && value.constructor && value.constructor.name) |
65 |
| - |
66 |
| - if (value === null) return true |
67 |
| - if (typeof value === 'undefined') return true |
68 |
| - if (typeof value === 'string' && value === '') return true |
69 |
| - if (Array.isArray(value) && value.length < 1) return true |
70 |
| - if (typeof value === 'object' && value.constructor.name === 'Object' && Object.keys(value).length < 1 && Object.getOwnPropertyNames(value) < 1) return true |
71 |
| - |
72 |
| - if (typeof value === 'object' && value.constructor.name === 'String' && Object.keys(value).length < 1) return true // new String() |
73 |
| - |
74 |
| - debug('isEmpty false') |
75 |
| - return false |
76 |
| -} |
77 |
| - |
78 |
| -module.exports = isEmpty</code></pre> |
79 |
| - </article> |
80 |
| - </section> |
81 |
| - |
82 |
| - |
83 |
| - |
84 |
| - |
85 |
| - |
86 |
| - |
87 |
| -</div> |
88 |
| - |
89 |
| -<br class="clear"> |
90 |
| - |
91 |
| -<footer> |
92 |
| - Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.2</a> using the <a href="https://github.com/clenemt/docdash">docdash</a> theme. |
93 |
| -</footer> |
94 |
| - |
95 |
| -<script>prettyPrint();</script> |
96 |
| -<script src="scripts/linenumber.js"></script> |
97 |
| - |
98 |
| -<script src="scripts/jquery-3.1.1.min.js"></script> |
99 |
| - |
100 |
| -<script src="scripts/search.js"></script> |
101 |
| - |
102 |
| - |
103 |
| -<script src="scripts/collapse.js"></script> |
104 |
| - |
105 |
| - |
106 |
| - |
107 |
| -</body> |
108 |
| -</html> |
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + |
| 5 | + <meta charset="utf-8"> |
| 6 | + <title>empty.js - Documentation</title> |
| 7 | + |
| 8 | + |
| 9 | + <script src="scripts/prettify/prettify.js"></script> |
| 10 | + <script src="scripts/prettify/lang-css.js"></script> |
| 11 | + <!--[if lt IE 9]> |
| 12 | + <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> |
| 13 | + <![endif]--> |
| 14 | + <link type="text/css" rel="stylesheet" href="styles/prettify.css"> |
| 15 | + <link type="text/css" rel="stylesheet" href="styles/jsdoc.css"> |
| 16 | +</head> |
| 17 | +<body> |
| 18 | + |
| 19 | +<input type="checkbox" id="nav-trigger" class="nav-trigger" /> |
| 20 | +<label for="nav-trigger" class="navicon-button x"> |
| 21 | + <div class="navicon"></div> |
| 22 | +</label> |
| 23 | + |
| 24 | +<label for="nav-trigger" class="overlay"></label> |
| 25 | + |
| 26 | +<nav> |
| 27 | + |
| 28 | + <input type="text" id="nav-search" placeholder="Search" /> |
| 29 | + |
| 30 | + <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-is.html">is</a><ul class='methods'><li data-type='method' style='display: none;'><a href="module-is.html#~empty">empty</a></li></ul></li></ul> |
| 31 | +</nav> |
| 32 | + |
| 33 | +<div id="main"> |
| 34 | + |
| 35 | + <h1 class="page-title">empty.js</h1> |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | + <section> |
| 44 | + <article> |
| 45 | + <pre class="prettyprint source linenums"><code>const debug = require('debug')('empty') |
| 46 | +/** |
| 47 | + * @module is |
| 48 | + * @author sanghak,Lee < [email protected]> |
| 49 | + */ |
| 50 | + |
| 51 | +/** |
| 52 | + * @description Check if parameter is empty. |
| 53 | + * |
| 54 | + * 'empty' means |
| 55 | + * - an empty string |
| 56 | + * - an empty array |
| 57 | + * - an empty object (**allow `new Proxy({}, {})`**) |
| 58 | + * - null |
| 59 | + * - undefined |
| 60 | + * @param {object} value parameter |
| 61 | + * @returns {boolean} |
| 62 | + * @example |
| 63 | + * const is = require('is-0') |
| 64 | + * is.empty('') // true |
| 65 | + * is.empty(1) // false |
| 66 | + */ |
| 67 | +const empty = (value) => { |
| 68 | + debug('value', value) |
| 69 | + debug('typeof value', typeof value) |
| 70 | + debug('Object.keys(value).length', value && Object.keys(value).length) |
| 71 | + debug('Object.getOwnPropertyNames()', value && Object.getOwnPropertyNames(value)) |
| 72 | + debug('value.constructor.name', value && value.constructor && value.constructor.name) |
| 73 | + |
| 74 | + if (value === null) return true |
| 75 | + if (typeof value === 'undefined') return true |
| 76 | + if (typeof value === 'string' && value === '') return true |
| 77 | + if (Array.isArray(value) && value.length < 1) return true |
| 78 | + if (typeof value === 'object' && value.constructor.name === 'Object' && Object.keys(value).length < 1 && Object.getOwnPropertyNames(value) < 1) return true |
| 79 | + |
| 80 | + if (typeof value === 'object' && value.constructor.name === 'String' && Object.keys(value).length < 1) return true // new String() |
| 81 | + |
| 82 | + debug('isEmpty false') |
| 83 | + return false |
| 84 | +} |
| 85 | + |
| 86 | +module.exports = empty</code></pre> |
| 87 | + </article> |
| 88 | + </section> |
| 89 | + |
| 90 | + |
| 91 | + |
| 92 | + |
| 93 | + |
| 94 | + |
| 95 | +</div> |
| 96 | + |
| 97 | +<br class="clear"> |
| 98 | + |
| 99 | +<footer> |
| 100 | + Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.2</a> using the <a href="https://github.com/clenemt/docdash">docdash</a> theme. |
| 101 | +</footer> |
| 102 | + |
| 103 | +<script>prettyPrint();</script> |
| 104 | +<script src="scripts/linenumber.js"></script> |
| 105 | + |
| 106 | +<script src="scripts/jquery-3.1.1.min.js"></script> |
| 107 | + |
| 108 | +<script src="scripts/search.js"></script> |
| 109 | + |
| 110 | + |
| 111 | +<script src="scripts/collapse.js"></script> |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | +</body> |
| 116 | +</html> |
0 commit comments