UNPKG

pp-is

Version:

Collection of methods for check

1 lines 1.57 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).ppIs=t()}(this,(function(){"use strict";const e=(e,t)=>(e=>Object.prototype.toString.call(e))(e)==="[object "+t+"]",t=t=>e(t,"String"),i=t=>e(t,"Array"),o=t=>e(t,"Object"),s=t=>!0===t||!1===t||e(t,"Boolean"),n=t=>e(t,"Function"),d=t=>e(t,"Undefined"),l=t=>e(t,"Null"),r=e=>Number.isNaN(Number.parseInt(e)),a=(e,t,i)=>{const o=e(t);return s(o)?o:i},p=e=>(t,i,o)=>((e,t,i,o)=>{const s=e(t);return s?!n(i)||a(i,t,s):!!n(o)&&a(o,t,s)})(e,t,i,o);return{isArray:p(i),isBoolean:p(s),isDate:p((t=>e(t,"Date"))),isElement:p((e=>!(!e||1!==e.nodeType))),isEmpty:p((e=>t(e)?""===e:i(e)?0==e.length:!o(e)||0===Object.keys(e).length)),isBlank:p((e=>!!t(e)&&(""===e||""===e.trim()))),isFunction:p(n),isNull:p(l),isNumber:p((t=>e(t,"Number")&&!r(t))),isObject:p(o),isString:p(t),isUndefined:p(d),isNil:p((e=>d(e)||l(e))),isEmail:p((e=>/^([a-z1-9\._-]+)@([a-z0-9-]+\.[a-z]{2,11}|[a-z0-9]+\.[a-z]{2,24}\.[a-z]{2,24})$/i.test(e))),isNaN:p(r),isRegExp:p((t=>e(t,"RegExp"))),isUrl:p((e=>/^(https?:\/\/)?([w]{3}\.|[w]{3}2\.)?([a-z\d]+\.)?([a-z\d]+\.[a-z]{2,}|localhost|[\d]+\.[\d]+\.[\d]+\.[\d]+)(\:[\d]+)?([\??\/?]+[\/;&a-z\d%_.~+=-]*)?(\#[\/;&a-z\d%_.~+=-]*)?$/gi.test(e))),isNodeList:p((e=>"undefined"!=typeof NodeList&&NodeList.prototype.isPrototypeOf(e))),isHTMLCollection:p((e=>"undefined"!=typeof HTMLCollection&&HTMLCollection.prototype.isPrototypeOf(e))),isPromise:p((t=>e(t,"Promise")))}}));