forked from arasatasaygin/is.js
-
Notifications
You must be signed in to change notification settings - Fork 3
/
is-it-check.min.js
1 lines (1 loc) · 13.3 KB
/
is-it-check.min.js
1
((e,t)=>{if(typeof define==="function"&&define.amd){define(()=>e.is=t())}else if(typeof exports==="object"){module.exports=t()}else{e.is=t()}})(this,()=>{const a={};a.VERSION="1.1.1";a.not={};a.all={};a.any={};const o=Object.prototype.toString;const r=Array.prototype.slice;const i=Object.prototype.hasOwnProperty;const s=t=>(...e)=>!t(...r.call(e));const l=o=>(...e)=>{const t=d(e);for(const n of t){if(!o.call(null,n)){return false}}return true};const c=o=>(...e)=>{const t=d(e);for(const n of t){if(o.call(null,n)){return true}}return false};const u={"<":(e,t)=>e<t,"<=":(e,t)=>e<=t,">":(e,t)=>e>t,">=":(e,t)=>e>=t};const n=(e,t)=>{const n=`${t}`;const o=+(n.match(/\d+/)||NaN);const a=n.match(/^[<>]=?|/)[0];return u[a]?u[a](e,o):e==o||o!==o};const d=e=>{let t=r.call(e);const n=t.length;if(n===1&&a.array(t[0])){t=t[0]}return t};a.arguments=e=>o.call(e)==="[object Arguments]"||e!=null&&typeof e==="object"&&"callee"in e;a.array=e=>Array.isArray(e)&&o.call(e)==="[object Array]";a.boolean=e=>(e===true||e===false)&&new Boolean(e)instanceof Boolean&&o.call(e)==="[object Boolean]";a.char=e=>a.string(e)&&e.length===1;a.date=e=>new Date(e)instanceof Date&&a.not.nan(e)&&o.call(e)==="[object Date]";a.domNode=e=>a.object(e)&&e.nodeType>0;a.error=e=>o.call(e)==="[object Error]";a["function"]=e=>o.call(e)==="[object Function]"||typeof e==="function";a.json=e=>o.call(e)==="[object Object]";a.nan=e=>Number.isNaN(e);a["null"]=e=>e===null;a.number=e=>new Number(e)instanceof Number&&typeof e==="number"&&Number.isFinite(e);a.object=e=>Object(e)===e;a.regexp=e=>o.call(e)==="[object RegExp]";a.sameType=(e,t)=>{const n=o.call(e);if(n!==o.call(t)){return false}if(n==="[object Number]"){return!a.any.nan(e,t)||a.all.nan(e,t)}return true};a.sameType.api=["not"];a.string=e=>new String(e)instanceof String&&typeof e==="string"&&o.call(e)==="[object String]";a.undefined=e=>e===void 0;a.windowObject=e=>e!=null&&typeof e==="object"&&"setInterval"in e;a.stream=e=>e!==null&&typeof e==="object"&&typeof e.pipe==="function";a.duplexStream=e=>a.writeableStream(e)&&a.readableStream(e);a.readableStream=e=>a.stream(e)&&e.readable!==false&&typeof e._read==="function"&&typeof e._readableState==="object";a.transformStream=e=>a.duplexStream(e)&&typeof e._transform==="function";a.writeableStream=e=>a.stream(e)&&e.writable!==false&&typeof e._write==="function"&&typeof e._writableState==="object";a.empty=e=>{if(a.object(e)){const t=Object.getOwnPropertyNames(e).length;if(t===0||t===1&&a.array(e)||t===2&&a.arguments(e)){return true}return false}return e===""};a.map=e=>{const t=/^function\s+Map\b/;const n=e.constructor?e.constructor+"":"";return t.test(n)};a.existy=e=>e!=null;a.falsy=e=>!e;a.truthy=s(a.falsy);a.above=(e,t)=>a.all.number(e,t)&&e>t;a.above.api=["not"];a.decimal=e=>a.number(e)&&e%1!==0;a.equal=(e,t)=>{if(a.all.array(e,t)){return e.length===t.length&&e.every(e=>t.includes(e))}if(a.all.object(e,t)){return JSON.stringify(e)===JSON.stringify(t)}if(a.all.number(e,t)){return e===t&&1/e===1/t}if(a.all.string(e,t)||a.all.regexp(e,t)){return`${e}`===`${t}`}if(a.all.boolean(e,t)){return e===t}return false};a.equal.api=["not"];a.even=e=>a.number(e)&&e%2===0;a.finite=isFinite||(e=>a.not.infinite(e)&&a.not.nan(e));a.infinite=e=>e===Infinity||e===-Infinity;a.integer=e=>Number.isInteger(e);a.negative=e=>a.number(e)&&e<0;a.odd=e=>a.number(e)&&(e%2===1||e%2===-1);a.positive=e=>a.number(e)&&e>0;a.under=(e,t)=>a.all.number(e,t)&&e<t;a.under.api=["not"];a.within=(e,t,n)=>a.all.number(e,t,n)&&e>t&&e<n;a.within.api=["not"];const e=["\\+https:\\/\\/developers.google.com\\/\\+\\/web\\/snippet\\/","ad\\smonitoring","adsbot","apex","applebot","archive.org_bot","baiduspider","bingbot","chromeheadless","cloudflare","cloudinary","crawler","curl","discordbot","duckduckbot","embedly","exabot","facebookexternalhit","facebot","flipboard","google","googlebot","gsa-crawler","gurujibot","guzzlehttp","heritrix","ia_archiver","insights","linkedinbot","ltx71","mediapartners","msnbot","odklbot","phantom\\.js","phantomjs","pingdom","pinterest","python","rtlnieuws","skypeuripreview","slackbot","slurp","spbot","telegrambot","test\\scertificate","testing","tiabot","tumblr ","twitterbot","vkshare","web\\sscraper","wget","yandexbot","whatsapp","orangebot","smtbot","qwantify","mj12bot","ahrefsbot","seznambot","panscient.com","duckduckgo-favicons-bot","uptimerobot","semrushbot","postman","dotbot","zoominfobot","ifttt","sogou","ru_bot","researchscan","nimbostratus-bot","slack-imgproxy","node-superagent","go-http-client","jersey","dataprovider.com","github-camo","dispatch","checkmarknetwork","screaming frog","whatweb","daum","netcraftsurveyagent","mojeekbot","surdotlybot","springbot"];const p={affirmative:/^(?:1|t(?:rue)?|y(?:es)?|ok(?:ay)?)$/,alphaNumeric:/^[A-Za-z0-9]+$/,caPostalCode:/^(?!.*[DFIOQU])[A-VXY][0-9][A-Z]\s?[0-9][A-Z][0-9]$/,crawler:new RegExp("^.*("+e.join("|")+").*$","i"),creditCard:/^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/,dateString:/^(1[0-2]|0?[1-9])([/-])(3[01]|[12][0-9]|0?[1-9])(?:\2)(?:[0-9]{2})?[0-9]{2}$/,email:/^[a-zA-Z0-9][-_.+!#$%&'*/=?^`{|]{0,1}([a-zA-Z0-9][-_.+!#$%&'*/=?^`{|]{0,1})*[a-zA-Z0-9]@[a-zA-Z0-9][-.]{0,1}([a-zA-Z][-.]{0,1})*[a-zA-Z0-9]\.[a-zA-Z0-9]{1,}([.-]{0,1}[a-zA-Z]){0,}[a-zA-Z0-9]{0,}$/i,eppPhone:/^\+[0-9]{1,3}\.[0-9]{4,14}(?:x.+)?$/,hexadecimal:/^(?:0x)?[0-9a-fA-F]+$/,hexColor:/^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,ipv4:/^(?:(?:\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])\.){3}(?:\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])$/,ipv6:/^((?=.*::)(?!.*::.+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\3)::|:\b|$))|(?!\2\3)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/i,macAddress:/^([0-9a-f]{2}[-:]){5}[0-9a-f]{2}$/i,nanpPhone:/^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/,socialSecurityNumber:/^(?!000|666)[0-8][0-9]{2}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4}$/,timeString:/^(2[0-3]|[01]?[0-9]):([0-5]?[0-9]):([0-5]?[0-9])$/,ukPostCode:/^[A-Z]{1,2}[0-9RCHNQ][0-9A-Z]?\s?[0-9][ABD-HJLNP-UW-Z]{2}$|^[A-Z]{2}-?[0-9]{4}$/,url:/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/i,usZipCode:/^[0-9]{5}(?:-[0-9]{4})?$/};const t=(t,n)=>{a[t]=e=>a.existy(e)&&n[t].test(e)};for(const $ in p){if(Object.prototype.hasOwnProperty.call(p,$)){t($,p)}}a.ip=e=>a.ipv4(e)||a.ipv6(e);a.capitalized=e=>{if(a.not.string(e)){return false}const t=e.split(" ");for(const n of t){if(n.length){const o=n.charAt(0);if(o!==o.toUpperCase()){return false}}}return true};a.endWith=(e,t)=>{if(a.not.string(e)){return false}t+="";const n=e.length-t.length;return n>=0&&e.indexOf(t,n)===n};a.endWith.api=["not"];a.include=(e,t)=>e.includes(t);a.include.api=["not"];a.umlaut=e=>a.string(e)&&a.array(e.match(/[\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df]/g));a.lowerCase=e=>a.string(e)&&e===e.toLowerCase();a.palindrome=n=>{if(a.not.string(n)){return false}n=n.replace(/[^a-zA-Z0-9]+/g,"").toLowerCase();return n.split("").every((e,t)=>e===n[n.length-1-t])};a.space=e=>{if(a.not.char(e)){return false}const t=e.charCodeAt(0);return t>8&&t<14||t===32};a.startWith=(e,t)=>a.string(e)&&e.indexOf(t)===0;a.startWith.api=["not"];a.upperCase=e=>a.string(e)&&e===e.toUpperCase();const f=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];const b=["january","february","march","april","may","june","july","august","september","october","november","december"];a.day=(e,t)=>a.date(e)&&t.toLowerCase()===f[e.getDay()];a.day.api=["not"];a.dayLightSavingTime=e=>{const t=new Date(e.getFullYear(),0,1);const n=new Date(e.getFullYear(),6,1);const o=Math.max(t.getTimezoneOffset(),n.getTimezoneOffset());return e.getTimezoneOffset()<o};a.future=e=>{const t=new Date;return a.date(e)&&e.getTime()>t.getTime()};a.inDateRange=(e,t,n)=>{if(a.not.date(e)||a.not.date(t)||a.not.date(n)){return false}const o=e.getTime();return o>t.getTime()&&o<n.getTime()};a.inDateRange.api=["not"];a.inLastMonth=e=>a.inDateRange(e,new Date((new Date).setMonth((new Date).getMonth()-1)),new Date);a.inLastWeek=e=>a.inDateRange(e,new Date((new Date).setDate((new Date).getDate()-7)),new Date);a.inLastYear=e=>a.inDateRange(e,new Date((new Date).setFullYear((new Date).getFullYear()-1)),new Date);a.inNextMonth=e=>a.inDateRange(e,new Date,new Date((new Date).setMonth((new Date).getMonth()+1)));a.inNextWeek=e=>a.inDateRange(e,new Date,new Date((new Date).setDate((new Date).getDate()+7)));a.inNextYear=e=>a.inDateRange(e,new Date,new Date((new Date).setFullYear((new Date).getFullYear()+1)));a.leapYear=e=>a.number(e)&&(e%4===0&&e%100!==0||e%400===0);a.month=(e,t)=>a.date(e)&&t.toLowerCase()===b[e.getMonth()];a.month.api=["not"];a.past=e=>{const t=new Date;return a.date(e)&&e.getTime()<t.getTime()};a.quarterOfYear=(e,t)=>a.date(e)&&a.number(t)&&t===Math.floor((e.getMonth()+3)/3);a.quarterOfYear.api=["not"];a.today=e=>{const t=new Date;const n=t.toDateString();return a.date(e)&&e.toDateString()===n};a.tomorrow=e=>{const t=new Date;const n=new Date(t.setDate(t.getDate()+1)).toDateString();return a.date(e)&&e.toDateString()===n};a.weekend=e=>a.date(e)&&(e.getDay()===6||e.getDay()===0);a.weekday=s(a.weekend);a.year=(e,t)=>a.date(e)&&a.number(t)&&t===e.getFullYear();a.year.api=["not"];a.yesterday=e=>{const t=new Date;const n=new Date(t.setDate(t.getDate()-1)).toDateString();return a.date(e)&&e.toDateString()===n};const m=a.windowObject(typeof global=="object"&&global)&&global;const g=a.windowObject(typeof self=="object"&&self)&&self;const w=a.windowObject(typeof this=="object"&&this)&&this;const h=m||g||w||Function("return this")();const y=g&&g.document;const D=h.is;const j=g?.navigator;const A=(j?.userAgentData?.platform||j?.platform||"").toLowerCase();const x=(j?.userAgent||"").toLowerCase();const v=(j?.vendor||"").toLowerCase();a.browser=()=>typeof window!=="undefined"&&typeof window.document!=="undefined";a.browser.api=["not"];a.nodejs=()=>typeof process!=="undefined"&&process.versions!=null&&process.versions.node!=null;a.nodejs.api=["not"];let k;a.deno=()=>typeof k!=="undefined"&&typeof k.core!=="undefined";a.deno.api=["not"];a.webworker=()=>typeof self==="object"&&self.constructor&&self.constructor.name==="DedicatedWorkerGlobalScope";a.webworker.api=["not"];a.android=()=>/android/.test(x);a.android.api=["not"];a.androidPhone=()=>/android/.test(x)&&/mobile/.test(x);a.androidPhone.api=["not"];a.androidTablet=()=>/android/.test(x)&&!/mobile/.test(x);a.androidTablet.api=["not"];a.blackberry=()=>/blackberry/.test(x)||/bb10/.test(x);a.blackberry.api=["not"];a.chrome=e=>{const t=/google inc/.test(v)?x.match(/(?:chrome|crios)\/(\d+)/):null;return t!==null&&a.not.opera()&&n(t[1],e)};a.chrome.api=["not"];a.desktop=()=>a.not.mobile()&&a.not.tablet();a.desktop.api=["not"];a.edge=e=>{const t=x.match(/edg(e|a|ios)?\/(\d+)/);return t!==null&&n(t[1],e)};a.edge.api=["not"];a.firefox=e=>{const t=x.match(/(?:firefox|fxios)\/(\d+)/);return t!==null&&n(t[1],e)};a.firefox.api=["not"];a.ie=e=>{const t=x.match(/(?:msie |trident.+?; rv:)(\d+)/);return t!==null&&n(t[1],e)};a.ie.api=["not"];a.ios=()=>a.iphone()||a.ipad()||a.ipod();a.ios.api=["not"];a.ipad=e=>{const t=x.match(/\(ipad.*os (\d+)[._](\d+)/)||(x.includes("mac")&&"ontouchend"in y?x.match(/version\/(\d+)/):null);return t!==null&&n(t[1],e)};a.ipad.api=["not"];a.iphone=e=>{const t=x.match(/\(iphone.*os (\d+)[._](\d+)/);return t!==null&&n(t[1]||1,e)};a.iphone.api=["not"];a.ipod=e=>{const t=x.match(/ipod.+?os (\d+)/);return t!==null&&n(t[1],e)};a.ipod.api=["not"];a.linux=()=>/linux/.test(A)&&a.not.android();a.linux.api=["not"];a.mac=()=>/mac/.test(A);a.mac.api=["not"];a.mobile=()=>a.iphone()||a.ipod()||a.androidPhone()||a.blackberry()||a.windowsPhone();a.mobile.api=["not"];a.offline=s(a.online);a.offline.api=["not"];a.online=()=>!j||j.onLine===true;a.online.api=["not"];a.opera=e=>{const t=x.match(/(?:^opera.+?version|opr)\/(\d+)/);return t!==null&&n(t[1],e)};a.opera.api=["not"];a.operaMini=e=>{const t=x.match(/opera mini\/(\d+)/);return t!==null&&n(t[1],e)};a.operaMini.api=["not"];a.phantom=e=>{const t=x.match(/phantomjs\/(\d+)/);return t!==null&&n(t[1],e)};a.phantom.api=["not"];a.safari=e=>{const t=x.match(/version\/(\d+)((?!chrome).)+?safari/);return t!==null&&n(t[1],e)};a.safari.api=["not"];a.tablet=()=>a.ipad()||a.androidTablet()||a.windowsTablet();a.tablet.api=["not"];a.touchDevice=()=>!!y&&("ontouchstart"in g||"DocumentTouch"in g&&y instanceof DocumentTouch);a.touchDevice.api=["not"];a.windows=()=>/win/.test(A);a.windows.api=["not"];a.windowsPhone=()=>a.windows()&&/phone/.test(x);a.windowsPhone.api=["not"];a.windowsTablet=()=>a.windows()&&a.not.windowsPhone()&&/touch/.test(x);a.windowsTablet.api=["not"];a.propertyCount=(e,t)=>{if(a.not.object(e)||a.not.number(t)){return false}let n=0;for(const o in e){if(i.call(e,o)&&++n>t){return false}}return n===t};a.propertyCount.api=["not"];a.propertyDefined=(e,t)=>a.object(e)&&a.string(t)&&t in e;a.propertyDefined.api=["not"];a.thenable=e=>a.object(e)&&typeof e.then==="function";a.inArray=(e,t)=>{if(a.not.array(t)){return false}return t.includes(e)};a.inArray.api=["not"];a.sorted=(e,t)=>{if(a.not.array(e)){return false}const n=u[t]||u[">="];for(const[o]of e.entries()){if(o>=1&&!n(e[o],e[o-1])){return false}}return true};const S=()=>{const e=a;for(const t in e){if(i.call(e,t)&&a["function"](e[t])){const n=e[t].api||["not","all","any"];for(const o of n){if(o==="not"){a.not[t]=s(a[t])}if(o==="all"){a.all[t]=l(a[t])}if(o==="any"){a.any[t]=c(a[t])}}}}};S();a.setNamespace=()=>{h.is=D;return this};a.setRegexp=(e,t)=>{for(const n in p){if(i.call(p,n)&&t===n){p[n]=e}}};return a});