diff --git a/dist/index.esm.js b/dist/index.esm.js new file mode 100644 index 0000000..3c18d31 --- /dev/null +++ b/dist/index.esm.js @@ -0,0 +1 @@ +function countItems(t){return t.reduce((t,e)=>(t[e]=t[e]?++t[e]:1,t),{})}function hasDuplicates(t){return new Set(t).sizeisString(t))}function isDate(t){return t instanceof Date}function isDateString(t){return/(^(?:(?:(?:31(?:(?:([-.\/])(?:0?[13578]|1[02])\2)|(?:([-.\/ ])(?:Jan|JAN|Mar|MAR|May|MAY|Jul|JUL|Aug|AUG|Oct|OCT|Dec|DEC)\3)))|(?:(?:29|30)(?:(?:([-.\/])(?:0?[13-9]|1[0-2])\4)|(?:([-.\/ ])(?:Jan|JAN|Mar|MAR|Apr|APR|May|MAY|Jun|JUN|Jul|JUL|Aug|AUG|Sep|SEP|Oct|OCT|Nov|NOV|Dec|DEC)\5))))(?:(?:1[6-9]|[2-9]\d)?\d{2}))$|^(?:29(?:(?:([-.\/])(?:0?2)\6)|(?:([-.\/ ])(?:Feb|FEB)\7))(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))$|^(?:(?:0?[1-9]|1\d|2[0-8])(?:(?:([-.\/])(?:(?:0?[1-9]|(?:1[0-2])))\8)|(?:([-.\/ ])(?:Jan|JAN|Feb|FEB|Mar|MAR|May|MAY|Jul|JUL|Aug|AUG|Oct|OCT|Dec|DEC)\9))(?:(?:1[6-9]|[2-9]\d)?\d{2}))$)/gm.test(t)}function isDefined(t){return null!=t}function isObject(t){let e=typeof t;return null!==t&&("object"===e||"function"===e)}function getLength(t){return isString(t)||isArray(t)?t.length:isObject(t)?Object.keys(t).length:0}function isEmpty(t){return null==t||0===getLength(t)}function isEqualDate(t,e){return t.getTime()===e.getTime()}function isObjectLike(t){return"object"==typeof t&&null!==t}function isEqual(t,e){return t===e||(isDate(t)&&isDate(e)?isEqualDate(t,e):!(null!==t&&null!==e&&(isObjectLike(t)||isObjectLike(e)))&&t!=t&&e!=e)}function getTag(t){return Object.prototype.toString.call(t)}function isMap(t){return isObjectLike(t)&&"[object Map]"===getTag(t)}function isNumber(t){return Number.isFinite(t)}function isSet(t){return isObjectLike(t)&&"[object Set]"===getTag(t)}function isNull(t){return null===t}function omitBy(t,e){return Object.keys(t).filter(n=>!e(n,t[n])).reduce((e,n)=>(e[n]=t[n],e),{})}function toChunks(t,e){let n=Math.ceil(t.length/e),i=RegExp(`.{1,${n}}`,"g");return t.match(i)??[]}function indexBy(t,e){return t.reduce((t,n)=>({...t,[n[e]]:n}),{})}function wrapInArray(t){return[t]}export{countItems,getLength,hasDuplicates,indexBy,isArray,isArrayOfString,isDate,isDateString as isDateValid,isDefined,isEmpty,isEqual,isEqualDate,isMap,isNull,isNumber,isObject,isObjectLike,isSet,isString,omitBy,toChunks,wrapInArray}; diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 0000000..c0d0fbc --- /dev/null +++ b/dist/index.js @@ -0,0 +1 @@ +"use strict";function countItems(t){return t.reduce((t,e)=>(t[e]=t[e]?++t[e]:1,t),{})}function hasDuplicates(t){return new Set(t).sizeisString(t))}function isDate(t){return t instanceof Date}function isDateString(t){return/(^(?:(?:(?:31(?:(?:([-.\/])(?:0?[13578]|1[02])\2)|(?:([-.\/ ])(?:Jan|JAN|Mar|MAR|May|MAY|Jul|JUL|Aug|AUG|Oct|OCT|Dec|DEC)\3)))|(?:(?:29|30)(?:(?:([-.\/])(?:0?[13-9]|1[0-2])\4)|(?:([-.\/ ])(?:Jan|JAN|Mar|MAR|Apr|APR|May|MAY|Jun|JUN|Jul|JUL|Aug|AUG|Sep|SEP|Oct|OCT|Nov|NOV|Dec|DEC)\5))))(?:(?:1[6-9]|[2-9]\d)?\d{2}))$|^(?:29(?:(?:([-.\/])(?:0?2)\6)|(?:([-.\/ ])(?:Feb|FEB)\7))(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))$|^(?:(?:0?[1-9]|1\d|2[0-8])(?:(?:([-.\/])(?:(?:0?[1-9]|(?:1[0-2])))\8)|(?:([-.\/ ])(?:Jan|JAN|Feb|FEB|Mar|MAR|May|MAY|Jul|JUL|Aug|AUG|Oct|OCT|Dec|DEC)\9))(?:(?:1[6-9]|[2-9]\d)?\d{2}))$)/gm.test(t)}function isDefined(t){return null!=t}function isObject(t){let e=typeof t;return null!==t&&("object"===e||"function"===e)}function getLength(t){return isString(t)||isArray(t)?t.length:isObject(t)?Object.keys(t).length:0}function isEmpty(t){return null==t||0===getLength(t)}function isEqualDate(t,e){return t.getTime()===e.getTime()}function isObjectLike(t){return"object"==typeof t&&null!==t}function isEqual(t,e){return t===e||(isDate(t)&&isDate(e)?isEqualDate(t,e):!(null!==t&&null!==e&&(isObjectLike(t)||isObjectLike(e)))&&t!=t&&e!=e)}function getTag(t){return Object.prototype.toString.call(t)}function isMap(t){return isObjectLike(t)&&"[object Map]"===getTag(t)}function isNumber(t){return Number.isFinite(t)}function isSet(t){return isObjectLike(t)&&"[object Set]"===getTag(t)}function isNull(t){return null===t}function omitBy(t,e){return Object.keys(t).filter(r=>!e(r,t[r])).reduce((e,r)=>(e[r]=t[r],e),{})}function toChunks(t,e){let r=Math.ceil(t.length/e),i=RegExp(`.{1,${r}}`,"g");return t.match(i)??[]}function indexBy(t,e){return t.reduce((t,r)=>({...t,[r[e]]:r}),{})}function wrapInArray(t){return[t]}exports.countItems=countItems,exports.getLength=getLength,exports.hasDuplicates=hasDuplicates,exports.indexBy=indexBy,exports.isArray=isArray,exports.isArrayOfString=isArrayOfString,exports.isDate=isDate,exports.isDateValid=isDateString,exports.isDefined=isDefined,exports.isEmpty=isEmpty,exports.isEqual=isEqual,exports.isEqualDate=isEqualDate,exports.isMap=isMap,exports.isNull=isNull,exports.isNumber=isNumber,exports.isObject=isObject,exports.isObjectLike=isObjectLike,exports.isSet=isSet,exports.isString=isString,exports.omitBy=omitBy,exports.toChunks=toChunks,exports.wrapInArray=wrapInArray; diff --git a/dist/index.umd.js b/dist/index.umd.js new file mode 100644 index 0000000..843cafd --- /dev/null +++ b/dist/index.umd.js @@ -0,0 +1 @@ +!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).yotils={})}(this,function(t){"use strict";function n(t){return Array.isArray(t)}function e(t){return"string"==typeof t}function r(t){return t instanceof Date}function u(t){let n=typeof t;return null!==t&&("object"===n||"function"===n)}function i(t){return e(t)||n(t)?t.length:u(t)?Object.keys(t).length:0}function o(t,n){return t.getTime()===n.getTime()}function c(t){return"object"==typeof t&&null!==t}function f(t){return Object.prototype.toString.call(t)}t.countItems=function(t){return t.reduce((t,n)=>(t[n]=t[n]?++t[n]:1,t),{})},t.getLength=i,t.hasDuplicates=function(t){return new Set(t).size({...t,[e[n]]:e}),{})},t.isArray=n,t.isArrayOfString=function(t){return Array.isArray(t)&&t.every(t=>e(t))},t.isDate=r,t.isDateValid=function(t){return/(^(?:(?:(?:31(?:(?:([-.\/])(?:0?[13578]|1[02])\2)|(?:([-.\/ ])(?:Jan|JAN|Mar|MAR|May|MAY|Jul|JUL|Aug|AUG|Oct|OCT|Dec|DEC)\3)))|(?:(?:29|30)(?:(?:([-.\/])(?:0?[13-9]|1[0-2])\4)|(?:([-.\/ ])(?:Jan|JAN|Mar|MAR|Apr|APR|May|MAY|Jun|JUN|Jul|JUL|Aug|AUG|Sep|SEP|Oct|OCT|Nov|NOV|Dec|DEC)\5))))(?:(?:1[6-9]|[2-9]\d)?\d{2}))$|^(?:29(?:(?:([-.\/])(?:0?2)\6)|(?:([-.\/ ])(?:Feb|FEB)\7))(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))$|^(?:(?:0?[1-9]|1\d|2[0-8])(?:(?:([-.\/])(?:(?:0?[1-9]|(?:1[0-2])))\8)|(?:([-.\/ ])(?:Jan|JAN|Feb|FEB|Mar|MAR|May|MAY|Jul|JUL|Aug|AUG|Oct|OCT|Dec|DEC)\9))(?:(?:1[6-9]|[2-9]\d)?\d{2}))$)/gm.test(t)},t.isDefined=function(t){return null!=t},t.isEmpty=function(t){return null==t||0===i(t)},t.isEqual=function(t,n){return t===n||(r(t)&&r(n)?o(t,n):!(null!==t&&null!==n&&(c(t)||c(n)))&&t!=t&&n!=n)},t.isEqualDate=o,t.isMap=function(t){return c(t)&&"[object Map]"===f(t)},t.isNull=function(t){return null===t},t.isNumber=function(t){return Number.isFinite(t)},t.isObject=u,t.isObjectLike=c,t.isSet=function(t){return c(t)&&"[object Set]"===f(t)},t.isString=e,t.omitBy=function(t,n){return Object.keys(t).filter(e=>!n(e,t[e])).reduce((n,e)=>(n[e]=t[e],n),{})},t.toChunks=function(t,n){let e=Math.ceil(t.length/n),r=RegExp(`.{1,${e}}`,"g");return t.match(r)??[]},t.wrapInArray=function(t){return[t]}});