fish-helper 0.0.10 → 0.0.11

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/README.md CHANGED
@@ -31,3 +31,5 @@ const helper = require('fish-helper')
31
31
  > - count_down_by_remain_seconds(fn, seconds) ------- 60-second countdown. Time can pass by itself
32
32
  >
33
33
  > - format_thousandth(num) ------- format the data as a string with thousands of bits
34
+ >
35
+ > - is_empty(data) ------- determines whether the data is empty
@@ -1 +1 @@
1
- "use strict";function t(t,e,r,a){if("a"===r&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!a:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?a:"a"===r?a.call(t):a?a.value:e.get(t)}var e,r,a,s,i,n,o;const h=()=>null;e=new WeakMap,r=new WeakMap,a=new WeakMap,s=new WeakMap,i=new WeakMap,n=new WeakMap,o=new WeakMap;var l=new class{constructor(){e.set(this,1e3),r.set(this,36e5),a.set(this,0),s.set(this,(t=>{if(!t)return Date.now();let e=null;return e="string"==typeof t?t.replace(/(\/|\.|_)/g,"-"):new Date(t),new Date(e).getTime()})),i.set(this,(t=>`0${t}`.slice(-2))),n.set(this,(({date:e,hour:a=1,type:i="before_lt_hour"})=>{let n=t(this,s,"f").call(this,e);const o=new Date(n).getTime(),h=Date.now(),l=o<h,f=o>h;return"before_lt_hour"===i?l&&o+t(this,r,"f")*a>h:"before_gt_hour"===i?l&&o+t(this,r,"f")*a<h:"after_lt_hour"===i?f&&h+t(this,r,"f")*a>o:"after_gt_hour"===i&&(f&&h+t(this,r,"f")*a<o)})),this.offset_time=(e,r="minute")=>{const a=Math.abs(Date.now()-t(this,s,"f").call(this,e)),n=this.format_num2date(a);return"day"===r?t(this,i,"f").call(this,n.day):"hour"===r?t(this,i,"f").call(this,n.hour):"minute"===r?t(this,i,"f").call(this,n.minute):"second"===r?t(this,i,"f").call(this,n.seconds):"The second parameter has an error"},o.set(this,((r=0,s=h,i=t(this,e,"f"),n=0,l=Date.now())=>{r<=0||function(t,e,r,a,s){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===a?s.call(t,r):s?s.value=r:e.set(t,r)}(this,a,setTimeout((()=>{n+=1,r-=t(this,e,"f"),s({remain:r,obj:this.format_num2date(r)});const a=Date.now()-(l+n*t(this,e,"f"));let i=t(this,e,"f")-a;i<0&&(i=0),t(this,o,"f").call(this,r,s,i,n,l)}),i),"f")}))}before_lt_hour(e,r=1){return t(this,n,"f").call(this,{date:e,hour:r,type:"before_lt_hour"})}before_gt_hour(e,r=1){return t(this,n,"f").call(this,{date:e,hour:r,type:"before_gt_hour"})}after_lt_hour(e,r=1){return t(this,n,"f").call(this,{date:e,hour:r,type:"after_lt_hour"})}after_gt_hour(e,r=1){return t(this,n,"f").call(this,{date:e,hour:r,type:"after_gt_hour"})}is_current_year(e){const r=t(this,s,"f").call(this,e);return(new Date).getFullYear()===new Date(r).getFullYear()}get_time_obj(e){const r=t(this,s,"f").call(this,e),a=new Date(r),n=t(this,i,"f").call(this,a.getMonth()+1),o=t(this,i,"f").call(this,a.getDate()),h=t(this,i,"f").call(this,a.getHours()),l=t(this,i,"f").call(this,a.getMinutes()),f=t(this,i,"f").call(this,a.getSeconds());return{year:String(a.getFullYear()),month:n,day:o,hour:h,minute:l,seconds:f,day_of_week:String(a.getDay())}}format_count({num:t=0,decimal:e=1,divide:r=1e4,suffix:a="万",show_suffix_always:s=!1}){if(!t)return 0;if(r<=0||e<0)return s?`${t} ${a}`:t;const i=parseFloat(t);if(i<=0)return s?`${i} ${a}`:i;if(i>1&&i<r)return s?`${i} ${a}`:i;const[n,o]=(i/r).toFixed(e).split(".");return o&&0!==parseFloat(o)?`${n}.${o} ${a}`:`${n} ${a}`}format_num2date(e=Date.now()){const r=parseInt(e/1e3/60/60/24%24),a=parseInt(e/1e3/60/60%24),s=parseInt(e/1e3/60%60),n=parseInt(e/1e3%60);return{day:t(this,i,"f").call(this,r),hour:t(this,i,"f").call(this,a),minute:t(this,i,"f").call(this,s),seconds:t(this,i,"f").call(this,n)}}count_down_by_remain_seconds(r=h,s=60){const i=s*t(this,e,"f");return r({remain:i,obj:this.format_num2date(i)}),t(this,o,"f").call(this,i,r,t(this,e,"f")),()=>clearTimeout(t(this,a,"f"))}count_down(r=Date.now(),i=h){const n=t(this,s,"f").call(this,r)-Date.now();return i({remain:n,obj:this.format_num2date(n)}),t(this,o,"f").call(this,n,i,t(this,e,"f")),()=>clearTimeout(t(this,a,"f"))}format_thousandth(t){return t.toString().replace(/\d+/,(function(t){return t.replace(/(\d)(?=(\d{3})+$)/g,(function(t){return t+","}))}))}};module.exports=l;
1
+ "use strict";function t(t,e,r,s){if("a"===r&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?s:"a"===r?s.call(t):s?s.value:e.get(t)}var e,r,s,a,i,n,o,h;const l=()=>null;e=new WeakMap,r=new WeakMap,s=new WeakMap,a=new WeakMap,i=new WeakMap,n=new WeakMap,o=new WeakMap,h=new WeakMap;var f=new class{constructor(){e.set(this,1e3),r.set(this,36e5),s.set(this,0),a.set(this,(t=>Object.prototype.toString.call(t).slice(8,-1))),i.set(this,(t=>{if(!t)return Date.now();let e=null;return e="string"==typeof t?t.replace(/(\/|\.|_)/g,"-"):new Date(t),new Date(e).getTime()})),n.set(this,(t=>`0${t}`.slice(-2))),o.set(this,(({date:e,hour:s=1,type:a="before_lt_hour"})=>{let n=t(this,i,"f").call(this,e);const o=new Date(n).getTime(),h=Date.now(),l=o<h,f=o>h;return"before_lt_hour"===a?l&&o+t(this,r,"f")*s>h:"before_gt_hour"===a?l&&o+t(this,r,"f")*s<h:"after_lt_hour"===a?f&&h+t(this,r,"f")*s>o:"after_gt_hour"===a&&(f&&h+t(this,r,"f")*s<o)})),this.offset_time=(e,r="minute")=>{const s=Math.abs(Date.now()-t(this,i,"f").call(this,e)),a=this.format_num2date(s);return"day"===r?t(this,n,"f").call(this,a.day):"hour"===r?t(this,n,"f").call(this,a.hour):"minute"===r?t(this,n,"f").call(this,a.minute):"second"===r?t(this,n,"f").call(this,a.seconds):"The second parameter has an error"},h.set(this,((r=0,a=l,i=t(this,e,"f"),n=0,o=Date.now())=>{r<=0||function(t,e,r,s,a){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!a)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!a:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===s?a.call(t,r):a?a.value=r:e.set(t,r)}(this,s,setTimeout((()=>{n+=1,r-=t(this,e,"f"),a({remain:r,obj:this.format_num2date(r)});const s=Date.now()-(o+n*t(this,e,"f"));let i=t(this,e,"f")-s;i<0&&(i=0),t(this,h,"f").call(this,r,a,i,n,o)}),i),"f")}))}before_lt_hour(e,r=1){return t(this,o,"f").call(this,{date:e,hour:r,type:"before_lt_hour"})}before_gt_hour(e,r=1){return t(this,o,"f").call(this,{date:e,hour:r,type:"before_gt_hour"})}after_lt_hour(e,r=1){return t(this,o,"f").call(this,{date:e,hour:r,type:"after_lt_hour"})}after_gt_hour(e,r=1){return t(this,o,"f").call(this,{date:e,hour:r,type:"after_gt_hour"})}is_current_year(e){const r=t(this,i,"f").call(this,e);return(new Date).getFullYear()===new Date(r).getFullYear()}get_time_obj(e){const r=t(this,i,"f").call(this,e),s=new Date(r),a=t(this,n,"f").call(this,s.getMonth()+1),o=t(this,n,"f").call(this,s.getDate()),h=t(this,n,"f").call(this,s.getHours()),l=t(this,n,"f").call(this,s.getMinutes()),f=t(this,n,"f").call(this,s.getSeconds());return{year:String(s.getFullYear()),month:a,day:o,hour:h,minute:l,seconds:f,day_of_week:String(s.getDay())}}format_count({num:t=0,decimal:e=1,divide:r=1e4,suffix:s="万",show_suffix_always:a=!1}){if(!t)return 0;if(r<=0||e<0)return a?`${t} ${s}`:t;const i=parseFloat(t);if(i<=0)return a?`${i} ${s}`:i;if(i>1&&i<r)return a?`${i} ${s}`:i;const[n,o]=(i/r).toFixed(e).split(".");return o&&0!==parseFloat(o)?`${n}.${o} ${s}`:`${n} ${s}`}format_num2date(e=Date.now()){const r=parseInt(e/1e3/60/60/24%24),s=parseInt(e/1e3/60/60%24),a=parseInt(e/1e3/60%60),i=parseInt(e/1e3%60);return{day:t(this,n,"f").call(this,r),hour:t(this,n,"f").call(this,s),minute:t(this,n,"f").call(this,a),seconds:t(this,n,"f").call(this,i)}}count_down_by_remain_seconds(r=l,a=60){const i=a*t(this,e,"f");return r({remain:i,obj:this.format_num2date(i)}),t(this,h,"f").call(this,i,r,t(this,e,"f")),()=>clearTimeout(t(this,s,"f"))}count_down(r=Date.now(),a=l){const n=t(this,i,"f").call(this,r)-Date.now();return a({remain:n,obj:this.format_num2date(n)}),t(this,h,"f").call(this,n,a,t(this,e,"f")),()=>clearTimeout(t(this,s,"f"))}format_thousandth(t){return t.toString().replace(/\d+/,(function(t){return t.replace(/(\d)(?=(\d{3})+$)/g,(function(t){return t+","}))}))}is_empty(e){return null==e||("String"===t(this,a,"f").call(this,e)?!e.trim():"Array"===t(this,a,"f").call(this,e)?!e.length:"Object"===t(this,a,"f").call(this,e)&&!Object.keys(e).length)}};module.exports=f;
@@ -1 +1 @@
1
- function t(t,e,r,a){if("a"===r&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!a:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?a:"a"===r?a.call(t):a?a.value:e.get(t)}var e,r,a,s,i,n,o;const h=()=>null;e=new WeakMap,r=new WeakMap,a=new WeakMap,s=new WeakMap,i=new WeakMap,n=new WeakMap,o=new WeakMap;var l=new class{constructor(){e.set(this,1e3),r.set(this,36e5),a.set(this,0),s.set(this,(t=>{if(!t)return Date.now();let e=null;return e="string"==typeof t?t.replace(/(\/|\.|_)/g,"-"):new Date(t),new Date(e).getTime()})),i.set(this,(t=>`0${t}`.slice(-2))),n.set(this,(({date:e,hour:a=1,type:i="before_lt_hour"})=>{let n=t(this,s,"f").call(this,e);const o=new Date(n).getTime(),h=Date.now(),l=o<h,f=o>h;return"before_lt_hour"===i?l&&o+t(this,r,"f")*a>h:"before_gt_hour"===i?l&&o+t(this,r,"f")*a<h:"after_lt_hour"===i?f&&h+t(this,r,"f")*a>o:"after_gt_hour"===i&&(f&&h+t(this,r,"f")*a<o)})),this.offset_time=(e,r="minute")=>{const a=Math.abs(Date.now()-t(this,s,"f").call(this,e)),n=this.format_num2date(a);return"day"===r?t(this,i,"f").call(this,n.day):"hour"===r?t(this,i,"f").call(this,n.hour):"minute"===r?t(this,i,"f").call(this,n.minute):"second"===r?t(this,i,"f").call(this,n.seconds):"The second parameter has an error"},o.set(this,((r=0,s=h,i=t(this,e,"f"),n=0,l=Date.now())=>{r<=0||function(t,e,r,a,s){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===a?s.call(t,r):s?s.value=r:e.set(t,r)}(this,a,setTimeout((()=>{n+=1,r-=t(this,e,"f"),s({remain:r,obj:this.format_num2date(r)});const a=Date.now()-(l+n*t(this,e,"f"));let i=t(this,e,"f")-a;i<0&&(i=0),t(this,o,"f").call(this,r,s,i,n,l)}),i),"f")}))}before_lt_hour(e,r=1){return t(this,n,"f").call(this,{date:e,hour:r,type:"before_lt_hour"})}before_gt_hour(e,r=1){return t(this,n,"f").call(this,{date:e,hour:r,type:"before_gt_hour"})}after_lt_hour(e,r=1){return t(this,n,"f").call(this,{date:e,hour:r,type:"after_lt_hour"})}after_gt_hour(e,r=1){return t(this,n,"f").call(this,{date:e,hour:r,type:"after_gt_hour"})}is_current_year(e){const r=t(this,s,"f").call(this,e);return(new Date).getFullYear()===new Date(r).getFullYear()}get_time_obj(e){const r=t(this,s,"f").call(this,e),a=new Date(r),n=t(this,i,"f").call(this,a.getMonth()+1),o=t(this,i,"f").call(this,a.getDate()),h=t(this,i,"f").call(this,a.getHours()),l=t(this,i,"f").call(this,a.getMinutes()),f=t(this,i,"f").call(this,a.getSeconds());return{year:String(a.getFullYear()),month:n,day:o,hour:h,minute:l,seconds:f,day_of_week:String(a.getDay())}}format_count({num:t=0,decimal:e=1,divide:r=1e4,suffix:a="万",show_suffix_always:s=!1}){if(!t)return 0;if(r<=0||e<0)return s?`${t} ${a}`:t;const i=parseFloat(t);if(i<=0)return s?`${i} ${a}`:i;if(i>1&&i<r)return s?`${i} ${a}`:i;const[n,o]=(i/r).toFixed(e).split(".");return o&&0!==parseFloat(o)?`${n}.${o} ${a}`:`${n} ${a}`}format_num2date(e=Date.now()){const r=parseInt(e/1e3/60/60/24%24),a=parseInt(e/1e3/60/60%24),s=parseInt(e/1e3/60%60),n=parseInt(e/1e3%60);return{day:t(this,i,"f").call(this,r),hour:t(this,i,"f").call(this,a),minute:t(this,i,"f").call(this,s),seconds:t(this,i,"f").call(this,n)}}count_down_by_remain_seconds(r=h,s=60){const i=s*t(this,e,"f");return r({remain:i,obj:this.format_num2date(i)}),t(this,o,"f").call(this,i,r,t(this,e,"f")),()=>clearTimeout(t(this,a,"f"))}count_down(r=Date.now(),i=h){const n=t(this,s,"f").call(this,r)-Date.now();return i({remain:n,obj:this.format_num2date(n)}),t(this,o,"f").call(this,n,i,t(this,e,"f")),()=>clearTimeout(t(this,a,"f"))}format_thousandth(t){return t.toString().replace(/\d+/,(function(t){return t.replace(/(\d)(?=(\d{3})+$)/g,(function(t){return t+","}))}))}};export{l as default};
1
+ function t(t,e,r,a){if("a"===r&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!a:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?a:"a"===r?a.call(t):a?a.value:e.get(t)}var e,r,a,s,i,n,h,o;const l=()=>null;e=new WeakMap,r=new WeakMap,a=new WeakMap,s=new WeakMap,i=new WeakMap,n=new WeakMap,h=new WeakMap,o=new WeakMap;var f=new class{constructor(){e.set(this,1e3),r.set(this,36e5),a.set(this,0),s.set(this,(t=>Object.prototype.toString.call(t).slice(8,-1))),i.set(this,(t=>{if(!t)return Date.now();let e=null;return e="string"==typeof t?t.replace(/(\/|\.|_)/g,"-"):new Date(t),new Date(e).getTime()})),n.set(this,(t=>`0${t}`.slice(-2))),h.set(this,(({date:e,hour:a=1,type:s="before_lt_hour"})=>{let n=t(this,i,"f").call(this,e);const h=new Date(n).getTime(),o=Date.now(),l=h<o,f=h>o;return"before_lt_hour"===s?l&&h+t(this,r,"f")*a>o:"before_gt_hour"===s?l&&h+t(this,r,"f")*a<o:"after_lt_hour"===s?f&&o+t(this,r,"f")*a>h:"after_gt_hour"===s&&(f&&o+t(this,r,"f")*a<h)})),this.offset_time=(e,r="minute")=>{const a=Math.abs(Date.now()-t(this,i,"f").call(this,e)),s=this.format_num2date(a);return"day"===r?t(this,n,"f").call(this,s.day):"hour"===r?t(this,n,"f").call(this,s.hour):"minute"===r?t(this,n,"f").call(this,s.minute):"second"===r?t(this,n,"f").call(this,s.seconds):"The second parameter has an error"},o.set(this,((r=0,s=l,i=t(this,e,"f"),n=0,h=Date.now())=>{r<=0||function(t,e,r,a,s){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===a?s.call(t,r):s?s.value=r:e.set(t,r)}(this,a,setTimeout((()=>{n+=1,r-=t(this,e,"f"),s({remain:r,obj:this.format_num2date(r)});const a=Date.now()-(h+n*t(this,e,"f"));let i=t(this,e,"f")-a;i<0&&(i=0),t(this,o,"f").call(this,r,s,i,n,h)}),i),"f")}))}before_lt_hour(e,r=1){return t(this,h,"f").call(this,{date:e,hour:r,type:"before_lt_hour"})}before_gt_hour(e,r=1){return t(this,h,"f").call(this,{date:e,hour:r,type:"before_gt_hour"})}after_lt_hour(e,r=1){return t(this,h,"f").call(this,{date:e,hour:r,type:"after_lt_hour"})}after_gt_hour(e,r=1){return t(this,h,"f").call(this,{date:e,hour:r,type:"after_gt_hour"})}is_current_year(e){const r=t(this,i,"f").call(this,e);return(new Date).getFullYear()===new Date(r).getFullYear()}get_time_obj(e){const r=t(this,i,"f").call(this,e),a=new Date(r),s=t(this,n,"f").call(this,a.getMonth()+1),h=t(this,n,"f").call(this,a.getDate()),o=t(this,n,"f").call(this,a.getHours()),l=t(this,n,"f").call(this,a.getMinutes()),f=t(this,n,"f").call(this,a.getSeconds());return{year:String(a.getFullYear()),month:s,day:h,hour:o,minute:l,seconds:f,day_of_week:String(a.getDay())}}format_count({num:t=0,decimal:e=1,divide:r=1e4,suffix:a="万",show_suffix_always:s=!1}){if(!t)return 0;if(r<=0||e<0)return s?`${t} ${a}`:t;const i=parseFloat(t);if(i<=0)return s?`${i} ${a}`:i;if(i>1&&i<r)return s?`${i} ${a}`:i;const[n,h]=(i/r).toFixed(e).split(".");return h&&0!==parseFloat(h)?`${n}.${h} ${a}`:`${n} ${a}`}format_num2date(e=Date.now()){const r=parseInt(e/1e3/60/60/24%24),a=parseInt(e/1e3/60/60%24),s=parseInt(e/1e3/60%60),i=parseInt(e/1e3%60);return{day:t(this,n,"f").call(this,r),hour:t(this,n,"f").call(this,a),minute:t(this,n,"f").call(this,s),seconds:t(this,n,"f").call(this,i)}}count_down_by_remain_seconds(r=l,s=60){const i=s*t(this,e,"f");return r({remain:i,obj:this.format_num2date(i)}),t(this,o,"f").call(this,i,r,t(this,e,"f")),()=>clearTimeout(t(this,a,"f"))}count_down(r=Date.now(),s=l){const n=t(this,i,"f").call(this,r)-Date.now();return s({remain:n,obj:this.format_num2date(n)}),t(this,o,"f").call(this,n,s,t(this,e,"f")),()=>clearTimeout(t(this,a,"f"))}format_thousandth(t){return t.toString().replace(/\d+/,(function(t){return t.replace(/(\d)(?=(\d{3})+$)/g,(function(t){return t+","}))}))}is_empty(e){return null==e||("String"===t(this,s,"f").call(this,e)?!e.trim():"Array"===t(this,s,"f").call(this,e)?!e.length:"Object"===t(this,s,"f").call(this,e)&&!Object.keys(e).length)}};export{f as default};
@@ -36,6 +36,7 @@ declare class Helper {
36
36
  count_down_by_remain_seconds(fn?: CountDownCallback, seconds?: number): Function;
37
37
  count_down(date?: DateType, fn?: CountDownCallback): Function;
38
38
  format_thousandth(num: number | string): string;
39
+ is_empty(data: any): boolean;
39
40
  }
40
41
  declare const _default: Helper;
41
42
  export default _default;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "fish-helper",
3
3
  "private": false,
4
- "version": "0.0.10",
4
+ "version": "0.0.11",
5
5
  "main": "build/helper.cjs.js",
6
6
  "module": "build/helper.es.js",
7
7
  "types": "build/types/index.d.ts",