Remove excessive copyright/license boilerplate
[platform/upstream/nodejs.git] / deps / npm / node_modules / npm-registry-client / node_modules / concat-stream / node_modules / readable-stream / node_modules / core-util-is / lib / util.js
1 // NOTE: These type checking functions intentionally don't use `instanceof`
2 // because it is fragile and can be easily faked with `Object.create()`.
3 function isArray(ar) {
4   return Array.isArray(ar);
5 }
6 exports.isArray = isArray;
7
8 function isBoolean(arg) {
9   return typeof arg === 'boolean';
10 }
11 exports.isBoolean = isBoolean;
12
13 function isNull(arg) {
14   return arg === null;
15 }
16 exports.isNull = isNull;
17
18 function isNullOrUndefined(arg) {
19   return arg == null;
20 }
21 exports.isNullOrUndefined = isNullOrUndefined;
22
23 function isNumber(arg) {
24   return typeof arg === 'number';
25 }
26 exports.isNumber = isNumber;
27
28 function isString(arg) {
29   return typeof arg === 'string';
30 }
31 exports.isString = isString;
32
33 function isSymbol(arg) {
34   return typeof arg === 'symbol';
35 }
36 exports.isSymbol = isSymbol;
37
38 function isUndefined(arg) {
39   return arg === void 0;
40 }
41 exports.isUndefined = isUndefined;
42
43 function isRegExp(re) {
44   return isObject(re) && objectToString(re) === '[object RegExp]';
45 }
46 exports.isRegExp = isRegExp;
47
48 function isObject(arg) {
49   return typeof arg === 'object' && arg !== null;
50 }
51 exports.isObject = isObject;
52
53 function isDate(d) {
54   return isObject(d) && objectToString(d) === '[object Date]';
55 }
56 exports.isDate = isDate;
57
58 function isError(e) {
59   return isObject(e) &&
60       (objectToString(e) === '[object Error]' || e instanceof Error);
61 }
62 exports.isError = isError;
63
64 function isFunction(arg) {
65   return typeof arg === 'function';
66 }
67 exports.isFunction = isFunction;
68
69 function isPrimitive(arg) {
70   return arg === null ||
71          typeof arg === 'boolean' ||
72          typeof arg === 'number' ||
73          typeof arg === 'string' ||
74          typeof arg === 'symbol' ||  // ES6 symbol
75          typeof arg === 'undefined';
76 }
77 exports.isPrimitive = isPrimitive;
78
79 function isBuffer(arg) {
80   return Buffer.isBuffer(arg);
81 }
82 exports.isBuffer = isBuffer;
83
84 function objectToString(o) {
85   return Object.prototype.toString.call(o);
86 }