lgutils 1.3.3 → 1.3.5

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/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  export declare const accAdd: (arg1: number, arg2: number) => number;
3
2
 
4
3
  export declare const accDiv: (arg1: number, arg2: number) => number;
@@ -13,7 +12,7 @@ export declare const DATE_FORMAT = "YYYY/MM/DD";
13
12
 
14
13
  export declare function digitCnUppercase(n: number): string;
15
14
 
16
- export declare const download: (data: string, strFileName?: string, strMimeType?: string, isImgUrl?: boolean | undefined) => boolean | undefined;
15
+ export declare const download: (data: string, strFileName?: string, strMimeType?: string, isImgUrl?: boolean | undefined) => true | undefined;
17
16
 
18
17
  export declare const fileReaderToBase64: (target: any) => (cb: (p: any) => void) => void;
19
18
 
@@ -354,20 +354,19 @@ const download = (data, strFileName = 'download', strMimeType = 'application/oct
354
354
  const fn = strFileName;
355
355
  let blob = null;
356
356
  let fr = null;
357
- const d2b = (u) => {
358
- const p = u.split(/[:;,]/);
359
- const t = p[1];
360
- const dec = p[2] === 'base64' ? atob : decodeURIComponent;
361
- const bin = dec(p.pop());
362
- const mx = bin.length;
363
- let i = 0;
364
- const uia = new Uint8Array(mx);
365
- for (i; i < mx; ++i)
366
- uia[i] = bin.charCodeAt(i);
367
- return new B([uia], {
368
- type: t
369
- });
370
- };
357
+ // const d2b = (u: any) => {
358
+ // const p = u.split(/[:;,]/)
359
+ // const t = p[1]
360
+ // const dec = p[2] === 'base64' ? atob : decodeURIComponent
361
+ // const bin = dec(p.pop())
362
+ // const mx = bin.length
363
+ // let i = 0
364
+ // const uia = new Uint8Array(mx)
365
+ // for (i; i < mx; ++i) uia[i] = bin.charCodeAt(i)
366
+ // return new B([uia], {
367
+ // type: t
368
+ // })
369
+ // }
371
370
  const saver = (url, winMode) => {
372
371
  if ('download' in a) {
373
372
  // html5 A[download]
@@ -405,9 +404,10 @@ const download = (data, strFileName = 'download', strMimeType = 'application/oct
405
404
  // }
406
405
  // go ahead and download dataURLs right away
407
406
  if (String(x).match(/^data\:[\w+\-]+\/[\w+\-]+[,;]/)) {
408
- return navigator.msSaveBlob // IE10 can't do a[download], only Blobs:
409
- ? navigator.msSaveBlob(d2b(x), fn)
410
- : saver(x); // everyone else can save dataURLs un-processed
407
+ return saver(x);
408
+ // return navigator?.msSaveBlob // IE10 can't do a[download], only Blobs:
409
+ // ? navigator?.msSaveBlob(d2b(x), fn)
410
+ // : saver(x) // everyone else can save dataURLs un-processed
411
411
  } // end if dataURL passed?
412
412
  try {
413
413
  blob =
@@ -424,10 +424,10 @@ const download = (data, strFileName = 'download', strMimeType = 'application/oct
424
424
  // blob = b.getBlob(m); // the blob
425
425
  // }
426
426
  }
427
- if (navigator.msSaveBlob) {
428
- // IE10+ : (has Blob, but not a[download] or URL)
429
- return navigator.msSaveBlob(blob, fn);
430
- }
427
+ // if (navigator.msSaveBlob) {
428
+ // // IE10+ : (has Blob, but not a[download] or URL)
429
+ // return navigator.msSaveBlob(blob, fn)
430
+ // }
431
431
  if (self.URL) {
432
432
  // simple fast and modern way using Blob and URL:
433
433
  // saver(self.URL.createObjectURL(blob), true);
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("qs"),e=require("d3-format"),r=require("lodash/omit"),o=require("moment");function a(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var s=a(r),n=a(o);const i="undefined"!=typeof window,l=t=>t&&"number"==typeof t.size&&"string"==typeof t.type&&"function"==typeof t.slice,c=i?localStorage:{};let p={};const d=e.format(",.2f"),m=e.format(","),u=e.format(".2%"),f=g(d),h=g(m),x=g(u);function g(t){return e=>w(e)?S:t(e)}const y=t=>d(t/1e4),M=g(y),b=(D="增信",function(t){return t?D:"不"+D});var D;const w=t=>null==t||""===t,S="——";function Y(t,e="YYYY-MM-DD"){return n(new Date(t)).format(e)}const A=g(Y),v={d:"天",m:"个月",y:"年"};function R(t){return t?`${parseInt(t,10)}${v[t.slice(-1).toLowerCase()]}`:t}const O=g(R);exports.DATE_FORMAT="YYYY/MM/DD",exports.FORMAT_DATE="YYYY-MM-DD",exports.FORMAT_TIME="YYYY-MM-DD HH:mm:ss",exports.NIL_STRING=S,exports.accAdd=(t,e)=>{let r,o,a;try{r=t.toString().split(".")[1].length}catch(s){r=0}try{o=e.toString().split(".")[1].length}catch(s){o=0}return a=Math.pow(10,Math.max(r,o)),(t*a+e*a)/a},exports.accDiv=(t,e)=>{let r,o,a=0,s=0;try{a=t.toString().split(".")[1].length}catch(n){}try{s=e.toString().split(".")[1].length}catch(n){}return r=Number(t.toString().replace(".","")),o=Number(e.toString().replace(".","")),r/o*Math.pow(10,s-a)},exports.accMul=(t,e)=>{let r=0,o=t.toString(),a=e.toString();try{r+=o.split(".")[1].length}catch(s){}try{r+=a.split(".")[1].length}catch(s){}return Number(o.replace(".",""))*Number(a.replace(".",""))/Math.pow(10,r)},exports.accSub=function(t,e){let r,o,a,s;try{r=t.toString().split(".")[1].length}catch(n){r=0}try{o=e.toString().split(".")[1].length}catch(n){o=0}return a=Math.pow(10,Math.max(r,o)),s=r>=o?r:o,((t*a-e*a)/a).toFixed(s)},exports.cutTimeFn=t=>`00‘${0===t?"00":"0"+Math.floor(t/60)}’${0===t?"00":t%60>=10?t%60:"0"+t%60}`,exports.digitCnUppercase=function(t){var e=["角","分"],r=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],o=[["元","万","亿"],["","拾","佰","仟"]],a=t<0?"欠":"";t=Math.abs(t);for(var s="",n=0;n<e.length;n++)s+=(r[Math.floor(10*t*Math.pow(10,n))%10]+e[n]).replace(/零./,"");for(s=s||"整",t=Math.floor(t),n=0;n<o[0].length&&t>0;n++){for(var i="",l=0;l<o[1].length&&t>0;l++)i=r[t%10]+o[1][l]+i,t=Math.floor(t/10);s=i.replace(/(零.)*零$/,"").replace(/^$/,"零")+o[0][n]+s}return a+s.replace(/(零.)*零元/,"元").replace(/(零.)+/g,"零").replace(/^整$/,"零元整")},exports.download=(t,e="download",r="application/octet-stream",o)=>{const a=window;let s=r,n=t;const i=document,l=i.createElement("a"),c=t=>String(t),p=a.Blob||c(l),d=e;let m=null,u=null;const f=(e,r)=>{if("download"in l)return l.href=o?t:e,l.setAttribute("download",d),l.innerHTML="downloading...",i.body.appendChild(l),setTimeout((()=>{l.click(),i.body.removeChild(l),!0===r&&setTimeout((()=>{a.URL.revokeObjectURL(l.href)}),250)}),66),!0;const s=i.createElement("iframe");i.body.appendChild(s),r||(e="data:"+e.replace(/^data:([\w\/\-\+]+)/,"application/octet-stream")),s.src=e,setTimeout((()=>{i.body.removeChild(s)}),333)};if(String(n).match(/^data\:[\w+\-]+\/[\w+\-]+[,;]/))return navigator.msSaveBlob?navigator.msSaveBlob((t=>{const e=t.split(/[:;,]/),r=e[1],o=("base64"===e[2]?atob:decodeURIComponent)(e.pop()),a=o.length;let s=0;const n=new Uint8Array(a);for(;s<a;++s)n[s]=o.charCodeAt(s);return new p([n],{type:r})})(n),d):f(n);try{m=n instanceof p?n:new p([n],{type:s})}catch(h){}if(navigator.msSaveBlob)return navigator.msSaveBlob(m,d);if(a.URL)f(a.URL.createObjectURL(m),!0);else{if("string"==typeof m||m.constructor===c(l))try{return f("data:"+s+";base64,"+a.btoa(m))}catch(h){return f("data:"+s+","+encodeURIComponent(m))}u=new FileReader,u.onload=function(){f(this.result)},u.readAsDataURL(m)}return!0},exports.fileReaderToBase64=t=>e=>{const r=new FileReader;r.onload=t=>{e&&e(t.target.result)},r.readAsDataURL(t)},exports.format10k=y,exports.format10kNil=M,exports.formatCash=d,exports.formatCash2=t=>(Math.floor(100*t)/100).toFixed(2),exports.formatCashInt=m,exports.formatCashIntNil=h,exports.formatCashNil=f,exports.formatCreditEnhanced=b,exports.formatDate=Y,exports.formatDateNil=A,exports.formatDuration=R,exports.formatDurationNil=O,exports.formatRatio=u,exports.formatRatioNil=x,exports.getBase64=t=>new Promise(((e,r)=>{const o=new FileReader;o.readAsDataURL(t),o.onload=()=>e(o.result),o.onerror=t=>r(t)})),exports.getItem=t=>((p[t]||c.getItem(""+t))&&(p[t]=JSON.parse(c.getItem(""+t)||"null")),p[t]),exports.getQueryObject=(e=window.location.href)=>{const r=e.split("?")[1];return t.parse(r||"")},exports.getSearchParams=t=>new URLSearchParams(t),exports.getValOfArr=t=>{const e=t.length,r=t.reduce(((t,e)=>t+e),0),o=t.reduce(((t,e)=>t*e),1);return{min:Math.min.apply(null,t),max:Math.max.apply(null,t),sum:r,average:r/e,mull:o}},exports.getValueWithNil=t=>w(t)?S:t,exports.inBrowser=i,exports.isArray=t=>Array.isArray(t),exports.isBlob=l,exports.isCardNo=t=>/^(\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$/.test(t),exports.isDate=t=>t instanceof Date,exports.isEmail=t=>/^(.+)@(.+)\.(.+)$/.test(t),exports.isFile=t=>l(t)&&"string"==typeof t.name&&("object"==typeof t.lastModifiedDate||"number"==typeof t.lastModified),exports.isNil=w,exports.isNull=t=>null===t,exports.isObject=t=>t===Object(t),exports.isPhone=t=>/^[1](\d{10})$/.test(t),exports.isSMSCode=t=>t.match(/^\d{6}$/),exports.isUndefined=t=>void 0===t,exports.log=(...t)=>{console.group("====================="),console.info(...t),console.groupEnd()},exports.normalizeFormValues=function(t){return Object.entries(t).filter((([t,e])=>void 0!==e&&"all"!==e)).reduce(((t,[e,r])=>(Array.isArray(r)&&r.some((t=>n.isMoment(t)))?(r[0]&&(t.startDate=r[0].format("YYYY-MM-DD")),r[1]&&(t.endDate=r[1].format("YYYY-MM-DD"))):t[e]=n.isMoment(r)?r.format("YYYY-MM-DD"):r,t)),{})},exports.normalizeSearchParams=function(t){return(t.startDate||t.endDate)&&(t=Object.assign(Object.assign({},s(t,["startDate","endDate"])),{dateRange:[t.startDate&&n(t.startDate),t.endDate&&n(t.endDate)]})),Object.entries(t).forEach((([e,r])=>{"string"==typeof r&&r.includes(",")&&(t[e]="all")})),t},exports.os=()=>{if(!i)return{isTablet:!1,isPhone:!1,isAndroid:!1,isPc:!1};const t=navigator.userAgent,e=/(?:Windows Phone)/.test(t),r=/(?:SymbianOS)/.test(t)||e,o=/(?:Android)/.test(t),a=/(?:Firefox)/.test(t),s=/(?:iPad|PlayBook)/.test(t)||o&&!/(?:Mobile)/.test(t)||a&&/(?:Tablet)/.test(t),n=/(?:iPhone)/.test(t)&&!s;return{isTablet:s,isPhone:n,isAndroid:o,isPc:!n&&!o&&!r}},exports.playAudio=t=>{const e=document.querySelectorAll("audio");Array.from(e).forEach((t=>{t.pause(),t.currentTime=0})),document.querySelector(`#${t}`).play()},exports.random=(t,e)=>Math.round(Math.random()*(e-t)+t),exports.randomString=(t=32)=>{const e="ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678",r=e.length;let o="";for(let a=0;a<t;a++)o+=e.charAt(Math.floor(Math.random()*r));return o},exports.removeAll=()=>(p={},c.clear()),exports.removeItem=t=>(delete p[t],c.removeItem(""+t)),exports.setItem=(t,e)=>(p[t]=e,c.setItem(""+t,JSON.stringify(e))),exports.setProxyObj=(t,e,r)=>new Proxy(t,{get:(t,r)=>(e(),Reflect.get(t,r)),set:(t,e,o)=>(r(),Reflect.set(t,e,o))}),exports.sortObj=(t,e,r="asc")=>t.sort(((t,o)=>"asc"===r?o[e]-t[e]:t[e]-o[e])),exports.sumObj=(t,e)=>t.reduce(((t,r)=>r[e]+t),0),exports.trimString=t=>t.replace(/(^\s*)|(\s*$)/g,"");
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("qs"),e=require("d3-format"),r=require("lodash/omit"),o=require("moment");function a(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var s=a(r),n=a(o);const i="undefined"!=typeof window,l=t=>t&&"number"==typeof t.size&&"string"==typeof t.type&&"function"==typeof t.slice,c=i?localStorage:{};let p={};const d=e.format(",.2f"),u=e.format(","),m=e.format(".2%"),f=g(d),h=g(u),x=g(m);function g(t){return e=>w(e)?S:t(e)}const y=t=>d(t/1e4),M=g(y),D=(b="增信",function(t){return t?b:"不"+b});var b;const w=t=>null==t||""===t,S="——";function Y(t,e="YYYY-MM-DD"){return n(new Date(t)).format(e)}const A=g(Y),R={d:"天",m:"个月",y:"年"};function O(t){return t?`${parseInt(t,10)}${R[t.slice(-1).toLowerCase()]}`:t}const N=g(O);exports.DATE_FORMAT="YYYY/MM/DD",exports.FORMAT_DATE="YYYY-MM-DD",exports.FORMAT_TIME="YYYY-MM-DD HH:mm:ss",exports.NIL_STRING=S,exports.accAdd=(t,e)=>{let r,o,a;try{r=t.toString().split(".")[1].length}catch(s){r=0}try{o=e.toString().split(".")[1].length}catch(s){o=0}return a=Math.pow(10,Math.max(r,o)),(t*a+e*a)/a},exports.accDiv=(t,e)=>{let r,o,a=0,s=0;try{a=t.toString().split(".")[1].length}catch(n){}try{s=e.toString().split(".")[1].length}catch(n){}return r=Number(t.toString().replace(".","")),o=Number(e.toString().replace(".","")),r/o*Math.pow(10,s-a)},exports.accMul=(t,e)=>{let r=0,o=t.toString(),a=e.toString();try{r+=o.split(".")[1].length}catch(s){}try{r+=a.split(".")[1].length}catch(s){}return Number(o.replace(".",""))*Number(a.replace(".",""))/Math.pow(10,r)},exports.accSub=function(t,e){let r,o,a,s;try{r=t.toString().split(".")[1].length}catch(n){r=0}try{o=e.toString().split(".")[1].length}catch(n){o=0}return a=Math.pow(10,Math.max(r,o)),s=r>=o?r:o,((t*a-e*a)/a).toFixed(s)},exports.cutTimeFn=t=>`00‘${0===t?"00":"0"+Math.floor(t/60)}’${0===t?"00":t%60>=10?t%60:"0"+t%60}`,exports.digitCnUppercase=function(t){var e=["角","分"],r=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],o=[["元","万","亿"],["","拾","佰","仟"]],a=t<0?"欠":"";t=Math.abs(t);for(var s="",n=0;n<e.length;n++)s+=(r[Math.floor(10*t*Math.pow(10,n))%10]+e[n]).replace(/零./,"");for(s=s||"整",t=Math.floor(t),n=0;n<o[0].length&&t>0;n++){for(var i="",l=0;l<o[1].length&&t>0;l++)i=r[t%10]+o[1][l]+i,t=Math.floor(t/10);s=i.replace(/(零.)*零$/,"").replace(/^$/,"零")+o[0][n]+s}return a+s.replace(/(零.)*零元/,"元").replace(/(零.)+/g,"零").replace(/^整$/,"零元整")},exports.download=(t,e="download",r="application/octet-stream",o)=>{const a=window;let s=r,n=t;const i=document,l=i.createElement("a"),c=t=>String(t),p=a.Blob||c(l),d=e;let u=null,m=null;const f=(e,r)=>{if("download"in l)return l.href=o?t:e,l.setAttribute("download",d),l.innerHTML="downloading...",i.body.appendChild(l),setTimeout((()=>{l.click(),i.body.removeChild(l),!0===r&&setTimeout((()=>{a.URL.revokeObjectURL(l.href)}),250)}),66),!0;const s=i.createElement("iframe");i.body.appendChild(s),r||(e="data:"+e.replace(/^data:([\w\/\-\+]+)/,"application/octet-stream")),s.src=e,setTimeout((()=>{i.body.removeChild(s)}),333)};if(String(n).match(/^data\:[\w+\-]+\/[\w+\-]+[,;]/))return f(n);try{u=n instanceof p?n:new p([n],{type:s})}catch(h){}if(a.URL)f(a.URL.createObjectURL(u),!0);else{if("string"==typeof u||u.constructor===c(l))try{return f("data:"+s+";base64,"+a.btoa(u))}catch(h){return f("data:"+s+","+encodeURIComponent(u))}m=new FileReader,m.onload=function(){f(this.result)},m.readAsDataURL(u)}return!0},exports.fileReaderToBase64=t=>e=>{const r=new FileReader;r.onload=t=>{e&&e(t.target.result)},r.readAsDataURL(t)},exports.format10k=y,exports.format10kNil=M,exports.formatCash=d,exports.formatCash2=t=>(Math.floor(100*t)/100).toFixed(2),exports.formatCashInt=u,exports.formatCashIntNil=h,exports.formatCashNil=f,exports.formatCreditEnhanced=D,exports.formatDate=Y,exports.formatDateNil=A,exports.formatDuration=O,exports.formatDurationNil=N,exports.formatRatio=m,exports.formatRatioNil=x,exports.getBase64=t=>new Promise(((e,r)=>{const o=new FileReader;o.readAsDataURL(t),o.onload=()=>e(o.result),o.onerror=t=>r(t)})),exports.getItem=t=>((p[t]||c.getItem(""+t))&&(p[t]=JSON.parse(c.getItem(""+t)||"null")),p[t]),exports.getQueryObject=(e=window.location.href)=>{const r=e.split("?")[1];return t.parse(r||"")},exports.getSearchParams=t=>new URLSearchParams(t),exports.getValOfArr=t=>{const e=t.length,r=t.reduce(((t,e)=>t+e),0),o=t.reduce(((t,e)=>t*e),1);return{min:Math.min.apply(null,t),max:Math.max.apply(null,t),sum:r,average:r/e,mull:o}},exports.getValueWithNil=t=>w(t)?S:t,exports.inBrowser=i,exports.isArray=t=>Array.isArray(t),exports.isBlob=l,exports.isCardNo=t=>/^(\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$/.test(t),exports.isDate=t=>t instanceof Date,exports.isEmail=t=>/^(.+)@(.+)\.(.+)$/.test(t),exports.isFile=t=>l(t)&&"string"==typeof t.name&&("object"==typeof t.lastModifiedDate||"number"==typeof t.lastModified),exports.isNil=w,exports.isNull=t=>null===t,exports.isObject=t=>t===Object(t),exports.isPhone=t=>/^[1](\d{10})$/.test(t),exports.isSMSCode=t=>t.match(/^\d{6}$/),exports.isUndefined=t=>void 0===t,exports.log=(...t)=>{console.group("====================="),console.info(...t),console.groupEnd()},exports.normalizeFormValues=function(t){return Object.entries(t).filter((([t,e])=>void 0!==e&&"all"!==e)).reduce(((t,[e,r])=>(Array.isArray(r)&&r.some((t=>n.isMoment(t)))?(r[0]&&(t.startDate=r[0].format("YYYY-MM-DD")),r[1]&&(t.endDate=r[1].format("YYYY-MM-DD"))):t[e]=n.isMoment(r)?r.format("YYYY-MM-DD"):r,t)),{})},exports.normalizeSearchParams=function(t){return(t.startDate||t.endDate)&&(t=Object.assign(Object.assign({},s(t,["startDate","endDate"])),{dateRange:[t.startDate&&n(t.startDate),t.endDate&&n(t.endDate)]})),Object.entries(t).forEach((([e,r])=>{"string"==typeof r&&r.includes(",")&&(t[e]="all")})),t},exports.os=()=>{if(!i)return{isTablet:!1,isPhone:!1,isAndroid:!1,isPc:!1};const t=navigator.userAgent,e=/(?:Windows Phone)/.test(t),r=/(?:SymbianOS)/.test(t)||e,o=/(?:Android)/.test(t),a=/(?:Firefox)/.test(t),s=/(?:iPad|PlayBook)/.test(t)||o&&!/(?:Mobile)/.test(t)||a&&/(?:Tablet)/.test(t),n=/(?:iPhone)/.test(t)&&!s;return{isTablet:s,isPhone:n,isAndroid:o,isPc:!n&&!o&&!r}},exports.playAudio=t=>{const e=document.querySelectorAll("audio");Array.from(e).forEach((t=>{t.pause(),t.currentTime=0})),document.querySelector(`#${t}`).play()},exports.random=(t,e)=>Math.round(Math.random()*(e-t)+t),exports.randomString=(t=32)=>{const e="ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678",r=e.length;let o="";for(let a=0;a<t;a++)o+=e.charAt(Math.floor(Math.random()*r));return o},exports.removeAll=()=>(p={},c.clear()),exports.removeItem=t=>(delete p[t],c.removeItem(""+t)),exports.setItem=(t,e)=>(p[t]=e,c.setItem(""+t,JSON.stringify(e))),exports.setProxyObj=(t,e,r)=>new Proxy(t,{get:(t,r)=>(e(),Reflect.get(t,r)),set:(t,e,o)=>(r(),Reflect.set(t,e,o))}),exports.sortObj=(t,e,r="asc")=>t.sort(((t,o)=>"asc"===r?o[e]-t[e]:t[e]-o[e])),exports.sumObj=(t,e)=>t.reduce(((t,r)=>r[e]+t),0),exports.trimString=t=>t.replace(/(^\s*)|(\s*$)/g,"");
@@ -345,20 +345,19 @@ const download = (data, strFileName = 'download', strMimeType = 'application/oct
345
345
  const fn = strFileName;
346
346
  let blob = null;
347
347
  let fr = null;
348
- const d2b = (u) => {
349
- const p = u.split(/[:;,]/);
350
- const t = p[1];
351
- const dec = p[2] === 'base64' ? atob : decodeURIComponent;
352
- const bin = dec(p.pop());
353
- const mx = bin.length;
354
- let i = 0;
355
- const uia = new Uint8Array(mx);
356
- for (i; i < mx; ++i)
357
- uia[i] = bin.charCodeAt(i);
358
- return new B([uia], {
359
- type: t
360
- });
361
- };
348
+ // const d2b = (u: any) => {
349
+ // const p = u.split(/[:;,]/)
350
+ // const t = p[1]
351
+ // const dec = p[2] === 'base64' ? atob : decodeURIComponent
352
+ // const bin = dec(p.pop())
353
+ // const mx = bin.length
354
+ // let i = 0
355
+ // const uia = new Uint8Array(mx)
356
+ // for (i; i < mx; ++i) uia[i] = bin.charCodeAt(i)
357
+ // return new B([uia], {
358
+ // type: t
359
+ // })
360
+ // }
362
361
  const saver = (url, winMode) => {
363
362
  if ('download' in a) {
364
363
  // html5 A[download]
@@ -396,9 +395,10 @@ const download = (data, strFileName = 'download', strMimeType = 'application/oct
396
395
  // }
397
396
  // go ahead and download dataURLs right away
398
397
  if (String(x).match(/^data\:[\w+\-]+\/[\w+\-]+[,;]/)) {
399
- return navigator.msSaveBlob // IE10 can't do a[download], only Blobs:
400
- ? navigator.msSaveBlob(d2b(x), fn)
401
- : saver(x); // everyone else can save dataURLs un-processed
398
+ return saver(x);
399
+ // return navigator?.msSaveBlob // IE10 can't do a[download], only Blobs:
400
+ // ? navigator?.msSaveBlob(d2b(x), fn)
401
+ // : saver(x) // everyone else can save dataURLs un-processed
402
402
  } // end if dataURL passed?
403
403
  try {
404
404
  blob =
@@ -415,10 +415,10 @@ const download = (data, strFileName = 'download', strMimeType = 'application/oct
415
415
  // blob = b.getBlob(m); // the blob
416
416
  // }
417
417
  }
418
- if (navigator.msSaveBlob) {
419
- // IE10+ : (has Blob, but not a[download] or URL)
420
- return navigator.msSaveBlob(blob, fn);
421
- }
418
+ // if (navigator.msSaveBlob) {
419
+ // // IE10+ : (has Blob, but not a[download] or URL)
420
+ // return navigator.msSaveBlob(blob, fn)
421
+ // }
422
422
  if (self.URL) {
423
423
  // simple fast and modern way using Blob and URL:
424
424
  // saver(self.URL.createObjectURL(blob), true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lgutils",
3
- "version": "1.3.3",
3
+ "version": "1.3.5",
4
4
  "description": "lgutils",
5
5
  "main": "index.js",
6
6
  "module": "lib/lgutils.cjs.prod.js",
@@ -35,5 +35,5 @@
35
35
  "@types/moment": "^2.13.0",
36
36
  "@types/qs": "^6.9.0"
37
37
  },
38
- "gitHead": "e94fc5bc6a95ca90393043a3ff8437bb493b1d0f"
38
+ "gitHead": "35e3d5499dce983ef12a69119674dd64416567ba"
39
39
  }