jinbi-utils 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +19 -0
- package/.cz-config.js +55 -0
- package/.dockerignore +3 -0
- package/.editorconfig +12 -0
- package/.eslintignore +8 -0
- package/.eslintrc.js +54 -0
- package/Dockerfile +3 -0
- package/README.md +160 -0
- package/api-extractor.json +15 -0
- package/commitlint.config.js +3 -0
- package/dist/index.esm.js +846 -0
- package/dist/index.esm.min.js +15 -0
- package/dist/index.umd.js +886 -0
- package/dist/index.umd.min.js +16 -0
- package/docs/assets/css/main.css +2679 -0
- package/docs/assets/images/icons.png +0 -0
- package/docs/assets/images/icons@2x.png +0 -0
- package/docs/assets/images/widgets.png +0 -0
- package/docs/assets/images/widgets@2x.png +0 -0
- package/docs/assets/js/main.js +1 -0
- package/docs/assets/js/search.json +1 -0
- package/docs/globals.html +144 -0
- package/docs/index.html +147 -0
- package/docs/interfaces/file.compressimgqualitycallback.html +212 -0
- package/docs/interfaces/file.compressimgscalecallback.html +206 -0
- package/docs/interfaces/file.exportbyblobparams.html +294 -0
- package/docs/interfaces/file.filesizeobject.html +227 -0
- package/docs/interfaces/file.genexportbyblobparams.html +237 -0
- package/docs/modules/common.html +188 -0
- package/docs/modules/date.html +364 -0
- package/docs/modules/file.html +452 -0
- package/docs/modules/number.html +356 -0
- package/docs/modules/object.html +245 -0
- package/docs/modules/print.html +183 -0
- package/docs/modules/string.html +352 -0
- package/docs/modules/validate.html +389 -0
- package/jest.config.js +15 -0
- package/package.json +75 -0
- package/rollup.config.js +65 -0
- package/src/common/index.ts +285 -0
- package/src/date/index.ts +141 -0
- package/src/file/index.ts +296 -0
- package/src/http/http.ts +0 -0
- package/src/http/httpEnums.ts +62 -0
- package/src/index.ts +8 -0
- package/src/number/index.ts +190 -0
- package/src/object/index.ts +54 -0
- package/src/print/index.ts +102 -0
- package/src/string/index.ts +111 -0
- package/src/validate/index.ts +78 -0
- package/src/wecom/wecom.ts +75 -0
- package/test/common/index.test.ts +19 -0
- package/test/date/index.test.ts +107 -0
- package/test/file/index.test.ts +104 -0
- package/test/number/index.test.ts +108 -0
- package/test/object/index.test.ts +20 -0
- package/test/string/index.test.ts +82 -0
- package/tsconfig.json +39 -0
- package/typedoc.json +9 -0
- package/types/common/index.d.ts +17 -0
- package/types/date/index.d.ts +60 -0
- package/types/file/index.d.ts +96 -0
- package/types/index.d.ts +8 -0
- package/types/number/index.d.ts +62 -0
- package/types/object/index.d.ts +25 -0
- package/types/print/index.d.ts +11 -0
- package/types/string/index.d.ts +45 -0
- package/types/validate/index.d.ts +45 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function t(t){return null===t||""===t||void 0===t}function e(t){return"string"==typeof t?t.replace(/-/g,"/"):t}function n(t){return t?new Date(e(t)):new Date}function r(t,n){void 0===t&&(t=Date.now()),void 0===n&&(n="yyyy-MM-dd HH:mm:ss"),t=e(t);var r={"M+":(t=new Date(t)).getMonth()+1,"d+":t.getDate(),"h+":t.getHours()%12==0?12:t.getHours()%12,"H+":t.getHours(),"m+":t.getMinutes(),"s+":t.getSeconds(),"q+":Math.floor((t.getMonth()+3)/3),S:t.getMilliseconds()};return/(y+)/.test(n)&&(n=n.replace(RegExp.$1,(""+t.getFullYear()).substr(4-RegExp.$1.length))),Object.keys(r).forEach((function(t){new RegExp("("+t+")").test(n)&&(n=n.replace(RegExp.$1,1===RegExp.$1.length?r[t]:("00"+r[t]).substr((""+r[t]).length)))})),n}function o(n,o,i){if(void 0===o&&(o="yyyy年MM月dd日 HH时mm分ss秒"),void 0===i&&(i="-"),t(n))return i;n=e(n);var a=new Date(n),u=(Date.now()-a.getTime())/1e3;return u<0?n:u<30?"刚刚":u<3600?Math.ceil(u/60)+"分钟前":u<86400?Math.floor(u/3600)+"小时前":u<172800?"1天前":r(n,o)}function i(n,o,i){if(void 0===o&&(o=0),void 0===i&&(i="yyyy-MM-dd"),t(n))return"-";n=e(n);var a=new Date(n);return a.setDate(a.getDate()+Number(o)),r(a,i)}
|
|
2
|
+
/*! *****************************************************************************
|
|
3
|
+
Copyright (c) Microsoft Corporation.
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
10
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
11
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
12
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
+
***************************************************************************** */function a(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}c((r=r.apply(t,e||[])).next())}))}function u(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}function c(e,n){if(void 0===n&&(n="-"),t(e))return n;var r=e.toString();return r.includes(".")||(r+="."),r.replace(/\d(?=(\d{3})+\.)/g,(function(t){return t+","})).replace(/\.$/,"")}function f(e){void 0===e&&(e="");if(t(e))return"";if(Number(e)>=1e15)return e;var n,r,o,i=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],a=["","拾","佰","仟"],u=["","万","亿","兆"],c=["角","分","毫","厘"],f="";if("0"===(e=parseFloat(e).toString()))return f=i[0]+"元整";if(-1===(e=e.toString()).indexOf(".")?(n=e,r=""):(n=(o=e.split("."))[0],r=o[1].substr(0,4)),parseInt(n,10)>0){for(var s=0,l=n.length,d=0;d<l;d+=1){var g=n.substr(d,1),h=l-d-1,p=h/4,v=h%4;"0"===g?s+=1:(s>0&&(f+=i[0]),s=0,f+=i[parseInt(g,10)]+a[v]),0===v&&s<4&&(f+=u[p])}f+="元"}if(""!==r){var b=r.length;for(d=0;d<b;d+=1){var w=r.substr(d,1);"0"!==w&&(f+=i[Number(w)]+c[d])}}return""===f?f+=i[0]+"元整":""===r&&(f+="整"),f}function s(t,e){void 0===e&&(e=2);var n=parseFloat(String(t));if(Number.isNaN(n))return"";var r=(n=Math.round(Number(t)*Math.pow(10,e))/Math.pow(10,e)).toString(),o=r.indexOf(".");for(o<0&&(o=r.length,r+=".");r.length<=o+e;)r+="0";return r}function l(e,n){if(void 0===n&&(n=0),t(e))return e;var r=Math.pow(10,n),o=Number(e)*r;return Math.ceil(o)/r}function d(e,n){if(void 0===n&&(n=0),t(e))return e;var r=Math.pow(10,n),o=Number(e)*r;return Math.floor(o)/r}function g(t,e){void 0===e&&(e="B");var n=["B","KB","MB","GB","TB"],r=n.indexOf(e.toUpperCase());for(r=-1===r?0:r;t>=1024&&r<n.length;)t/=1024,r+=1;return{size:t,unit:n[r]}}function h(e,n,r){if(void 0===n&&(n="B"),void 0===r&&(r="-"),t(e))return r;var o=g(parseFloat(e.toString()),n);return""+l(o.size,2)+o.unit}function p(t){for(var e=t.match(/:(.*?);/)[1],n=window.atob(t.split(",")[1]),r=new ArrayBuffer(n.length),o=new Uint8Array(r),i=0;i<n.length;i+=1)o[i]=n.charCodeAt(i);return new Blob([r],{type:e})}function v(t){return new Promise((function(e,n){var r=new FileReader;r.onload=function(t){t&&t.target?e(t.target.result):n(t)},r.onerror=function(t){n(t)},r.readAsDataURL(t)}))}function b(t,e,n){return new Promise((function(r,o){var i=parseFloat((t.size/1024/1024).toString()),a=new FileReader;a.onload=function(a){var u=new Image;u.onload=function(){var o=u.width,a=u.height,c=document.createElement("canvas"),f=c.getContext("2d"),s=e?e(o,a):1;(Number.isNaN(s)||"number"!=typeof s)&&(s=1);var l=n?n(i,s,o,a):1;if((Number.isNaN(l)||"number"!=typeof l)&&(l=1),f){var d=parseInt((o*s).toString(),10),g=parseInt((a*s).toString(),10);c.setAttribute("width",d.toString()),c.setAttribute("height",g.toString()),f.drawImage(u,0,0,d,g)}var h=c.toDataURL(t.type,l);r(p(h))},u.onerror=function(t){o(t)},a.target&&(u.src=a.target.result)},a.onerror=function(t){o(t)},a.readAsDataURL(t)}))}function w(t){var e=t.axiosRequest,n=t.notWithCredentials,r=void 0===n?[]:n;return function(t){var n=this,o=t.filename,i=t.url,c=t.data,f=void 0===c?{}:c,s=t.params,l=void 0===s?{}:s,d=t.method,g=void 0===d?"post":d;return new Promise((function(t,c){e({method:g,url:i,data:f,params:l,responseType:"blob",config:{withCredentials:r.some((function(t){return!i.includes(t)}))}}).then((function(e){return a(n,void 0,void 0,(function(){var n,r,i,a,f,s,l,d,g,h;return u(this,(function(u){switch(u.label){case 0:return"application/json"!==(n=null==e?void 0:e.data).type?[3,1]:((r=new FileReader).readAsText(n,"utf-8"),r.onload=function(){var t={};try{t=JSON.parse(r.result)}catch(e){t=n}c(t)},[3,3]);case 1:try{i=e.headers,a=i["content-disposition"],f=decodeURIComponent(a.split(";")[1].split("filename=")[1]),o&&!o.includes(".")?(s=f.split("."),l=s[s.length-1],o+="."+l):o||(o=f)}catch(t){o||(o="download.xlsx")}return d=new Blob([e.data]),g=document.createElement("a"),[4,v(d)];case 2:h=u.sent(),g.href=h,g.download=o,document.body.appendChild(g),g.click(),document.body.removeChild(g),t(e),u.label=3;case 3:return[2]}}))}))})).catch((function(t){c(t)}))}))}}function y(t,e){var n=Object.keys,r=typeof t;return t&&e&&"object"===r&&r===typeof e?n(t).length===n(e).length&&n(t).every((function(n){return y(t[n],e[n])})):t===e}function m(t,e,n,r,o){if(void 0===o&&(o=[]),o.push(t),t[n]===e)throw"GOT IT!";if(t[r]&&t[r].length>0)for(var i=0;i<t[r].length;i++)m(t[r][i],e,n,r,o);o.pop()}function S(t,e,n,r){var o=[];try{for(var i=0;i<n.length;i++)m(n[i],t,e,r,o)}catch(t){return o}}function M(t){return/^(https?:|mailto:|tel:)/.test(t)}function x(t){if(!t)return t;return t.replace(/^\s+|\s+$/g,"")}function N(t){return/^0?(13[0-9]|14[5-9]|15[012356789]|166|17[0-8]|18[0-9]|19[8-9])[0-9]{8}$/.test(t.toString())}function D(t){return t=t.toString(),/^1/.test(t)&&11===t.length}function R(t){return/^0[1-9][0-9]{1,2}-[2-8][0-9]{6,7}$/.test(String(t))}function A(t){return/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(t)}function $(t){return/^[1-9][0-9]{4,9}$/gim.test(String(t))}function B(e,n){return void 0===n&&(n="-"),t(e)?n:e}function C(e,n,r){if(void 0===n&&(n=" "),void 0===r&&(r="-"),t(e))return r;if(11!==e.toString().length)return e;var o=e.toString().replace(/[^\d]/g,"").split(""),i="";return o.forEach((function(t,e){3!==e&&7!==e||(i+=n),i+=t})),i}function E(e,n){if(void 0===n&&(n=""),t(e))return n;if(11!==e.toString().length)return e;var r=e.toString();return r.substr(0,3)+"****"+r.substr(7,11)}function F(e,n){return void 0===n&&(n=""),t(e)?n:e.toString().replace(/\s/g,"").replace(/(.{4})/g,"$1 ")}function H(){for(var t=[],e=65;e<91;e+=1)t.push(String.fromCharCode(e));return t}export{i as addDays,v as blobToDataURL,g as calcFileSize,l as ceil,e as compatibleDate,b as compressImg,f as convertCurrency,p as dataURLtoBlob,y as deepEqual,h as fileSizeFormat,S as findNodePath,d as floor,F as formatBank,B as formatEmptyValue,s as formatFloat,C as formatPhone,E as formatPhoneHide,r as formatTime,o as fromNow,w as genExportByBlob,H as generateEnglishLetters,A as isEmail,t as isEmpty,M as isExternal,N as isMobile,D as isMobileSimple,$ as isQQ,R as isTelephone,n as newDate,c as toThousands,x as trimVal};
|