react / wstein / node_modules / browserify / node_modules / readable-stream / node_modules / core-util-is / lib / util.js
80551 views// Copyright Joyent, Inc. and other Node contributors.1//2// Permission is hereby granted, free of charge, to any person obtaining a3// copy of this software and associated documentation files (the4// "Software"), to deal in the Software without restriction, including5// without limitation the rights to use, copy, modify, merge, publish,6// distribute, sublicense, and/or sell copies of the Software, and to permit7// persons to whom the Software is furnished to do so, subject to the8// following conditions:9//10// The above copyright notice and this permission notice shall be included11// in all copies or substantial portions of the Software.12//13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS14// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF15// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN16// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,17// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR18// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE19// USE OR OTHER DEALINGS IN THE SOFTWARE.2021// NOTE: These type checking functions intentionally don't use `instanceof`22// because it is fragile and can be easily faked with `Object.create()`.23function isArray(ar) {24return Array.isArray(ar);25}26exports.isArray = isArray;2728function isBoolean(arg) {29return typeof arg === 'boolean';30}31exports.isBoolean = isBoolean;3233function isNull(arg) {34return arg === null;35}36exports.isNull = isNull;3738function isNullOrUndefined(arg) {39return arg == null;40}41exports.isNullOrUndefined = isNullOrUndefined;4243function isNumber(arg) {44return typeof arg === 'number';45}46exports.isNumber = isNumber;4748function isString(arg) {49return typeof arg === 'string';50}51exports.isString = isString;5253function isSymbol(arg) {54return typeof arg === 'symbol';55}56exports.isSymbol = isSymbol;5758function isUndefined(arg) {59return arg === void 0;60}61exports.isUndefined = isUndefined;6263function isRegExp(re) {64return isObject(re) && objectToString(re) === '[object RegExp]';65}66exports.isRegExp = isRegExp;6768function isObject(arg) {69return typeof arg === 'object' && arg !== null;70}71exports.isObject = isObject;7273function isDate(d) {74return isObject(d) && objectToString(d) === '[object Date]';75}76exports.isDate = isDate;7778function isError(e) {79return isObject(e) &&80(objectToString(e) === '[object Error]' || e instanceof Error);81}82exports.isError = isError;8384function isFunction(arg) {85return typeof arg === 'function';86}87exports.isFunction = isFunction;8889function isPrimitive(arg) {90return arg === null ||91typeof arg === 'boolean' ||92typeof arg === 'number' ||93typeof arg === 'string' ||94typeof arg === 'symbol' || // ES6 symbol95typeof arg === 'undefined';96}97exports.isPrimitive = isPrimitive;9899function isBuffer(arg) {100return Buffer.isBuffer(arg);101}102exports.isBuffer = isBuffer;103104function objectToString(o) {105return Object.prototype.toString.call(o);106}107108