You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Isomorphic test suite by [test-runner](https://github.com/test-runner-js/test-runner) and [web-runner](https://github.com/test-runner-js/web-runner). Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).
205
+
Tested by [test-runner](https://github.com/test-runner-js/test-runner). Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).
Isomorphic test suite by [test-runner](https://github.com/test-runner-js/test-runner) and [web-runner](https://github.com/test-runner-js/web-runner). Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).
230
+
Tested by [test-runner](https://github.com/test-runner-js/test-runner). Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).
Copy file name to clipboardExpand all lines: dist/index.cjs
+52-21Lines changed: 52 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,5 @@
1
+
'use strict';
2
+
1
3
/**
2
4
* Takes any input and guarantees an array back.
3
5
*
@@ -60,15 +62,15 @@ function arrayify (input) {
60
62
* @module typical
61
63
* @typicalname t
62
64
* @example
63
-
* const t = require('typical')
65
+
* import * as t from 'typical'
64
66
* const allDefined = array.every(t.isDefined)
65
67
*/
66
68
67
69
/**
68
-
* Returns true if input is a number. It is a more reasonable alternative to `typeof n` which returns `number` for `NaN` and `Infinity`.
70
+
* Returns true if input is a number (including infinity). It is a more reasonable alternative to `typeof n` which returns `number` for `NaN`.
69
71
*
70
-
* @param {*} - the input to test
71
-
* @returns {boolean}
72
+
* @param {*} n - The input to test
73
+
* @returns {boolean} `true` if input is a number
72
74
* @static
73
75
* @example
74
76
* > t.isNumber(0)
@@ -86,16 +88,44 @@ function arrayify (input) {
86
88
* > t.isNumber(NaN)
87
89
* false
88
90
* > t.isNumber(Infinity)
89
-
* false
91
+
* true
90
92
*/
91
93
functionisNumber(n){
94
+
return!isNaN(parseFloat(n))
95
+
}
96
+
97
+
/**
98
+
* Returns true if input is a finite number. Identical to `isNumber` beside excluding infinity.
99
+
*
100
+
* @param {*} n - The input to test
101
+
* @returns {boolean}
102
+
* @static
103
+
* @example
104
+
* > t.isFiniteNumber(0)
105
+
* true
106
+
* > t.isFiniteNumber(1)
107
+
* true
108
+
* > t.isFiniteNumber(1.1)
109
+
* true
110
+
* > t.isFiniteNumber(0xff)
111
+
* true
112
+
* > t.isFiniteNumber(0644)
113
+
* true
114
+
* > t.isFiniteNumber(6.2e5)
115
+
* true
116
+
* > t.isFiniteNumber(NaN)
117
+
* false
118
+
* > t.isFiniteNumber(Infinity)
119
+
* false
120
+
*/
121
+
functionisFiniteNumber(n){
92
122
return!isNaN(parseFloat(n))&&isFinite(n)
93
123
}
94
124
95
125
/**
96
126
* A plain object is a simple object literal, it is not an instance of a class. Returns true if the input `typeof` is `object` and directly decends from `Object`.
97
127
*
98
-
* @param {*} - the input to test
128
+
* @param {*} input - The input to test
99
129
* @returns {boolean}
100
130
* @static
101
131
* @example
@@ -125,7 +155,7 @@ function isPlainObject (input) {
125
155
/**
126
156
* An array-like value has all the properties of an array yet is not an array instance. An example is the `arguments` object. Returns `true`` if the input value is an object, not `null`` and has a `length` property set with a numeric value.
127
157
*
128
-
* @param {*} - the input to test
158
+
* @param {*} input - The input to test
129
159
* @returns {boolean}
130
160
* @static
131
161
* @example
@@ -140,7 +170,7 @@ function isArrayLike (input) {
140
170
141
171
/**
142
172
* Returns true if the typeof input is `'object'` but not null.
143
-
* @param {*} - the input to test
173
+
* @param {*} input - The input to test
144
174
* @returns {boolean}
145
175
* @static
146
176
*/
@@ -150,7 +180,7 @@ function isObject (input) {
150
180
151
181
/**
152
182
* Returns true if the input value is defined.
153
-
* @param {*} - the input to test
183
+
* @param {*} input - The input to test
154
184
* @returns {boolean}
155
185
* @static
156
186
*/
@@ -160,7 +190,7 @@ function isDefined (input) {
160
190
161
191
/**
162
192
* Returns true if the input value is undefined.
163
-
* @param {*} - the input to test
193
+
* @param {*} input - The input to test
164
194
* @returns {boolean}
165
195
* @static
166
196
*/
@@ -170,27 +200,27 @@ function isUndefined (input) {
170
200
171
201
/**
172
202
* Returns true if the input value is null.
173
-
* @param {*} - the input to test
203
+
* @param {*} input - The input to test
174
204
* @returns {boolean}
175
205
* @static
176
206
*/
177
207
functionisNull(input){
178
-
returninput===null
208
+
returninput===null
179
209
}
180
210
181
211
/**
182
212
* Returns true if the input value is not one of `undefined`, `null`, or `NaN`.
0 commit comments