fish-helper 0.0.59 → 0.0.61

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/dist/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";function t(t,e,r,i){return new(r||(r=Promise))(function(n,o){function s(t){try{a(i.next(t))}catch(t){o(t)}}function _(t){try{a(i.throw(t))}catch(t){o(t)}}function a(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(s,_)}a((i=i.apply(t,e||[])).next())})}Object.defineProperty(exports,"__esModule",{value:!0}),"function"==typeof SuppressedError&&SuppressedError;const e=()=>null;function r(e,r,i){return t(this,void 0,void 0,function*(){const t=[];let i=0;const n=10485760;let o=new Uint8Array(n),s=0;for(;;){const{done:r,value:_}=yield e.read();if(_&&(s+_.length>n&&(t.push(o.slice(0,s)),o=new Uint8Array(n),s=0),o.set(_,s),s+=_.length,i+=_.length),r)break}s>0&&t.push(o.slice(0,s));return function(t,e){const r=URL.createObjectURL(t),i=document.createElement("a");i.href=r,i.download=e,document.body.appendChild(i),i.click(),setTimeout(()=>{document.body.removeChild(i),URL.revokeObjectURL(r)},100)}(new Blob(t,{type:"application/pdf"}),r),!0})}const i=new class{constructor(){this.__interval=1e3,this.__an_hour=36e5,this.__ticker=null,this.__ticker2=null,this.__get_type=t=>Object.prototype.toString.call(t).slice(8,-1),this.__date2timestamp=t=>{if(!t)return Date.now();let e=null;e="string"==typeof t?t.replace(/(\-|\_)/g,"/"):new Date(t);let r=new Date(e);return"Invalid Date"===r.toString()&&(r=new Date(t)),r.getTime()},this.__is_function=t=>"Function"===this.__get_type(t),this.__is_array=t=>"Array"===this.__get_type(t),this.__is_object=t=>"Object"===this.__get_type(t),this.__get_suffix2=t=>String(t).padStart(2,"0"),this.__compare_time=({date:t,hour:e=1,type:r="before_lt_hour"})=>{let i=this.__date2timestamp(t);const n=new Date(i).getTime(),o=Date.now(),s=n<o,_=n>o;return"before_lt_hour"===r?s&&n+this.__an_hour*e>o:"before_gt_hour"===r?s&&n+this.__an_hour*e<o:"after_lt_hour"===r?_&&o+this.__an_hour*e>n:"after_gt_hour"===r&&(_&&o+this.__an_hour*e<n)},this.offset_time=(t,e="minute")=>{const r=Math.abs(Date.now()-this.__date2timestamp(t)),i=this.format_num2date(r);return"day"===e?this.__get_suffix2(i.day):"hour"===e?this.__get_suffix2(i.hour):"minute"===e?this.__get_suffix2(i.minute):"second"===e?this.__get_suffix2(i.seconds):"The second parameter has an error"},this.__loop_time2=(t=0,r=e,i=this.__interval,n=0,o=Date.now())=>{if(t<=0)return clearTimeout(this.__ticker2),void(this.__ticker2=null);clearTimeout(this.__ticker2),this.__ticker2=setTimeout(()=>{n+=1,t-=this.__interval;let e=this.format_timestamp_to_day_hour_minute_second(t);r({remain:t,obj:e});const i=Date.now()-(o+n*this.__interval);let s=this.__interval-i;s<0&&(s=0),this.__loop_time2(t,r,s,n,o)},i)},this.__loop_time=(t=0,r=e,i=this.__interval,n=0,o=Date.now())=>{if(t<=0)return clearTimeout(this.__ticker),void(this.__ticker=null);clearTimeout(this.__ticker),this.__ticker=setTimeout(()=>{n+=1,t-=this.__interval;let e=this.format_num2date(t);r({remain:t,obj:e});const i=Date.now()-(o+n*this.__interval);let s=this.__interval-i;s<0&&(s=0),this.__loop_time(t,r,s,n,o)},i)},this.sleep=t=>new Promise(e=>setTimeout(e,t)),this.roxFormatThousandth=(t,e="万")=>t<1e4?t:(Math.floor(t/1e3)/10).toFixed(1)+e,this.chunk=(t,e,r=!1)=>{if(!Array.isArray(t)||e<=0)return[];const i=[];for(let n=0;n<t.length;n+=e){const o=t.slice(n,n+e);r?o.length===e&&i.push(o):i.push(o)}return i},this.debounce=(t,e=200,r=!1)=>{let i,n=null;return function(...o){const s=this,_=r&&!n;return n&&clearTimeout(n),n=setTimeout(()=>{n=null,r||(i=t.apply(s,o))},e),_&&(i=t.apply(s,o)),i}},this.flatten=(t,e=!1)=>{let r=[];return t.forEach(t=>{e&&Array.isArray(t)?r=r.concat(this.flatten(t,e)):r.push(t)}),r},this.safeRequest=(t,e)=>t&&t.then?t.catch?t.then(t=>[null,t]).catch(t=>(e&&Object.assign(t,e),[t,void 0])):t.then(t=>[null,t]):Promise.resolve([null,t]),this.checkPattern=t=>{const{str:e,likeStr:r,separator:i="-",caseSensitive:n=!1,symbol:o=""}=t,s=(r||"").split(i),_=(e||"").split(i);return s.every((t,e)=>t===o||(n?t===_[e]:_[e]&&t.toLowerCase()===_[e].toLowerCase()))},this.convertArr2Disable=t=>{var e;const r=[],{skuObjArr:i=[],skuArrField:n,checkedIndexArr:o=[],combineSkuArr:s=[],disabledArr:_=[],combineSeparator:a="-",combineSkuField:l="id"}=t;for(let t=0;t<i.length;t++){const u=n?(null===(e=i[t])||void 0===e?void 0:e[n])||[]:i[t]||[];Array.isArray(r[t])||(r[t]=[]);for(let e=0;e<u.length;e++){const i=o.slice(0,t),n=o.slice(t+1),u=i.concat(e).concat(n).join(a),c=s.filter(t=>this.checkPattern({str:t[l],likeStr:u,separator:a})),h=_.map(t=>{const{field:e,disabledFun:r,disabledFieldValue:i}=t,n=c.some(t=>r(t));return{[e]:n?i:!i}}).reduce((t,e)=>Object.assign(Object.assign({},t),e),{});r[t][e]=h}}return r},this.createSingleTon=t=>{let e=null;const r=new Proxy(t,{construct:(t,r)=>e||(e="undefined"!=typeof Reflect&&Reflect.construct?Reflect.construct(t,r):new t(...r),e)});return r.prototype.constructor=r,r},this.downloadLargePDF=(e,...i)=>t(this,[e,...i],void 0,function*(e,i="download.pdf"){var n,o;try{const s=yield fetch(e);if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);const _=s.headers.get("content-length"),a=_?parseInt(_,10):0,l=null===(o=null===(n=s.body)||void 0===n?void 0:n.getReader)||void 0===o?void 0:o.call(n);return window.showSaveFilePicker?l&&(yield function(e,r,i){return t(this,void 0,void 0,function*(){const t=yield window.showSaveFilePicker({suggestedName:r,types:[{description:"PDF 文件",accept:{"application/pdf":[".pdf"]}}]}),n=yield t.createWritable();let o=0;for(;;){const{done:t,value:r}=yield e.read();if(t)break;yield n.write(r),o+=r.length,i&&(o/i*100).toFixed(1)}return yield n.close(),!0})}(l,i,a)):l&&(yield r(l,i)),Promise.resolve()}catch(t){return Promise.resolve()}}),this.downloadBlob=(e,...r)=>t(this,[e,...r],void 0,function*(t,e="download.pdf"){try{const r=yield fetch(t);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);const i=yield r.blob(),n=document.createElement("a");return n.href=URL.createObjectURL(i),n.download=e,n.click(),URL.revokeObjectURL(n.href),!0}catch(t){return Promise.resolve()}})}before_lt_hour(t=Date.now(),e=1){return this.__compare_time({date:t,hour:e,type:"before_lt_hour"})}before_gt_hour(t=Date.now(),e=1){return this.__compare_time({date:t,hour:e,type:"before_gt_hour"})}after_lt_hour(t=Date.now(),e=1){return this.__compare_time({date:t,hour:e,type:"after_lt_hour"})}after_gt_hour(t=Date.now(),e=1){return this.__compare_time({date:t,hour:e,type:"after_gt_hour"})}is_current_year(t){const e=this.__date2timestamp(t);return(new Date).getFullYear()===new Date(e).getFullYear()}get_time_obj(t){const e=this.__date2timestamp(t),r=new Date(e),i=this.__get_suffix2(r.getMonth()+1),n=this.__get_suffix2(r.getDate()),o=this.__get_suffix2(r.getHours()),s=this.__get_suffix2(r.getMinutes()),_=this.__get_suffix2(r.getSeconds());return{year:String(r.getFullYear()),month:i,day:n,hour:o,minute:s,seconds:_,day_of_week:String(r.getDay())}}format_count({num:t=0,decimal:e=1,divide:r=1e4,suffix:i="万",show_suffix_always:n=!1}){if(!t)return 0;if(r<=0||e<0)return n?`${t} ${i}`:t;const o=parseFloat(t);if(o<=0)return n?`${o} ${i}`:o;if(o>0&&o<r)return n?`${o} ${i}`:o;const[s,_]=(o/r).toFixed(e).split(".");return _&&0!==parseFloat(_)?`${s}.${_} ${i}`:`${s} ${i}`}format_num2date(t=Date.now()){const e=parseInt(t/1e3/60/60/24%24),r=parseInt(t/1e3/60/60%24),i=parseInt(t/1e3/60%60),n=parseInt(t/1e3%60);return{day:this.__get_suffix2(e),hour:this.__get_suffix2(r),minute:this.__get_suffix2(i),seconds:this.__get_suffix2(n)}}count_down_by_remain_seconds(t=e,r=60){let i;clearTimeout(i);let n=1e3*r,o=this.format_num2date(n),s={remain:n,obj:o};t(s);let _=this;return function t(r=0,a=e,l=1e3,u=0,c=Date.now()){if(r<=0)return clearTimeout(i),_=null,i=null,n=null,o=null,s=null,void a({remain:0,obj:{day:"00",hour:"00",minute:"00",seconds:"00"}});clearTimeout(i),i=setTimeout(()=>{u+=1,r-=1e3;let e=_.format_num2date(r);a({remain:r,obj:e});let i=1e3-(Date.now()-(c+1e3*u));i<0&&(i=0),t(r,a,i,u,c)},l)}(n,t,1e3),()=>{clearTimeout(i),_=null,i=null,n=null,o=null,s=null}}format_timestamp_to_day_hour_minute_second(t=Date.now()){const e=Math.floor(t/864e5),r=Math.floor(t%864e5/36e5),i=Math.floor(t%36e5/6e4),n=Math.floor(t%6e4/1e3);return{day:this.__get_suffix2(e),hour:this.__get_suffix2(r),minute:this.__get_suffix2(i),seconds:this.__get_suffix2(n)}}count_down(t=Date.now(),r=e){let i;clearTimeout(i);let n=this,o=this.__date2timestamp(t),s=o-Date.now(),_=this.format_timestamp_to_day_hour_minute_second(s),a={remain:s,obj:_};return r(a),function t(r=0,l=e,u=1e3,c=0,h=Date.now()){if(r<=0)return clearTimeout(i),i=null,n=null,o=null,s=null,_=null,a=null,void l({remain:0,obj:{day:"00",hour:"00",minute:"00",seconds:"00"}});clearTimeout(i),i=setTimeout(()=>{c+=1,r-=1e3;let e=n.format_timestamp_to_day_hour_minute_second(r);l({remain:r,obj:e});let i=1e3-(Date.now()-(h+1e3*c));i<0&&(i=0),t(r,l,i,c,h)},u)}(s,r,1e3),()=>{clearTimeout(i),i=null,n=null,o=null,s=null,_=null,a=null}}add(t=1,e=Date.now()){return this.__date2timestamp(e)+60*t*60*1e3}format_thousandth(t,e=2){try{const r=parseFloat(t),i=r.toString().split(".");let n=!1,o="";i[1]&&(o=i[1].replace(/0+$/,""),n=o.length>0);let s=0;n&&(s=void 0!==e?e:o.length);const _=r.toFixed(s).split("."),a=(_[0]||"").replace(/(\d)(?=(\d{3})+$)/g,"$1,");return _[1]?`${a}.${_[1]}`:a}catch(t){return 0}}format_thousandth_with_same_dotlen(t){var e;try{const r=(null===(e=t.toString().split(".")[1])||void 0===e?void 0:e.length)||0;let i=t.toString().replace(/\d+/,function(t){return t.replace(/(\d)(?=(\d{3})+$)/g,function(t){return t+","})});return r&&(i=i.replace(/\d+\.\d+/,function(t){return t.replace(/(\d)(?=(\d{3})+\.)/g,function(t){return t+","})})),i}catch(t){return 0}}is_empty(t){return null==t||("String"===this.__get_type(t)?!t.trim():"Array"===this.__get_type(t)?!t.length:"Object"===this.__get_type(t)&&!Object.keys(t).length)}poll(t,e=1){let r;if(!this.__is_function(t))return()=>{clearTimeout(r),r=void 0};const i=60*e*1e3,n=()=>{t(),r=setTimeout(n,i)};return n(),()=>{clearTimeout(r),r=void 0}}is_equal(t,e,r=!1){const i=this.__is_array(t)||this.__is_object(t),n=this.__is_array(e)||this.__is_object(e);if(!i||!n)return r?t===e:t==e;const o=Object.keys(t),s=Object.keys(e);return 0===o.length&&0===s.length||o.length===s.length&&o.every(i=>{const n=this.__is_array(t[i])||this.__is_object(t[i]),o=this.__is_array(e[i])||this.__is_object(e[i]);return n&&o?this.is_equal(t[i],e[i],r):r?t[i]===e[i]:t[i]==e[i]})}contains(t,e,r=!1){const i=this.__is_array(t)||this.__is_object(t),n=this.__is_array(e)||this.__is_object(e);if(!i||!n)return r?t===e:t==e;const o=Object.keys(t),s=Object.keys(e);return 0===s.length||!(0===o.length||o.length<s.length)&&s.every(i=>{if(o.indexOf(i)<0)return!1;const n=this.__is_array(t[i])||this.__is_object(t[i]),s=this.__is_array(e[i])||this.__is_object(e[i]);return n&&s?this.contains(t[i],e[i],r):r?t[i]===e[i]:t[i]==e[i]})}};exports.default=i,exports.helper=i;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const t=()=>null;const e=new class{constructor(){this.__interval=1e3,this.__an_hour=36e5,this.__ticker=null,this.__ticker2=null,this.__get_type=t=>Object.prototype.toString.call(t).slice(8,-1),this.__date2timestamp=t=>{if(!t)return Date.now();let e=null;e="string"==typeof t?t.replace(/(\-|\_)/g,"/"):new Date(t);let r=new Date(e);return"Invalid Date"===r.toString()&&(r=new Date(t)),r.getTime()},this.__is_function=t=>"Function"===this.__get_type(t),this.__is_array=t=>"Array"===this.__get_type(t),this.__is_object=t=>"Object"===this.__get_type(t),this.__get_suffix2=t=>String(t).padStart(2,"0"),this.__compare_time=({date:t,hour:e=1,type:r="before_lt_hour"})=>{let i=this.__date2timestamp(t);const _=new Date(i).getTime(),n=Date.now(),s=_<n,o=_>n;return"before_lt_hour"===r?s&&_+this.__an_hour*e>n:"before_gt_hour"===r?s&&_+this.__an_hour*e<n:"after_lt_hour"===r?o&&n+this.__an_hour*e>_:"after_gt_hour"===r&&(o&&n+this.__an_hour*e<_)},this.offset_time=(t,e="minute")=>{const r=Math.abs(Date.now()-this.__date2timestamp(t)),i=this.format_num2date(r);return"day"===e?this.__get_suffix2(i.day):"hour"===e?this.__get_suffix2(i.hour):"minute"===e?this.__get_suffix2(i.minute):"second"===e?this.__get_suffix2(i.seconds):"The second parameter has an error"},this.__loop_time2=(e=0,r=t,i=this.__interval,_=0,n=Date.now())=>{if(e<=0)return clearTimeout(this.__ticker2),void(this.__ticker2=null);clearTimeout(this.__ticker2),this.__ticker2=setTimeout(()=>{_+=1,e-=this.__interval;let t=this.format_timestamp_to_day_hour_minute_second(e);r({remain:e,obj:t});const i=Date.now()-(n+_*this.__interval);let s=this.__interval-i;s<0&&(s=0),this.__loop_time2(e,r,s,_,n)},i)},this.__loop_time=(e=0,r=t,i=this.__interval,_=0,n=Date.now())=>{if(e<=0)return clearTimeout(this.__ticker),void(this.__ticker=null);clearTimeout(this.__ticker),this.__ticker=setTimeout(()=>{_+=1,e-=this.__interval;let t=this.format_num2date(e);r({remain:e,obj:t});const i=Date.now()-(n+_*this.__interval);let s=this.__interval-i;s<0&&(s=0),this.__loop_time(e,r,s,_,n)},i)},this.sleep=t=>new Promise(e=>setTimeout(e,t)),this.roxFormatThousandth=(t,e="万")=>t<1e4?t:(Math.floor(t/1e3)/10).toFixed(1)+e,this.chunk=(t,e,r=!1)=>{if(!Array.isArray(t)||e<=0)return[];const i=[];for(let _=0;_<t.length;_+=e){const n=t.slice(_,_+e);r?n.length===e&&i.push(n):i.push(n)}return i},this.debounce=(t,e=200,r=!1)=>{let i,_=null;return function(...n){const s=this,o=r&&!_;return _&&clearTimeout(_),_=setTimeout(()=>{_=null,r||(i=t.apply(s,n))},e),o&&(i=t.apply(s,n)),i}},this.flatten=(t,e=!1)=>{let r=[];return t.forEach(t=>{e&&Array.isArray(t)?r=r.concat(this.flatten(t,e)):r.push(t)}),r},this.safeRequest=(t,e)=>t&&t.then?t.catch?t.then(t=>[null,t]).catch(t=>(e&&Object.assign(t,e),[t,void 0])):t.then(t=>[null,t]):Promise.resolve([null,t]),this.checkPattern=t=>{const{str:e,likeStr:r,separator:i="-",caseSensitive:_=!1,symbol:n=""}=t,s=(r||"").split(i),o=(e||"").split(i);return s.every((t,e)=>t===n||(_?t===o[e]:o[e]&&t.toLowerCase()===o[e].toLowerCase()))},this.convertArr2Disable=t=>{var e;const r=[],{skuObjArr:i=[],skuArrField:_,checkedIndexArr:n=[],combineSkuArr:s=[],disabledArr:o=[],combineSeparator:a="-",combineSkuField:u="id"}=t;for(let t=0;t<i.length;t++){const l=_?(null===(e=i[t])||void 0===e?void 0:e[_])||[]:i[t]||[];Array.isArray(r[t])||(r[t]=[]);for(let e=0;e<l.length;e++){const i=n.slice(0,t),_=n.slice(t+1),l=i.concat(e).concat(_).join(a),h=s.filter(t=>this.checkPattern({str:t[u],likeStr:l,separator:a})),c=o.map(t=>{const{field:e,disabledFun:r,disabledFieldValue:i}=t,_=h.some(t=>r(t));return{[e]:_?i:!i}}).reduce((t,e)=>Object.assign(Object.assign({},t),e),{});r[t][e]=c}}return r},this.createSingleTon=t=>{let e=null;const r=new Proxy(t,{construct:(t,r)=>e||(e="undefined"!=typeof Reflect&&Reflect.construct?Reflect.construct(t,r):new t(...r),e)});return r.prototype.constructor=r,r}}before_lt_hour(t=Date.now(),e=1){return this.__compare_time({date:t,hour:e,type:"before_lt_hour"})}before_gt_hour(t=Date.now(),e=1){return this.__compare_time({date:t,hour:e,type:"before_gt_hour"})}after_lt_hour(t=Date.now(),e=1){return this.__compare_time({date:t,hour:e,type:"after_lt_hour"})}after_gt_hour(t=Date.now(),e=1){return this.__compare_time({date:t,hour:e,type:"after_gt_hour"})}is_current_year(t){const e=this.__date2timestamp(t);return(new Date).getFullYear()===new Date(e).getFullYear()}get_time_obj(t){const e=this.__date2timestamp(t),r=new Date(e),i=this.__get_suffix2(r.getMonth()+1),_=this.__get_suffix2(r.getDate()),n=this.__get_suffix2(r.getHours()),s=this.__get_suffix2(r.getMinutes()),o=this.__get_suffix2(r.getSeconds());return{year:String(r.getFullYear()),month:i,day:_,hour:n,minute:s,seconds:o,day_of_week:String(r.getDay())}}format_count({num:t=0,decimal:e=1,divide:r=1e4,suffix:i="万",show_suffix_always:_=!1}){if(!t)return 0;if(r<=0||e<0)return _?`${t} ${i}`:t;const n=parseFloat(t);if(n<=0)return _?`${n} ${i}`:n;if(n>0&&n<r)return _?`${n} ${i}`:n;const[s,o]=(n/r).toFixed(e).split(".");return o&&0!==parseFloat(o)?`${s}.${o} ${i}`:`${s} ${i}`}format_num2date(t=Date.now()){const e=parseInt(t/1e3/60/60/24%24),r=parseInt(t/1e3/60/60%24),i=parseInt(t/1e3/60%60),_=parseInt(t/1e3%60);return{day:this.__get_suffix2(e),hour:this.__get_suffix2(r),minute:this.__get_suffix2(i),seconds:this.__get_suffix2(_)}}count_down_by_remain_seconds(e=t,r=60){let i;clearTimeout(i);let _=1e3*r,n=this.format_num2date(_),s={remain:_,obj:n};e(s);let o=this;return function e(r=0,a=t,u=1e3,l=0,h=Date.now()){if(r<=0)return clearTimeout(i),o=null,i=null,_=null,n=null,s=null,void a({remain:0,obj:{day:"00",hour:"00",minute:"00",seconds:"00"}});clearTimeout(i),i=setTimeout(()=>{l+=1,r-=1e3;let t=o.format_num2date(r);a({remain:r,obj:t});let i=1e3-(Date.now()-(h+1e3*l));i<0&&(i=0),e(r,a,i,l,h)},u)}(_,e,1e3),()=>{clearTimeout(i),o=null,i=null,_=null,n=null,s=null}}format_timestamp_to_day_hour_minute_second(t=Date.now()){const e=Math.floor(t/864e5),r=Math.floor(t%864e5/36e5),i=Math.floor(t%36e5/6e4),_=Math.floor(t%6e4/1e3);return{day:this.__get_suffix2(e),hour:this.__get_suffix2(r),minute:this.__get_suffix2(i),seconds:this.__get_suffix2(_)}}count_down(e=Date.now(),r=t){let i;clearTimeout(i);let _=this,n=this.__date2timestamp(e),s=n-Date.now(),o=this.format_timestamp_to_day_hour_minute_second(s),a={remain:s,obj:o};return r(a),function e(r=0,u=t,l=1e3,h=0,c=Date.now()){if(r<=0)return clearTimeout(i),i=null,_=null,n=null,s=null,o=null,a=null,void u({remain:0,obj:{day:"00",hour:"00",minute:"00",seconds:"00"}});clearTimeout(i),i=setTimeout(()=>{h+=1,r-=1e3;let t=_.format_timestamp_to_day_hour_minute_second(r);u({remain:r,obj:t});let i=1e3-(Date.now()-(c+1e3*h));i<0&&(i=0),e(r,u,i,h,c)},l)}(s,r,1e3),()=>{clearTimeout(i),i=null,_=null,n=null,s=null,o=null,a=null}}add(t=1,e=Date.now()){return this.__date2timestamp(e)+60*t*60*1e3}format_thousandth(t,e=2){try{const r=parseFloat(t),i=r.toString().split(".");let _=!1,n="";i[1]&&(n=i[1].replace(/0+$/,""),_=n.length>0);let s=0;_&&(s=void 0!==e?e:n.length);const o=r.toFixed(s).split("."),a=(o[0]||"").replace(/(\d)(?=(\d{3})+$)/g,"$1,");return o[1]?`${a}.${o[1]}`:a}catch(t){return 0}}format_thousandth_with_same_dotlen(t){var e;try{const r=(null===(e=t.toString().split(".")[1])||void 0===e?void 0:e.length)||0;let i=t.toString().replace(/\d+/,function(t){return t.replace(/(\d)(?=(\d{3})+$)/g,function(t){return t+","})});return r&&(i=i.replace(/\d+\.\d+/,function(t){return t.replace(/(\d)(?=(\d{3})+\.)/g,function(t){return t+","})})),i}catch(t){return 0}}is_empty(t){return null==t||("String"===this.__get_type(t)?!t.trim():"Array"===this.__get_type(t)?!t.length:"Object"===this.__get_type(t)&&!Object.keys(t).length)}poll(t,e=1){let r;if(!this.__is_function(t))return()=>{clearTimeout(r),r=void 0};const i=60*e*1e3,_=()=>{t(),r=setTimeout(_,i)};return _(),()=>{clearTimeout(r),r=void 0}}is_equal(t,e,r=!1){const i=this.__is_array(t)||this.__is_object(t),_=this.__is_array(e)||this.__is_object(e);if(!i||!_)return r?t===e:t==e;const n=Object.keys(t),s=Object.keys(e);return 0===n.length&&0===s.length||n.length===s.length&&n.every(i=>{const _=this.__is_array(t[i])||this.__is_object(t[i]),n=this.__is_array(e[i])||this.__is_object(e[i]);return _&&n?this.is_equal(t[i],e[i],r):r?t[i]===e[i]:t[i]==e[i]})}contains(t,e,r=!1){const i=this.__is_array(t)||this.__is_object(t),_=this.__is_array(e)||this.__is_object(e);if(!i||!_)return r?t===e:t==e;const n=Object.keys(t),s=Object.keys(e);return 0===s.length||!(0===n.length||n.length<s.length)&&s.every(i=>{if(n.indexOf(i)<0)return!1;const _=this.__is_array(t[i])||this.__is_object(t[i]),s=this.__is_array(e[i])||this.__is_object(e[i]);return _&&s?this.contains(t[i],e[i],r):r?t[i]===e[i]:t[i]==e[i]})}};exports.default=e,exports.helper=e;
package/dist/es/index.js CHANGED
@@ -1 +1 @@
1
- function t(t,e,r,i){return new(r||(r=Promise))(function(n,o){function s(t){try{a(i.next(t))}catch(t){o(t)}}function _(t){try{a(i.throw(t))}catch(t){o(t)}}function a(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(s,_)}a((i=i.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const e=()=>null;function r(e,r,i){return t(this,void 0,void 0,function*(){const t=[];let i=0;const n=10485760;let o=new Uint8Array(n),s=0;for(;;){const{done:r,value:_}=yield e.read();if(_&&(s+_.length>n&&(t.push(o.slice(0,s)),o=new Uint8Array(n),s=0),o.set(_,s),s+=_.length,i+=_.length),r)break}s>0&&t.push(o.slice(0,s));return function(t,e){const r=URL.createObjectURL(t),i=document.createElement("a");i.href=r,i.download=e,document.body.appendChild(i),i.click(),setTimeout(()=>{document.body.removeChild(i),URL.revokeObjectURL(r)},100)}(new Blob(t,{type:"application/pdf"}),r),!0})}const i=new class{constructor(){this.__interval=1e3,this.__an_hour=36e5,this.__ticker=null,this.__ticker2=null,this.__get_type=t=>Object.prototype.toString.call(t).slice(8,-1),this.__date2timestamp=t=>{if(!t)return Date.now();let e=null;e="string"==typeof t?t.replace(/(\-|\_)/g,"/"):new Date(t);let r=new Date(e);return"Invalid Date"===r.toString()&&(r=new Date(t)),r.getTime()},this.__is_function=t=>"Function"===this.__get_type(t),this.__is_array=t=>"Array"===this.__get_type(t),this.__is_object=t=>"Object"===this.__get_type(t),this.__get_suffix2=t=>String(t).padStart(2,"0"),this.__compare_time=({date:t,hour:e=1,type:r="before_lt_hour"})=>{let i=this.__date2timestamp(t);const n=new Date(i).getTime(),o=Date.now(),s=n<o,_=n>o;return"before_lt_hour"===r?s&&n+this.__an_hour*e>o:"before_gt_hour"===r?s&&n+this.__an_hour*e<o:"after_lt_hour"===r?_&&o+this.__an_hour*e>n:"after_gt_hour"===r&&(_&&o+this.__an_hour*e<n)},this.offset_time=(t,e="minute")=>{const r=Math.abs(Date.now()-this.__date2timestamp(t)),i=this.format_num2date(r);return"day"===e?this.__get_suffix2(i.day):"hour"===e?this.__get_suffix2(i.hour):"minute"===e?this.__get_suffix2(i.minute):"second"===e?this.__get_suffix2(i.seconds):"The second parameter has an error"},this.__loop_time2=(t=0,r=e,i=this.__interval,n=0,o=Date.now())=>{if(t<=0)return clearTimeout(this.__ticker2),void(this.__ticker2=null);clearTimeout(this.__ticker2),this.__ticker2=setTimeout(()=>{n+=1,t-=this.__interval;let e=this.format_timestamp_to_day_hour_minute_second(t);r({remain:t,obj:e});const i=Date.now()-(o+n*this.__interval);let s=this.__interval-i;s<0&&(s=0),this.__loop_time2(t,r,s,n,o)},i)},this.__loop_time=(t=0,r=e,i=this.__interval,n=0,o=Date.now())=>{if(t<=0)return clearTimeout(this.__ticker),void(this.__ticker=null);clearTimeout(this.__ticker),this.__ticker=setTimeout(()=>{n+=1,t-=this.__interval;let e=this.format_num2date(t);r({remain:t,obj:e});const i=Date.now()-(o+n*this.__interval);let s=this.__interval-i;s<0&&(s=0),this.__loop_time(t,r,s,n,o)},i)},this.sleep=t=>new Promise(e=>setTimeout(e,t)),this.roxFormatThousandth=(t,e="万")=>t<1e4?t:(Math.floor(t/1e3)/10).toFixed(1)+e,this.chunk=(t,e,r=!1)=>{if(!Array.isArray(t)||e<=0)return[];const i=[];for(let n=0;n<t.length;n+=e){const o=t.slice(n,n+e);r?o.length===e&&i.push(o):i.push(o)}return i},this.debounce=(t,e=200,r=!1)=>{let i,n=null;return function(...o){const s=this,_=r&&!n;return n&&clearTimeout(n),n=setTimeout(()=>{n=null,r||(i=t.apply(s,o))},e),_&&(i=t.apply(s,o)),i}},this.flatten=(t,e=!1)=>{let r=[];return t.forEach(t=>{e&&Array.isArray(t)?r=r.concat(this.flatten(t,e)):r.push(t)}),r},this.safeRequest=(t,e)=>t&&t.then?t.catch?t.then(t=>[null,t]).catch(t=>(e&&Object.assign(t,e),[t,void 0])):t.then(t=>[null,t]):Promise.resolve([null,t]),this.checkPattern=t=>{const{str:e,likeStr:r,separator:i="-",caseSensitive:n=!1,symbol:o=""}=t,s=(r||"").split(i),_=(e||"").split(i);return s.every((t,e)=>t===o||(n?t===_[e]:_[e]&&t.toLowerCase()===_[e].toLowerCase()))},this.convertArr2Disable=t=>{var e;const r=[],{skuObjArr:i=[],skuArrField:n,checkedIndexArr:o=[],combineSkuArr:s=[],disabledArr:_=[],combineSeparator:a="-",combineSkuField:l="id"}=t;for(let t=0;t<i.length;t++){const u=n?(null===(e=i[t])||void 0===e?void 0:e[n])||[]:i[t]||[];Array.isArray(r[t])||(r[t]=[]);for(let e=0;e<u.length;e++){const i=o.slice(0,t),n=o.slice(t+1),u=i.concat(e).concat(n).join(a),c=s.filter(t=>this.checkPattern({str:t[l],likeStr:u,separator:a})),h=_.map(t=>{const{field:e,disabledFun:r,disabledFieldValue:i}=t,n=c.some(t=>r(t));return{[e]:n?i:!i}}).reduce((t,e)=>Object.assign(Object.assign({},t),e),{});r[t][e]=h}}return r},this.createSingleTon=t=>{let e=null;const r=new Proxy(t,{construct:(t,r)=>e||(e="undefined"!=typeof Reflect&&Reflect.construct?Reflect.construct(t,r):new t(...r),e)});return r.prototype.constructor=r,r},this.downloadLargePDF=(e,...i)=>t(this,[e,...i],void 0,function*(e,i="download.pdf"){var n,o;try{const s=yield fetch(e);if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);const _=s.headers.get("content-length"),a=_?parseInt(_,10):0,l=null===(o=null===(n=s.body)||void 0===n?void 0:n.getReader)||void 0===o?void 0:o.call(n);return window.showSaveFilePicker?l&&(yield function(e,r,i){return t(this,void 0,void 0,function*(){const t=yield window.showSaveFilePicker({suggestedName:r,types:[{description:"PDF 文件",accept:{"application/pdf":[".pdf"]}}]}),n=yield t.createWritable();let o=0;for(;;){const{done:t,value:r}=yield e.read();if(t)break;yield n.write(r),o+=r.length,i&&(o/i*100).toFixed(1)}return yield n.close(),!0})}(l,i,a)):l&&(yield r(l,i)),Promise.resolve()}catch(t){return Promise.resolve()}}),this.downloadBlob=(e,...r)=>t(this,[e,...r],void 0,function*(t,e="download.pdf"){try{const r=yield fetch(t);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);const i=yield r.blob(),n=document.createElement("a");return n.href=URL.createObjectURL(i),n.download=e,n.click(),URL.revokeObjectURL(n.href),!0}catch(t){return Promise.resolve()}})}before_lt_hour(t=Date.now(),e=1){return this.__compare_time({date:t,hour:e,type:"before_lt_hour"})}before_gt_hour(t=Date.now(),e=1){return this.__compare_time({date:t,hour:e,type:"before_gt_hour"})}after_lt_hour(t=Date.now(),e=1){return this.__compare_time({date:t,hour:e,type:"after_lt_hour"})}after_gt_hour(t=Date.now(),e=1){return this.__compare_time({date:t,hour:e,type:"after_gt_hour"})}is_current_year(t){const e=this.__date2timestamp(t);return(new Date).getFullYear()===new Date(e).getFullYear()}get_time_obj(t){const e=this.__date2timestamp(t),r=new Date(e),i=this.__get_suffix2(r.getMonth()+1),n=this.__get_suffix2(r.getDate()),o=this.__get_suffix2(r.getHours()),s=this.__get_suffix2(r.getMinutes()),_=this.__get_suffix2(r.getSeconds());return{year:String(r.getFullYear()),month:i,day:n,hour:o,minute:s,seconds:_,day_of_week:String(r.getDay())}}format_count({num:t=0,decimal:e=1,divide:r=1e4,suffix:i="万",show_suffix_always:n=!1}){if(!t)return 0;if(r<=0||e<0)return n?`${t} ${i}`:t;const o=parseFloat(t);if(o<=0)return n?`${o} ${i}`:o;if(o>0&&o<r)return n?`${o} ${i}`:o;const[s,_]=(o/r).toFixed(e).split(".");return _&&0!==parseFloat(_)?`${s}.${_} ${i}`:`${s} ${i}`}format_num2date(t=Date.now()){const e=parseInt(t/1e3/60/60/24%24),r=parseInt(t/1e3/60/60%24),i=parseInt(t/1e3/60%60),n=parseInt(t/1e3%60);return{day:this.__get_suffix2(e),hour:this.__get_suffix2(r),minute:this.__get_suffix2(i),seconds:this.__get_suffix2(n)}}count_down_by_remain_seconds(t=e,r=60){let i;clearTimeout(i);let n=1e3*r,o=this.format_num2date(n),s={remain:n,obj:o};t(s);let _=this;return function t(r=0,a=e,l=1e3,u=0,c=Date.now()){if(r<=0)return clearTimeout(i),_=null,i=null,n=null,o=null,s=null,void a({remain:0,obj:{day:"00",hour:"00",minute:"00",seconds:"00"}});clearTimeout(i),i=setTimeout(()=>{u+=1,r-=1e3;let e=_.format_num2date(r);a({remain:r,obj:e});let i=1e3-(Date.now()-(c+1e3*u));i<0&&(i=0),t(r,a,i,u,c)},l)}(n,t,1e3),()=>{clearTimeout(i),_=null,i=null,n=null,o=null,s=null}}format_timestamp_to_day_hour_minute_second(t=Date.now()){const e=Math.floor(t/864e5),r=Math.floor(t%864e5/36e5),i=Math.floor(t%36e5/6e4),n=Math.floor(t%6e4/1e3);return{day:this.__get_suffix2(e),hour:this.__get_suffix2(r),minute:this.__get_suffix2(i),seconds:this.__get_suffix2(n)}}count_down(t=Date.now(),r=e){let i;clearTimeout(i);let n=this,o=this.__date2timestamp(t),s=o-Date.now(),_=this.format_timestamp_to_day_hour_minute_second(s),a={remain:s,obj:_};return r(a),function t(r=0,l=e,u=1e3,c=0,h=Date.now()){if(r<=0)return clearTimeout(i),i=null,n=null,o=null,s=null,_=null,a=null,void l({remain:0,obj:{day:"00",hour:"00",minute:"00",seconds:"00"}});clearTimeout(i),i=setTimeout(()=>{c+=1,r-=1e3;let e=n.format_timestamp_to_day_hour_minute_second(r);l({remain:r,obj:e});let i=1e3-(Date.now()-(h+1e3*c));i<0&&(i=0),t(r,l,i,c,h)},u)}(s,r,1e3),()=>{clearTimeout(i),i=null,n=null,o=null,s=null,_=null,a=null}}add(t=1,e=Date.now()){return this.__date2timestamp(e)+60*t*60*1e3}format_thousandth(t,e=2){try{const r=parseFloat(t),i=r.toString().split(".");let n=!1,o="";i[1]&&(o=i[1].replace(/0+$/,""),n=o.length>0);let s=0;n&&(s=void 0!==e?e:o.length);const _=r.toFixed(s).split("."),a=(_[0]||"").replace(/(\d)(?=(\d{3})+$)/g,"$1,");return _[1]?`${a}.${_[1]}`:a}catch(t){return 0}}format_thousandth_with_same_dotlen(t){var e;try{const r=(null===(e=t.toString().split(".")[1])||void 0===e?void 0:e.length)||0;let i=t.toString().replace(/\d+/,function(t){return t.replace(/(\d)(?=(\d{3})+$)/g,function(t){return t+","})});return r&&(i=i.replace(/\d+\.\d+/,function(t){return t.replace(/(\d)(?=(\d{3})+\.)/g,function(t){return t+","})})),i}catch(t){return 0}}is_empty(t){return null==t||("String"===this.__get_type(t)?!t.trim():"Array"===this.__get_type(t)?!t.length:"Object"===this.__get_type(t)&&!Object.keys(t).length)}poll(t,e=1){let r;if(!this.__is_function(t))return()=>{clearTimeout(r),r=void 0};const i=60*e*1e3,n=()=>{t(),r=setTimeout(n,i)};return n(),()=>{clearTimeout(r),r=void 0}}is_equal(t,e,r=!1){const i=this.__is_array(t)||this.__is_object(t),n=this.__is_array(e)||this.__is_object(e);if(!i||!n)return r?t===e:t==e;const o=Object.keys(t),s=Object.keys(e);return 0===o.length&&0===s.length||o.length===s.length&&o.every(i=>{const n=this.__is_array(t[i])||this.__is_object(t[i]),o=this.__is_array(e[i])||this.__is_object(e[i]);return n&&o?this.is_equal(t[i],e[i],r):r?t[i]===e[i]:t[i]==e[i]})}contains(t,e,r=!1){const i=this.__is_array(t)||this.__is_object(t),n=this.__is_array(e)||this.__is_object(e);if(!i||!n)return r?t===e:t==e;const o=Object.keys(t),s=Object.keys(e);return 0===s.length||!(0===o.length||o.length<s.length)&&s.every(i=>{if(o.indexOf(i)<0)return!1;const n=this.__is_array(t[i])||this.__is_object(t[i]),s=this.__is_array(e[i])||this.__is_object(e[i]);return n&&s?this.contains(t[i],e[i],r):r?t[i]===e[i]:t[i]==e[i]})}};export{i as default,i as helper};
1
+ const t=()=>null;const e=new class{constructor(){this.__interval=1e3,this.__an_hour=36e5,this.__ticker=null,this.__ticker2=null,this.__get_type=t=>Object.prototype.toString.call(t).slice(8,-1),this.__date2timestamp=t=>{if(!t)return Date.now();let e=null;e="string"==typeof t?t.replace(/(\-|\_)/g,"/"):new Date(t);let r=new Date(e);return"Invalid Date"===r.toString()&&(r=new Date(t)),r.getTime()},this.__is_function=t=>"Function"===this.__get_type(t),this.__is_array=t=>"Array"===this.__get_type(t),this.__is_object=t=>"Object"===this.__get_type(t),this.__get_suffix2=t=>String(t).padStart(2,"0"),this.__compare_time=({date:t,hour:e=1,type:r="before_lt_hour"})=>{let i=this.__date2timestamp(t);const n=new Date(i).getTime(),_=Date.now(),s=n<_,o=n>_;return"before_lt_hour"===r?s&&n+this.__an_hour*e>_:"before_gt_hour"===r?s&&n+this.__an_hour*e<_:"after_lt_hour"===r?o&&_+this.__an_hour*e>n:"after_gt_hour"===r&&(o&&_+this.__an_hour*e<n)},this.offset_time=(t,e="minute")=>{const r=Math.abs(Date.now()-this.__date2timestamp(t)),i=this.format_num2date(r);return"day"===e?this.__get_suffix2(i.day):"hour"===e?this.__get_suffix2(i.hour):"minute"===e?this.__get_suffix2(i.minute):"second"===e?this.__get_suffix2(i.seconds):"The second parameter has an error"},this.__loop_time2=(e=0,r=t,i=this.__interval,n=0,_=Date.now())=>{if(e<=0)return clearTimeout(this.__ticker2),void(this.__ticker2=null);clearTimeout(this.__ticker2),this.__ticker2=setTimeout(()=>{n+=1,e-=this.__interval;let t=this.format_timestamp_to_day_hour_minute_second(e);r({remain:e,obj:t});const i=Date.now()-(_+n*this.__interval);let s=this.__interval-i;s<0&&(s=0),this.__loop_time2(e,r,s,n,_)},i)},this.__loop_time=(e=0,r=t,i=this.__interval,n=0,_=Date.now())=>{if(e<=0)return clearTimeout(this.__ticker),void(this.__ticker=null);clearTimeout(this.__ticker),this.__ticker=setTimeout(()=>{n+=1,e-=this.__interval;let t=this.format_num2date(e);r({remain:e,obj:t});const i=Date.now()-(_+n*this.__interval);let s=this.__interval-i;s<0&&(s=0),this.__loop_time(e,r,s,n,_)},i)},this.sleep=t=>new Promise(e=>setTimeout(e,t)),this.roxFormatThousandth=(t,e="万")=>t<1e4?t:(Math.floor(t/1e3)/10).toFixed(1)+e,this.chunk=(t,e,r=!1)=>{if(!Array.isArray(t)||e<=0)return[];const i=[];for(let n=0;n<t.length;n+=e){const _=t.slice(n,n+e);r?_.length===e&&i.push(_):i.push(_)}return i},this.debounce=(t,e=200,r=!1)=>{let i,n=null;return function(..._){const s=this,o=r&&!n;return n&&clearTimeout(n),n=setTimeout(()=>{n=null,r||(i=t.apply(s,_))},e),o&&(i=t.apply(s,_)),i}},this.flatten=(t,e=!1)=>{let r=[];return t.forEach(t=>{e&&Array.isArray(t)?r=r.concat(this.flatten(t,e)):r.push(t)}),r},this.safeRequest=(t,e)=>t&&t.then?t.catch?t.then(t=>[null,t]).catch(t=>(e&&Object.assign(t,e),[t,void 0])):t.then(t=>[null,t]):Promise.resolve([null,t]),this.checkPattern=t=>{const{str:e,likeStr:r,separator:i="-",caseSensitive:n=!1,symbol:_=""}=t,s=(r||"").split(i),o=(e||"").split(i);return s.every((t,e)=>t===_||(n?t===o[e]:o[e]&&t.toLowerCase()===o[e].toLowerCase()))},this.convertArr2Disable=t=>{var e;const r=[],{skuObjArr:i=[],skuArrField:n,checkedIndexArr:_=[],combineSkuArr:s=[],disabledArr:o=[],combineSeparator:a="-",combineSkuField:u="id"}=t;for(let t=0;t<i.length;t++){const l=n?(null===(e=i[t])||void 0===e?void 0:e[n])||[]:i[t]||[];Array.isArray(r[t])||(r[t]=[]);for(let e=0;e<l.length;e++){const i=_.slice(0,t),n=_.slice(t+1),l=i.concat(e).concat(n).join(a),h=s.filter(t=>this.checkPattern({str:t[u],likeStr:l,separator:a})),c=o.map(t=>{const{field:e,disabledFun:r,disabledFieldValue:i}=t,n=h.some(t=>r(t));return{[e]:n?i:!i}}).reduce((t,e)=>Object.assign(Object.assign({},t),e),{});r[t][e]=c}}return r},this.createSingleTon=t=>{let e=null;const r=new Proxy(t,{construct:(t,r)=>e||(e="undefined"!=typeof Reflect&&Reflect.construct?Reflect.construct(t,r):new t(...r),e)});return r.prototype.constructor=r,r}}before_lt_hour(t=Date.now(),e=1){return this.__compare_time({date:t,hour:e,type:"before_lt_hour"})}before_gt_hour(t=Date.now(),e=1){return this.__compare_time({date:t,hour:e,type:"before_gt_hour"})}after_lt_hour(t=Date.now(),e=1){return this.__compare_time({date:t,hour:e,type:"after_lt_hour"})}after_gt_hour(t=Date.now(),e=1){return this.__compare_time({date:t,hour:e,type:"after_gt_hour"})}is_current_year(t){const e=this.__date2timestamp(t);return(new Date).getFullYear()===new Date(e).getFullYear()}get_time_obj(t){const e=this.__date2timestamp(t),r=new Date(e),i=this.__get_suffix2(r.getMonth()+1),n=this.__get_suffix2(r.getDate()),_=this.__get_suffix2(r.getHours()),s=this.__get_suffix2(r.getMinutes()),o=this.__get_suffix2(r.getSeconds());return{year:String(r.getFullYear()),month:i,day:n,hour:_,minute:s,seconds:o,day_of_week:String(r.getDay())}}format_count({num:t=0,decimal:e=1,divide:r=1e4,suffix:i="万",show_suffix_always:n=!1}){if(!t)return 0;if(r<=0||e<0)return n?`${t} ${i}`:t;const _=parseFloat(t);if(_<=0)return n?`${_} ${i}`:_;if(_>0&&_<r)return n?`${_} ${i}`:_;const[s,o]=(_/r).toFixed(e).split(".");return o&&0!==parseFloat(o)?`${s}.${o} ${i}`:`${s} ${i}`}format_num2date(t=Date.now()){const e=parseInt(t/1e3/60/60/24%24),r=parseInt(t/1e3/60/60%24),i=parseInt(t/1e3/60%60),n=parseInt(t/1e3%60);return{day:this.__get_suffix2(e),hour:this.__get_suffix2(r),minute:this.__get_suffix2(i),seconds:this.__get_suffix2(n)}}count_down_by_remain_seconds(e=t,r=60){let i;clearTimeout(i);let n=1e3*r,_=this.format_num2date(n),s={remain:n,obj:_};e(s);let o=this;return function e(r=0,a=t,u=1e3,l=0,h=Date.now()){if(r<=0)return clearTimeout(i),o=null,i=null,n=null,_=null,s=null,void a({remain:0,obj:{day:"00",hour:"00",minute:"00",seconds:"00"}});clearTimeout(i),i=setTimeout(()=>{l+=1,r-=1e3;let t=o.format_num2date(r);a({remain:r,obj:t});let i=1e3-(Date.now()-(h+1e3*l));i<0&&(i=0),e(r,a,i,l,h)},u)}(n,e,1e3),()=>{clearTimeout(i),o=null,i=null,n=null,_=null,s=null}}format_timestamp_to_day_hour_minute_second(t=Date.now()){const e=Math.floor(t/864e5),r=Math.floor(t%864e5/36e5),i=Math.floor(t%36e5/6e4),n=Math.floor(t%6e4/1e3);return{day:this.__get_suffix2(e),hour:this.__get_suffix2(r),minute:this.__get_suffix2(i),seconds:this.__get_suffix2(n)}}count_down(e=Date.now(),r=t){let i;clearTimeout(i);let n=this,_=this.__date2timestamp(e),s=_-Date.now(),o=this.format_timestamp_to_day_hour_minute_second(s),a={remain:s,obj:o};return r(a),function e(r=0,u=t,l=1e3,h=0,c=Date.now()){if(r<=0)return clearTimeout(i),i=null,n=null,_=null,s=null,o=null,a=null,void u({remain:0,obj:{day:"00",hour:"00",minute:"00",seconds:"00"}});clearTimeout(i),i=setTimeout(()=>{h+=1,r-=1e3;let t=n.format_timestamp_to_day_hour_minute_second(r);u({remain:r,obj:t});let i=1e3-(Date.now()-(c+1e3*h));i<0&&(i=0),e(r,u,i,h,c)},l)}(s,r,1e3),()=>{clearTimeout(i),i=null,n=null,_=null,s=null,o=null,a=null}}add(t=1,e=Date.now()){return this.__date2timestamp(e)+60*t*60*1e3}format_thousandth(t,e=2){try{const r=parseFloat(t),i=r.toString().split(".");let n=!1,_="";i[1]&&(_=i[1].replace(/0+$/,""),n=_.length>0);let s=0;n&&(s=void 0!==e?e:_.length);const o=r.toFixed(s).split("."),a=(o[0]||"").replace(/(\d)(?=(\d{3})+$)/g,"$1,");return o[1]?`${a}.${o[1]}`:a}catch(t){return 0}}format_thousandth_with_same_dotlen(t){var e;try{const r=(null===(e=t.toString().split(".")[1])||void 0===e?void 0:e.length)||0;let i=t.toString().replace(/\d+/,function(t){return t.replace(/(\d)(?=(\d{3})+$)/g,function(t){return t+","})});return r&&(i=i.replace(/\d+\.\d+/,function(t){return t.replace(/(\d)(?=(\d{3})+\.)/g,function(t){return t+","})})),i}catch(t){return 0}}is_empty(t){return null==t||("String"===this.__get_type(t)?!t.trim():"Array"===this.__get_type(t)?!t.length:"Object"===this.__get_type(t)&&!Object.keys(t).length)}poll(t,e=1){let r;if(!this.__is_function(t))return()=>{clearTimeout(r),r=void 0};const i=60*e*1e3,n=()=>{t(),r=setTimeout(n,i)};return n(),()=>{clearTimeout(r),r=void 0}}is_equal(t,e,r=!1){const i=this.__is_array(t)||this.__is_object(t),n=this.__is_array(e)||this.__is_object(e);if(!i||!n)return r?t===e:t==e;const _=Object.keys(t),s=Object.keys(e);return 0===_.length&&0===s.length||_.length===s.length&&_.every(i=>{const n=this.__is_array(t[i])||this.__is_object(t[i]),_=this.__is_array(e[i])||this.__is_object(e[i]);return n&&_?this.is_equal(t[i],e[i],r):r?t[i]===e[i]:t[i]==e[i]})}contains(t,e,r=!1){const i=this.__is_array(t)||this.__is_object(t),n=this.__is_array(e)||this.__is_object(e);if(!i||!n)return r?t===e:t==e;const _=Object.keys(t),s=Object.keys(e);return 0===s.length||!(0===_.length||_.length<s.length)&&s.every(i=>{if(_.indexOf(i)<0)return!1;const n=this.__is_array(t[i])||this.__is_object(t[i]),s=this.__is_array(e[i])||this.__is_object(e[i]);return n&&s?this.contains(t[i],e[i],r):r?t[i]===e[i]:t[i]==e[i]})}};export{e as default,e as helper};
@@ -102,8 +102,6 @@ declare class Helper {
102
102
  [key: string]: boolean;
103
103
  }[][];
104
104
  createSingleTon: <T extends Constructor>(className: T) => T;
105
- downloadLargePDF: (url: string, filename?: string) => Promise<void>;
106
- downloadBlob: (url: string, filename?: string) => Promise<true | void>;
107
105
  }
108
106
  declare const helper: Helper;
109
107
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fish-helper",
3
- "version": "0.0.59",
3
+ "version": "0.0.61",
4
4
  "description": "a tool to process time",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/es/index.js",