@phun-ky/typeof
Version:
A set of JavaScript helper functions to check for types
29 lines (28 loc) • 2.64 kB
JavaScript
/**
* @phun-ky/typeof
* A set of JavaScript helper functions to check for types
* @author Alexander Vassbotn Røyne-Helgesen <alexander@phun-ky.net>
* @version 1.2.17
* @license
* Copyright (c) 2024 Alexander Vassbotn Røyne-Helgesen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
const t=t=>"string"==typeof t,r=r=>!t(r),e=t=>"number"==typeof t,o=t=>!e(t),n=t=>"boolean"==typeof t,c=t=>!n(t),p=t=>void 0===t,u=t=>!p(t),l=t=>{if("object"!=typeof t||null===t)return!1;if("[object Object]"!==Object.prototype.toString.call(t))return!1;const r=Object.getPrototypeOf(t);if(null===r)return!0;const e=Object.prototype.hasOwnProperty.call(r,"constructor")?r.constructor:null;return"function"==typeof e&&e instanceof e&&Function.prototype.call(e)===Function.prototype.call(t)},y=t=>{const r=typeof t;return null!==t&&("object"===r||"function"===r)},f=t=>{if("function"!=typeof t)return!1;if(i(t))return!1;try{const r=Object.getOwnPropertyDescriptor(t,"prototype");return!!r&&!r.writable}catch{return!1}},i=t=>{if("function"!=typeof t)return!1;return[Object,Array,Function,String,Number,Boolean,Date,RegExp,Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,Map,WeakMap,Set,WeakSet,Promise,BigInt,Symbol].includes(t)},a=t=>"object"==typeof t&&null!==t&&Object.getPrototypeOf(t)!==Object.prototype&&null!==Object.getPrototypeOf(t);export{n as isBoolean,i as isBuiltInConstructor,f as isClass,a as isInstanceOfUnknownClass,c as isNotBoolean,o as isNotNumber,r as isNotString,u as isNotUndefined,e as isNumber,y as isObjectLoose,l as isObjectStrict,t as isString,p as isUndefined};
//# sourceMappingURL=typeof.js.map