diff --git a/README.md b/README.md index a1fc92e..325695f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,18 @@ +

+ Finka.js +

+ # Finka.js -Finks.js +[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE.md) + +Handy tool in nowadays JavaScript jungle. + +It's extending default JS classes like `Array` or `String` with new handy methods, +that probably sooner or later you are going to search for on Stack Overflow ;) + ## Getting Started @@ -25,9 +37,9 @@ npm install finka-js Download version that fits your better: -[Compressed version - 1.44KB](https://raw.githubusercontent.com/bitbar/finka-js/master/dist/kasza.min.js) +[Compressed version - 15KB](https://raw.githubusercontent.com/bitbar/finka-js/master/dist/finka.min.js) -[Uncompressed version - 2.41KB](https://raw.githubusercontent.com/bitbar/finka-js/master/dist/kasza.js) +[Uncompressed version - 31KB](https://raw.githubusercontent.com/bitbar/finka-js/master/dist/finka.js) And simply add HTML tag: diff --git a/bower.json b/bower.json index 7972f21..490984b 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "finka-js", - "description": "Finka.js", + "description": "Handy tool in nowadays JavaScript jungle", "main": "dist/finka.min.js", "authors": [ "Marek SierociƄski (https://github.com/marverix)", diff --git a/dist/finka.js b/dist/finka.js index 1b8db72..151db1a 100644 --- a/dist/finka.js +++ b/dist/finka.js @@ -1,4 +1,4 @@ -/* Finka.js v0.1.0 | (c) Bitbar Technologies and contributors | https://github.com/bitbar/finka-js/blob/master/LICENSE.md */ +/* Finka.js v0.1.1 | (c) Bitbar Technologies and contributors | https://github.com/bitbar/finka-js/blob/master/LICENSE.md */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory() : typeof define === 'function' && define.amd ? define(factory) : @@ -7,12 +7,7 @@ var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; - function createCommonjsModule(fn, module) { - return module = { exports: {} }, fn(module, module.exports), module.exports; - } - - var global_1 = createCommonjsModule(function (module) { - commonjsGlobal.isNodeJs = module != null && module.exports != null; + commonjsGlobal.isNodeJs = typeof commonjsGlobal.module != 'undefined' && typeof commonjsGlobal.module.exports != 'undefined'; commonjsGlobal.isJSONString = function(str) { try { @@ -62,7 +57,6 @@ commonjsGlobal.xor = function(a, b) { return !a != !b; }; - }); Object.copy = function(src, dst, what) { if(what == null || what.length == 0) { diff --git a/dist/finka.min.js b/dist/finka.min.js index c0dc17c..62034cf 100644 --- a/dist/finka.min.js +++ b/dist/finka.min.js @@ -1,6 +1,6 @@ -/* Finka.js v0.1.0 | (c) Bitbar Technologies and contributors | https://github.com/bitbar/finka-js/blob/master/LICENSE.md */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e():"function"==typeof define&&define.amd?define(e):e()}(0,function(){"use strict";var t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var e;(function(e){t.isNodeJs=null!=e&&null!=e.exports,t.isJSONString=function(t){try{JSON.parse(t)}catch(t){return!1}return!0},t.getLanguage=function(){return isNodeJs?(process.env.LANG||process.env.LANGUAGE||process.env.LC_ALL||process.env.LC_MESSAGES).replace(/^([a-z]{2})_([A-Z]{2}).+$/,(t,e,r)=>e+"-"+r):navigator.language},t.getCountry=function(){return getLanguage().substr(0,2).toUpperCase()},t.parseValue=function(t){if("string"!=typeof t)return t;if(isNumeric(t))return parseFloat(t);var e=t.toLowerCase();return"true"===e||"false"===e?"true"===e:t},t.xor=function(t,e){return!t!=!e}})(e={exports:{}},e.exports);function r(){return function(t){var e=4294967087,r=4294944443,n=12345,o=12345,a=123,i=12345,u=12345,f=123;0===t.length&&(t=[+new Date]);for(var s,c=(s=4022871197,function(t){t=t.toString();for(var e=0;e>>0,s=(r*=s)>>>0,s+=4294967296*(r-=s)}return 2.3283064365386963e-10*(s>>>0)}),h=0;ht.indexOf(e)<0)},Array.prototype.clone=function(){return this.slice(0)},Array.prototype.lookFor=function(t){var e;for(e=0;e0;t--){var e=Math.floor(Math.rand()*(t+1)),r=this[t];this[t]=this[e],this[e]=r}},Array.sortArrayOfObjects=function(t,e,r){var n,o;null==r&&(r=!1),r=r?-1:1,t.sort(function(t,a){return n=t[e],o=a[e],"string"==typeof n&&(n=n.toLowerCase()),"string"==typeof o&&(o=o.toLowerCase()),n>o?1*r:nt.toUpperCase())},String.prototype.lowerFirstLetter=function(){return this.valueOf().replace(/[a-z]/i,t=>t.toLowerCase())},String.prototype.toCamelCase=function(){var t,e,r,n;if((t=this.valueOf()).indexOf("-")<0)return t;for(r=(e=t.split("-"))[0],n=1;n>>0,s=(r*=s)>>>0,s+=4294967296*(r-=s)}return 2.3283064365386963e-10*(s>>>0)}),h=0;he+"-"+r):navigator.language},t.getCountry=function(){return getLanguage().substr(0,2).toUpperCase()},t.parseValue=function(t){if("string"!=typeof t)return t;if(isNumeric(t))return parseFloat(t);var e=t.toLowerCase();return"true"===e||"false"===e?"true"===e:t},t.xor=function(t,e){return!t!=!e},Object.copy=function(t,e,r){if(null==r||0==r.length)for(var n in t)e[n]=t[n];else for(n=0;nt.indexOf(e)<0)},Array.prototype.clone=function(){return this.slice(0)},Array.prototype.lookFor=function(t){var e;for(e=0;e0;t--){var e=Math.floor(Math.rand()*(t+1)),r=this[t];this[t]=this[e],this[e]=r}},Array.sortArrayOfObjects=function(t,e,r){var n,o;null==r&&(r=!1),r=r?-1:1,t.sort(function(t,a){return n=t[e],o=a[e],"string"==typeof n&&(n=n.toLowerCase()),"string"==typeof o&&(o=o.toLowerCase()),n>o?1*r:nt.toUpperCase())},String.prototype.lowerFirstLetter=function(){return this.valueOf().replace(/[a-z]/i,t=>t.toLowerCase())},String.prototype.toCamelCase=function(){var t,e,r,n;if((t=this.valueOf()).indexOf("-")<0)return t;for(r=(e=t.split("-"))[0],n=1;n-1}),Date.SECOND=1e3,Date.MINUTE=60*Date.SECOND,Date.HOUR=60*Date.MINUTE,Date.DAY=24*Date.HOUR,Date.WEEK=7*Date.DAY,Date.TODAY=Date.HOUR*Math.floor(Date.now()/Date.HOUR),Date.YESTERDAY=Date.TODAY-Date.DAY,Date.TOMORROW=Date.TODAY+Date.DAY,Date.DAYAFTERTOMORROW=Date.TOMORROW+Date.DAY,Date.daysFromNow=function(t){return Date.now()+Date.DAY*t},Date.getFormat=function(t){var e,r,n,o;void 0===t&&(t=!0),e=["AF","CN","HU","JP","KP","KR","LT","MN","TW"],r=["BZ","FM","US"];try{n=getCountry()||"US"}catch(t){n="US"}return o=e.indexOf(n)>=0?"y-m-d":r.indexOf(n)>=0?"m/d/y":"d.m.y",1==t&&(o=(o=(o=o.replace("d","dd")).replace("m","mm")).replace("y","yyyy")),o},Date.getTimezoneName=function(){return(new this).toString().match(/\(([^)]+)\)$/)[1]},Date.toHmsFormat=function(t,e,r,n){var o,a,i,u,f,s,c=0;return void 0===e&&(e="round"),void 0===r&&(r="seconds"),f=function(t,e){return t>0?t+e:""},s=function(){u=(o+a+i).trim()},t=parseInt(t),c=void 0!==n&&n?t:Math.round(t/1e3),"hours"==r?(o=f(Math[e](c/3600),"h "),a=f(0,"m "),i=f("0s"),s(),0==u.length&&(u="0h")):"minutes"==r?(o=f(Math.floor(c/3600),"h "),a=f(Math[e](c%3600/60),"m "),i=f("0s"),s(),0==u.length&&(u="0m")):(o=f(Math.floor(c/3600),"h "),a=f(Math.floor(c%3600/60),"m "),i=Math[e](c%3600%60)+"s",s(),0==u.length&&(u="0s")),u},Date.toStopwatchFormat=function(t){var e,r,n,o,a;return t-=e=Math.max(0,t%1e3),e=Math.floor(e/100),t/=1e3,t-=r=Math.max(0,t%60),t/=60,t-=n=Math.max(0,t%60),t/=60,o=Math.max(0,t),a=n.pad(2)+":"+r.pad(2)+"."+e,o>0&&(a=o.pad(2)+":"+a),a},Date.prototype.daysPassed=function(t){if(void 0===t?t=new Date:"number"!=typeof t&&"string"!=typeof t||(t=new Date(t)),!(t instanceof Date))throw"Date.daysPassed: toDate is not instance of Date";return Math.floor(Math.abs((this.getTime()-t.getTime())/864e5))},Date.prototype.toUiTime=function(t){return void 0===t&&(t=!0),t=t?":"+this.getSeconds().pad(2):"",this.getHours().pad(2)+":"+this.getMinutes().pad(2)+t},Date.prototype.toCustomDate=function(t){return t=(t=(t=t.replace("d",this.getDate().pad(2))).replace("m",(this.getMonth()+1).pad(2))).replace("y",this.getFullYear())},Date.prototype.toUiDate=function(){return this.toCustomDate(Date.getFormat(!1))},Date.prototype.toUiDateTime=function(t){return this.toUiDate()+" "+this.toUiTime(t)},Date.prototype.toInputDateFormat=function(){return this.toCustomDate("y-m-d")},Date.prototype.toInputTimeFormat=function(){return this.toUiTime(!1)},Date.prototype.addTime=function(t){return this.setTime(this.getTime()+t)};var n=Object.freeze({default:r});function o(t,e){var r=t[0],n=t[1],o=t[2],a=t[3];n=s(n=s(n=s(n=s(n=f(n=f(n=f(n=f(n=u(n=u(n=u(n=u(n=i(n=i(n=i(n=i(n,o=i(o,a=i(a,r=i(r,n,o,a,e[0],7,-680876936),n,o,e[1],12,-389564586),r,n,e[2],17,606105819),a,r,e[3],22,-1044525330),o=i(o,a=i(a,r=i(r,n,o,a,e[4],7,-176418897),n,o,e[5],12,1200080426),r,n,e[6],17,-1473231341),a,r,e[7],22,-45705983),o=i(o,a=i(a,r=i(r,n,o,a,e[8],7,1770035416),n,o,e[9],12,-1958414417),r,n,e[10],17,-42063),a,r,e[11],22,-1990404162),o=i(o,a=i(a,r=i(r,n,o,a,e[12],7,1804603682),n,o,e[13],12,-40341101),r,n,e[14],17,-1502002290),a,r,e[15],22,1236535329),o=u(o,a=u(a,r=u(r,n,o,a,e[1],5,-165796510),n,o,e[6],9,-1069501632),r,n,e[11],14,643717713),a,r,e[0],20,-373897302),o=u(o,a=u(a,r=u(r,n,o,a,e[5],5,-701558691),n,o,e[10],9,38016083),r,n,e[15],14,-660478335),a,r,e[4],20,-405537848),o=u(o,a=u(a,r=u(r,n,o,a,e[9],5,568446438),n,o,e[14],9,-1019803690),r,n,e[3],14,-187363961),a,r,e[8],20,1163531501),o=u(o,a=u(a,r=u(r,n,o,a,e[13],5,-1444681467),n,o,e[2],9,-51403784),r,n,e[7],14,1735328473),a,r,e[12],20,-1926607734),o=f(o,a=f(a,r=f(r,n,o,a,e[5],4,-378558),n,o,e[8],11,-2022574463),r,n,e[11],16,1839030562),a,r,e[14],23,-35309556),o=f(o,a=f(a,r=f(r,n,o,a,e[1],4,-1530992060),n,o,e[4],11,1272893353),r,n,e[7],16,-155497632),a,r,e[10],23,-1094730640),o=f(o,a=f(a,r=f(r,n,o,a,e[13],4,681279174),n,o,e[0],11,-358537222),r,n,e[3],16,-722521979),a,r,e[6],23,76029189),o=f(o,a=f(a,r=f(r,n,o,a,e[9],4,-640364487),n,o,e[12],11,-421815835),r,n,e[15],16,530742520),a,r,e[2],23,-995338651),o=s(o,a=s(a,r=s(r,n,o,a,e[0],6,-198630844),n,o,e[7],10,1126891415),r,n,e[14],15,-1416354905),a,r,e[5],21,-57434055),o=s(o,a=s(a,r=s(r,n,o,a,e[12],6,1700485571),n,o,e[3],10,-1894986606),r,n,e[10],15,-1051523),a,r,e[1],21,-2054922799),o=s(o,a=s(a,r=s(r,n,o,a,e[8],6,1873313359),n,o,e[15],10,-30611744),r,n,e[6],15,-1560198380),a,r,e[13],21,1309151649),o=s(o,a=s(a,r=s(r,n,o,a,e[4],6,-145523070),n,o,e[11],10,-1120210379),r,n,e[2],15,718787259),a,r,e[9],21,-343485551),t[0]=g(r,t[0]),t[1]=g(n,t[1]),t[2]=g(o,t[2]),t[3]=g(a,t[3])}function a(t,e,r,n,o,a){return e=g(g(e,t),g(n,a)),g(e<>>32-o,r)}function i(t,e,r,n,o,i,u){return a(e&r|~e&n,t,e,o,i,u)}function u(t,e,r,n,o,i,u){return a(e&n|r&~n,t,e,o,i,u)}function f(t,e,r,n,o,i,u){return a(e^r^n,t,e,o,i,u)}function s(t,e,r,n,o,i,u){return a(r^(e|~n),t,e,o,i,u)}function c(t){var e,r=[];for(e=0;e<64;e+=4)r[e>>2]=t.charCodeAt(e)+(t.charCodeAt(e+1)<<8)+(t.charCodeAt(e+2)<<16)+(t.charCodeAt(e+3)<<24);return r}var h="0123456789abcdef".split("");function p(t){for(var e="",r=0;r<4;r++)e+=h[t>>8*r+4&15]+h[t>>8*r&15];return e}function l(t){return function(t){for(var e=0;e>2]|=t.charCodeAt(e)<<(e%4<<3);if(a[e>>2]|=128<<(e%4<<3),e>55)for(o(n,a),e=0;e<16;e++)a[e]=0;return a[14]=8*r,o(n,a),n}(t))}function g(t,e){return t+e&4294967295}if("5d41402abc4b2a76b9719d911017c592"!=l("hello")){function g(t,e){var r=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(r>>16)<<16|65535&r}}var d=Object.freeze({default:l}),y=n&&r||n,m=d&&l||d;t.md5=m,Math.MRG32k2a=new y,Math.rand=function(){return this.MRG32k2a()},Math.roundTo=function(t,e){if((""+t).includes("e")){var r=(""+t).split("e"),n="";return+r[1]+e>0&&(n="+"),+(Math.round(+r[0]+"e"+n+(+r[1]+e))+"e-"+e)}return+(Math.round(t+"e+"+e)+"e-"+e)},Math.median=function(t){if(0===t.length)return 0;t.sort(function(t,e){return t-e});var e=Math.floor(t.length/2);return t.length%2?t[e]:(t[e-1]+t[e])/2},Math.sum=function(t){return 0===t.length?0:t.reduce(function(t,e){return t+e})},Math.avg=function(t){return 0===t.length?0:Math.sum(t)/t.length},RegExp.escapeString=function(t){return t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},Promise.isPromise=function(t){return"object"==typeof t&&(t instanceof Promise||"function"==typeof t.then)};var v={};if(t.FileSize=v,v.B=1,v.KB=1024*v.B,v.MB=1024*v.KB,v.GB=1024*v.MB,v.TB=1024*v.GB,t.isWebpSupported=!1,null!=Image){var D=new Image;D.onload=function(){t.isWebpSupported=D.width>0&&D.height>0},D.src="data:image/webp;base64,UklGRhoAAABXRUJQVlA4TA0AAAAvAAAAEAcQERGIiP4HAA=="}null!=HTMLCanvasElement&&(HTMLCanvasElement.prototype.defaultDataType=function(){return global.isWebpSupported?"image/webp":"image/jpeg"},HTMLCanvasElement.prototype.toBase64=function(t){return void 0===t&&(t=this.defaultDataType()),this.toDataURL(t)},HTMLCanvasElement.prototype.toAlphaBase64=function(){var t="image/png";return global.isWebpSupported,this.toBase64(t)},HTMLCanvasElement.prototype.toBlobType=function(t,e){var r,n,o,a;if(void 0===e&&(e=this.defaultDataType()),"function"==typeof this.toBlob)this.toBlob(t,e,.9);else if("function"==typeof this.msToBlob)t(this.msToBlob());else{for(r=this.toBase64(e),o=[],r=(n=atob(r.split(",")[1])).length,a=0;a-1}),Date.SECOND=1e3,Date.MINUTE=60*Date.SECOND,Date.HOUR=60*Date.MINUTE,Date.DAY=24*Date.HOUR,Date.WEEK=7*Date.DAY,Date.TODAY=Date.HOUR*Math.floor(Date.now()/Date.HOUR),Date.YESTERDAY=Date.TODAY-Date.DAY,Date.TOMORROW=Date.TODAY+Date.DAY,Date.DAYAFTERTOMORROW=Date.TOMORROW+Date.DAY,Date.daysFromNow=function(t){return Date.now()+Date.DAY*t},Date.getFormat=function(t){var e,r,n,o;void 0===t&&(t=!0),e=["AF","CN","HU","JP","KP","KR","LT","MN","TW"],r=["BZ","FM","US"];try{n=getCountry()||"US"}catch(t){n="US"}return o=e.indexOf(n)>=0?"y-m-d":r.indexOf(n)>=0?"m/d/y":"d.m.y",1==t&&(o=(o=(o=o.replace("d","dd")).replace("m","mm")).replace("y","yyyy")),o},Date.getTimezoneName=function(){return(new this).toString().match(/\(([^)]+)\)$/)[1]},Date.toHmsFormat=function(t,e,r,n){var o,a,i,u,f,s,c=0;return void 0===e&&(e="round"),void 0===r&&(r="seconds"),f=function(t,e){return t>0?t+e:""},s=function(){u=(o+a+i).trim()},t=parseInt(t),c=void 0!==n&&n?t:Math.round(t/1e3),"hours"==r?(o=f(Math[e](c/3600),"h "),a=f(0,"m "),i=f("0s"),s(),0==u.length&&(u="0h")):"minutes"==r?(o=f(Math.floor(c/3600),"h "),a=f(Math[e](c%3600/60),"m "),i=f("0s"),s(),0==u.length&&(u="0m")):(o=f(Math.floor(c/3600),"h "),a=f(Math.floor(c%3600/60),"m "),i=Math[e](c%3600%60)+"s",s(),0==u.length&&(u="0s")),u},Date.toStopwatchFormat=function(t){var e,r,n,o,a;return t-=e=Math.max(0,t%1e3),e=Math.floor(e/100),t/=1e3,t-=r=Math.max(0,t%60),t/=60,t-=n=Math.max(0,t%60),t/=60,o=Math.max(0,t),a=n.pad(2)+":"+r.pad(2)+"."+e,o>0&&(a=o.pad(2)+":"+a),a},Date.prototype.daysPassed=function(t){if(void 0===t?t=new Date:"number"!=typeof t&&"string"!=typeof t||(t=new Date(t)),!(t instanceof Date))throw"Date.daysPassed: toDate is not instance of Date";return Math.floor(Math.abs((this.getTime()-t.getTime())/864e5))},Date.prototype.toUiTime=function(t){return void 0===t&&(t=!0),t=t?":"+this.getSeconds().pad(2):"",this.getHours().pad(2)+":"+this.getMinutes().pad(2)+t},Date.prototype.toCustomDate=function(t){return t=(t=(t=t.replace("d",this.getDate().pad(2))).replace("m",(this.getMonth()+1).pad(2))).replace("y",this.getFullYear())},Date.prototype.toUiDate=function(){return this.toCustomDate(Date.getFormat(!1))},Date.prototype.toUiDateTime=function(t){return this.toUiDate()+" "+this.toUiTime(t)},Date.prototype.toInputDateFormat=function(){return this.toCustomDate("y-m-d")},Date.prototype.toInputTimeFormat=function(){return this.toUiTime(!1)},Date.prototype.addTime=function(t){return this.setTime(this.getTime()+t)};var r=Object.freeze({default:e});function n(t,e){var r=t[0],n=t[1],o=t[2],s=t[3];n=f(n=f(n=f(n=f(n=u(n=u(n=u(n=u(n=i(n=i(n=i(n=i(n=a(n=a(n=a(n=a(n,o=a(o,s=a(s,r=a(r,n,o,s,e[0],7,-680876936),n,o,e[1],12,-389564586),r,n,e[2],17,606105819),s,r,e[3],22,-1044525330),o=a(o,s=a(s,r=a(r,n,o,s,e[4],7,-176418897),n,o,e[5],12,1200080426),r,n,e[6],17,-1473231341),s,r,e[7],22,-45705983),o=a(o,s=a(s,r=a(r,n,o,s,e[8],7,1770035416),n,o,e[9],12,-1958414417),r,n,e[10],17,-42063),s,r,e[11],22,-1990404162),o=a(o,s=a(s,r=a(r,n,o,s,e[12],7,1804603682),n,o,e[13],12,-40341101),r,n,e[14],17,-1502002290),s,r,e[15],22,1236535329),o=i(o,s=i(s,r=i(r,n,o,s,e[1],5,-165796510),n,o,e[6],9,-1069501632),r,n,e[11],14,643717713),s,r,e[0],20,-373897302),o=i(o,s=i(s,r=i(r,n,o,s,e[5],5,-701558691),n,o,e[10],9,38016083),r,n,e[15],14,-660478335),s,r,e[4],20,-405537848),o=i(o,s=i(s,r=i(r,n,o,s,e[9],5,568446438),n,o,e[14],9,-1019803690),r,n,e[3],14,-187363961),s,r,e[8],20,1163531501),o=i(o,s=i(s,r=i(r,n,o,s,e[13],5,-1444681467),n,o,e[2],9,-51403784),r,n,e[7],14,1735328473),s,r,e[12],20,-1926607734),o=u(o,s=u(s,r=u(r,n,o,s,e[5],4,-378558),n,o,e[8],11,-2022574463),r,n,e[11],16,1839030562),s,r,e[14],23,-35309556),o=u(o,s=u(s,r=u(r,n,o,s,e[1],4,-1530992060),n,o,e[4],11,1272893353),r,n,e[7],16,-155497632),s,r,e[10],23,-1094730640),o=u(o,s=u(s,r=u(r,n,o,s,e[13],4,681279174),n,o,e[0],11,-358537222),r,n,e[3],16,-722521979),s,r,e[6],23,76029189),o=u(o,s=u(s,r=u(r,n,o,s,e[9],4,-640364487),n,o,e[12],11,-421815835),r,n,e[15],16,530742520),s,r,e[2],23,-995338651),o=f(o,s=f(s,r=f(r,n,o,s,e[0],6,-198630844),n,o,e[7],10,1126891415),r,n,e[14],15,-1416354905),s,r,e[5],21,-57434055),o=f(o,s=f(s,r=f(r,n,o,s,e[12],6,1700485571),n,o,e[3],10,-1894986606),r,n,e[10],15,-1051523),s,r,e[1],21,-2054922799),o=f(o,s=f(s,r=f(r,n,o,s,e[8],6,1873313359),n,o,e[15],10,-30611744),r,n,e[6],15,-1560198380),s,r,e[13],21,1309151649),o=f(o,s=f(s,r=f(r,n,o,s,e[4],6,-145523070),n,o,e[11],10,-1120210379),r,n,e[2],15,718787259),s,r,e[9],21,-343485551),t[0]=l(r,t[0]),t[1]=l(n,t[1]),t[2]=l(o,t[2]),t[3]=l(s,t[3])}function o(t,e,r,n,o,a){return e=l(l(e,t),l(n,a)),l(e<>>32-o,r)}function a(t,e,r,n,a,i,u){return o(e&r|~e&n,t,e,a,i,u)}function i(t,e,r,n,a,i,u){return o(e&n|r&~n,t,e,a,i,u)}function u(t,e,r,n,a,i,u){return o(e^r^n,t,e,a,i,u)}function f(t,e,r,n,a,i,u){return o(r^(e|~n),t,e,a,i,u)}function s(t){var e,r=[];for(e=0;e<64;e+=4)r[e>>2]=t.charCodeAt(e)+(t.charCodeAt(e+1)<<8)+(t.charCodeAt(e+2)<<16)+(t.charCodeAt(e+3)<<24);return r}var c="0123456789abcdef".split("");function h(t){for(var e="",r=0;r<4;r++)e+=c[t>>8*r+4&15]+c[t>>8*r&15];return e}function p(t){return function(t){for(var e=0;e>2]|=t.charCodeAt(e)<<(e%4<<3);if(a[e>>2]|=128<<(e%4<<3),e>55)for(n(o,a),e=0;e<16;e++)a[e]=0;return a[14]=8*r,n(o,a),o}(t))}function l(t,e){return t+e&4294967295}if("5d41402abc4b2a76b9719d911017c592"!=p("hello")){function l(t,e){var r=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(r>>16)<<16|65535&r}}var g=Object.freeze({default:p}),d=r&&e||r,y=g&&p||g;t.md5=y,Math.MRG32k2a=new d,Math.rand=function(){return this.MRG32k2a()},Math.roundTo=function(t,e){if((""+t).includes("e")){var r=(""+t).split("e"),n="";return+r[1]+e>0&&(n="+"),+(Math.round(+r[0]+"e"+n+(+r[1]+e))+"e-"+e)}return+(Math.round(t+"e+"+e)+"e-"+e)},Math.median=function(t){if(0===t.length)return 0;t.sort(function(t,e){return t-e});var e=Math.floor(t.length/2);return t.length%2?t[e]:(t[e-1]+t[e])/2},Math.sum=function(t){return 0===t.length?0:t.reduce(function(t,e){return t+e})},Math.avg=function(t){return 0===t.length?0:Math.sum(t)/t.length},RegExp.escapeString=function(t){return t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},Promise.isPromise=function(t){return"object"==typeof t&&(t instanceof Promise||"function"==typeof t.then)};var m={};if(t.FileSize=m,m.B=1,m.KB=1024*m.B,m.MB=1024*m.KB,m.GB=1024*m.MB,m.TB=1024*m.GB,t.isWebpSupported=!1,null!=Image){var v=new Image;v.onload=function(){t.isWebpSupported=v.width>0&&v.height>0},v.src="data:image/webp;base64,UklGRhoAAABXRUJQVlA4TA0AAAAvAAAAEAcQERGIiP4HAA=="}null!=HTMLCanvasElement&&(HTMLCanvasElement.prototype.defaultDataType=function(){return global.isWebpSupported?"image/webp":"image/jpeg"},HTMLCanvasElement.prototype.toBase64=function(t){return void 0===t&&(t=this.defaultDataType()),this.toDataURL(t)},HTMLCanvasElement.prototype.toAlphaBase64=function(){var t="image/png";return global.isWebpSupported,this.toBase64(t)},HTMLCanvasElement.prototype.toBlobType=function(t,e){var r,n,o,a;if(void 0===e&&(e=this.defaultDataType()),"function"==typeof this.toBlob)this.toBlob(t,e,.9);else if("function"==typeof this.msToBlob)t(this.msToBlob());else{for(r=this.toBase64(e),o=[],r=(n=atob(r.split(",")[1])).length,a=0;a0))throw"scale must be a positive number <1 ";for(e=t*t,r=this.width,n=this.height,u=Math.floor(r*t),f=Math.floor(n*t),o=0,a=0,i=0,s=0,h=0,M=0,b=0,c=0,p=0,l=0,g=0,d=0,y=0,m=0,v=0,D=!1,A=!1,O=this.getContext("2d").getImageData(0,0,r,n).data,C=new Float32Array(4*r*n),T=w=L=N=0,a=0;a + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/package.json b/package.json index e6fd665..d0a28d4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "finka-js", - "version": "0.1.0", - "description": "Finka.js", + "version": "0.1.1", + "description": "Handy tool in nowadays JavaScript jungle", "main": "dist/finka.min.js", "scripts": { "build": "npx rollup -c", diff --git a/src/global.js b/src/global.js index c0005ef..5a1220a 100644 --- a/src/global.js +++ b/src/global.js @@ -1,4 +1,4 @@ -global.isNodeJs = module != null && module.exports != null; +global.isNodeJs = typeof global.module != 'undefined' && typeof global.module.exports != 'undefined'; global.isJSONString = function(str) { try {