UNPKG

584 BJavaScriptView Raw
1/**
2 * @module type
3 *
4 * The type module is useful when it comes to testing the type of something.
5 */
6module.exports = {
7 array : typeof [],
8 object: typeof {},
9 function : typeof Function,
10 number : typeof 1,
11 boolean : typeof true,
12 symbol : typeof Symbol(),
13 string : typeof '',
14
15 isObject (val) {
16 return (val !== undefined) && val.constructor === Object;
17 },
18
19 isNotObject (val) {
20 return !this.isObject(val);
21 },
22
23 isArray (val) {
24 return (val !== undefined) && val.constructor === Array;
25 },
26
27 isNotArray (val) {
28 return !this.isArray(val);
29 }
30
31};