-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathType.js
41 lines (28 loc) · 959 Bytes
/
Type.js
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
// returns true if type is of type, and false if not
const isObject = any => any && typeof any === 'object' && a.constructor === Object
const isString = any => typeof any === 'string' || any instanceof String
const isNumber = any => typeof any === 'number' && isFinite(any)
const isArray = any => Array.isArray(any)
const isFunction = any => typeof any === 'function'
const isNull = any => any === null
const isUndefined = any => typeof any === 'undefined'
const isBoolean = any => typeof any === 'boolean'
const isRegExp = any => any && typeof any === 'object' && any.constructor === RegExp
const isError = any => any instanceof Error && typeof any.message !== 'undefined'
const isDate = any => any instanceof Date
const isSymbol = any => typeof any === 'symbol'
const Type = {
isObject,
isString,
isNumber,
isArray,
isFunction,
isNull,
isUndefined,
isBoolean,
isRegExp,
isError,
isDate,
isSymbol,
}
export default Type;