typeis.js
Version:
The fast and reliable JS type-checking toolbox!
2 lines (1 loc) • 1.42 kB
JavaScript
var typeis=function(){"use strict";function o(t){return void 0===t}function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function e(t){return!t&&"object"===n(t)}function r(t){return"function"==typeof t}function u(t){return"object"===n(t)&&null!==t}function i(t){return u(t)||r(t)}function c(t){return Object.prototype.toString.call(t)}function f(t){return"[object Object]"===c(t)}var y=9007199254740991;function b(t){if(e(t)||o(t))return!1;var n,r=t.length;return"number"==typeof(n=r)&&-1<n&&n%1==0&&n<=y}function s(t){return!e(t)&&!r(t)&&b(t)}function l(t){return Array.isArray(t)}return{isUndefined:o,isNull:e,isObject:i,isFunction:r,isObjectLike:u,isPlainObject:function(t){if(!i(t))return!1;if(!f(t))return!1;var n=t.constructor;if("function"!=typeof n)return!1;var r=n.prototype;return!!f(r)&&!!r.hasOwnProperty("isPrototypeOf")},isArrayLike:s,isArray:l,isString:function(t){return"string"==typeof t||u(t)&&!l(t)&&"[object String]"==c(t)},isBoolean:function(t){return!0===t||!1===t||u(t)&&"[object Boolean]"==c(t)},isNumber:function(t){return"number"==typeof t||u(t)&&"[object Number]"===c(t)},isSymbol:function(t){return"symbol"===n(t)||u(t)&&"[object Symbol]"==c(t)},isArguments:function(t){return s(t)&&"[object Arguments]"===c(t)}}}();