Passed
Push — master ( db8b6d...8ae6ad )
by Lucas
02:30
created

T_FUNCTION   A

Complexity

Total Complexity 16
Complexity/F 1.07

Size

Lines of Code 1
Function Count 15

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 0
nc 1
dl 0
loc 1
rs 10
c 0
b 0
f 0
wmc 16
mnd 1
bc 16
fnc 15
bpm 1.0666
cpm 1.0666
noi 3
1
// Copyright Joyent, Inc. and other Node contributors.
2
//
3
// Permission is hereby granted, free of charge, to any person obtaining a
4
// copy of this software and associated documentation files (the
5
// "Software"), to deal in the Software without restriction, including
6
// without limitation the rights to use, copy, modify, merge, publish,
7
// distribute, sublicense, and/or sell copies of the Software, and to permit
8
// persons to whom the Software is furnished to do so, subject to the
9
// following conditions:
10
//
11
// The above copyright notice and this permission notice shall be included
12
// in all copies or substantial portions of the Software.
13
//
14
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20
// USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22
// NOTE: These type checking functions intentionally don't use `instanceof`
23
// because it is fragile and can be easily faked with `Object.create()`.
24
25
function isArray(arg) {
26
  if (Array.isArray) {
27
    return Array.isArray(arg);
28
  }
29
  return objectToString(arg) === '[object Array]';
30
}
31
exports.isArray = isArray;
32
33
function isBoolean(arg) {
34
  return typeof arg === 'boolean';
35
}
36
exports.isBoolean = isBoolean;
37
38
function isNull(arg) {
39
  return arg === null;
40
}
41
exports.isNull = isNull;
42
43
function isNullOrUndefined(arg) {
44
  return arg == null;
0 ignored issues
show
Best Practice introduced by
Comparing arg to null using the == operator is not safe. Consider using === instead.
Loading history...
45
}
46
exports.isNullOrUndefined = isNullOrUndefined;
47
48
function isNumber(arg) {
49
  return typeof arg === 'number';
50
}
51
exports.isNumber = isNumber;
52
53
function isString(arg) {
54
  return typeof arg === 'string';
55
}
56
exports.isString = isString;
57
58
function isSymbol(arg) {
59
  return typeof arg === 'symbol';
60
}
61
exports.isSymbol = isSymbol;
62
63
function isUndefined(arg) {
64
  return arg === void 0;
0 ignored issues
show
Coding Style introduced by
Consider using undefined instead of void(0). It is equivalent and more straightforward to read.
Loading history...
65
}
66
exports.isUndefined = isUndefined;
67
68
function isRegExp(re) {
69
  return objectToString(re) === '[object RegExp]';
70
}
71
exports.isRegExp = isRegExp;
72
73
function isObject(arg) {
74
  return typeof arg === 'object' && arg !== null;
75
}
76
exports.isObject = isObject;
77
78
function isDate(d) {
79
  return objectToString(d) === '[object Date]';
80
}
81
exports.isDate = isDate;
82
83
function isError(e) {
84
  return (objectToString(e) === '[object Error]' || e instanceof Error);
85
}
86
exports.isError = isError;
87
88
function isFunction(arg) {
89
  return typeof arg === 'function';
90
}
91
exports.isFunction = isFunction;
92
93 View Code Duplication
function isPrimitive(arg) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
94
  return arg === null ||
95
         typeof arg === 'boolean' ||
96
         typeof arg === 'number' ||
97
         typeof arg === 'string' ||
98
         typeof arg === 'symbol' ||  // ES6 symbol
99
         typeof arg === 'undefined';
100
}
101
exports.isPrimitive = isPrimitive;
102
103
exports.isBuffer = Buffer.isBuffer;
0 ignored issues
show
Bug introduced by
The variable Buffer seems to be never declared. If this is a global, consider adding a /** global: Buffer */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
104
105
function objectToString(o) {
106
  return Object.prototype.toString.call(o);
107
}
108