UNPKG

4.26 kBHTMLView Raw
1<!doctype html>
2<html>
3
4<head>
5 <meta name="generator" content="JSDoc 3.6.2">
6 <meta charset="utf-8">
7 <title>keyu 2.0.0 &raquo; Source: types/index.js</title>
8 <link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Karla:400,400i,700,700i" type="text/css">
9 <link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Noto+Serif:400,400i,700,700i" type="text/css">
10 <link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
11 <link href="css/baseline.css" rel="stylesheet">
12</head>
13
14<body onload="prettyPrint()">
15 <nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
16 <div id="jsdoc-navbar-container">
17 <div id="jsdoc-navbar-content">
18 <a href="index.html" class="jsdoc-navbar-package-name">keyu 2.<wbr>0.<wbr>0</a>
19 </div>
20 </div>
21 </nav>
22 <div id="jsdoc-body-container">
23 <div id="jsdoc-content">
24 <div id="jsdoc-content-container">
25 <div id="jsdoc-banner" role="banner">
26 </div>
27 <div id="jsdoc-main" role="main">
28 <header class="page-header">
29 <h1>Source: types/index.js</h1>
30 </header>
31 <article>
32 <pre class="prettyprint linenums"><code>/** @module types */
33
34/** Checks **correctly** if the passed type is or not a **number**
35 * @argument {*} num any possible data type
36 * @returns {boolean} indicating if is a number or not
37 * @example
38 * isNumber(null) // -&gt; false note isNaN(null) will return false instead
39 * @see [typesTest.js](https://github.com/nerac/keyu/blob/master/test/typesTest.js)
40 * @method
41 */
42const isNumber &#x3D; num &#x3D;&gt; !isNaN(num) &amp;amp;&amp;amp; num !&#x3D;&#x3D; null;
43
44/** Checks **correctly** if the passed type is or not an **object**
45 * @argument {*} num any possible data type
46 * @returns {boolean} indicating if it&#x27;s an object or not
47 * @example
48 * isObject(null) // -&gt; false note that typeof will return true
49 * isObject({}) // -&gt; true
50 * isObject(new Error()) // -&gt; true
51 * @see [typesTest.js](https://github.com/nerac/keyu/blob/master/test/typesTest.js)
52 * @method
53 */
54const isObject &#x3D; obj &#x3D;&gt; typeof obj &#x3D;&#x3D;&#x3D; &#x27;object&#x27; &amp;amp;&amp;amp; !Array.isArray(obj) &amp;amp;&amp;amp; obj !&#x3D;&#x3D; null;
55
56/** Checks if the passed type is a non defined value, either &#x60;undefined&#x60; or &#x60;null&#x60;
57 * @argument {*} num any possible data type
58 * @returns {boolean} indicating if it&#x27;s an non defined
59 * @example
60 * isNil(null) // -&gt; true
61 * isNil(3) // -&gt; false
62 * isNil() // -&gt; true
63 * isNil(undefined) // -&gt; true
64 * @see [typesTest.js](https://github.com/nerac/keyu/blob/master/test/typesTest.js)
65 * @method
66 */
67const isNil &#x3D; value &#x3D;&gt; typeof value &#x3D;&#x3D;&#x3D; &#x27;undefined&#x27; || value &#x3D;&#x3D;&#x3D; null;
68
69/** Returns the name of the function in which is called.
70 * @argument {String} [defaultValue] string for unknown calls.
71 * @returns {String} indicating the possible name of the function
72 * @example
73 * const hello &#x3D; () &#x3D;&gt; getFuncName()
74 * hello() // -&gt; &quot;hello&quot;
75 * getFuncName() // -&gt; &quot;Unknown&quot;
76 * getFuncName(&quot;ups&quot;) // -&gt; &quot;ups&quot;
77 * @see [typesTest.js](https://github.com/nerac/keyu/blob/master/test/typesTest.js)
78 * @method
79 */
80function getFuncName(defaultValue &#x3D; &#x27;Unknown&#x27;) {
81 return (getFuncName.caller &amp;amp;&amp;amp; getFuncName.caller.name) || defaultValue;
82}
83
84module.exports &#x3D; { isNumber, isObject, isNil, getFuncName };
85</code></pre>
86 </article>
87 </div>
88 </div>
89 <nav id="jsdoc-toc-nav" role="navigation"></nav>
90 </div>
91 </div>
92 <footer id="jsdoc-footer" class="jsdoc-footer">
93 <div id="jsdoc-footer-container">
94 <p>
95 Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.2 on June 17, 2019.
96 </p>
97 </div>
98 </footer>
99 <script src="scripts/jquery.min.js"></script>
100 <script src="scripts/jquery.cookie.js"></script>
101 <script src="scripts/tree.jquery.js"></script>
102 <script src="scripts/prettify.js"></script>
103 <script src="scripts/jsdoc-toc.js"></script>
104 <script src="scripts/linenumber.js"></script>
105 <script src="scripts/scrollanchor.js"></script>
106</body>
107
108</html>
\No newline at end of file