fish-helper 0.0.11 → 0.0.13
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 +2 -0
- package/build/helper.cjs.js +1 -1
- package/build/helper.es.js +1 -1
- package/build/types/index.d.ts +1 -0
- package/package.json +2 -4
package/README.md
CHANGED
|
@@ -8,6 +8,8 @@ const helper = require('fish-helper')
|
|
|
8
8
|
|
|
9
9
|
> Methods
|
|
10
10
|
>
|
|
11
|
+
> - add(hour, start) ------- add Hour from start date, return timestamp
|
|
12
|
+
>
|
|
11
13
|
> - offset_time(date, type) ------- The time difference (absolute value), returns the corresponding string as the second argument, such as 01,22....
|
|
12
14
|
>
|
|
13
15
|
> - before_lt_hour(date, hour) ------- The <strong>date</strong> is less than <strong>now</strong>, and the date is less than <strong>hour</strong> from <strong>now</strong>
|
package/build/helper.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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
|
|
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,h,o;const l=()=>null;e=new WeakMap,r=new WeakMap,s=new WeakMap,a=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),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))),h.set(this,(({date:e,hour:s=1,type:a="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"===a?l&&h+t(this,r,"f")*s>o:"before_gt_hour"===a?l&&h+t(this,r,"f")*s<o:"after_lt_hour"===a?f&&o+t(this,r,"f")*s>h:"after_gt_hour"===a&&(f&&o+t(this,r,"f")*s<h)})),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"},o.set(this,((r=0,a=l,i=t(this,e,"f"),n=0,h=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()-(h+n*t(this,e,"f"));let i=t(this,e,"f")-s;i<0&&(i=0),t(this,o,"f").call(this,r,a,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),s=new Date(r),a=t(this,n,"f").call(this,s.getMonth()+1),h=t(this,n,"f").call(this,s.getDate()),o=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:h,hour:o,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>0&&i<r)return a?`${i} ${s}`:i;const[n,h]=(i/r).toFixed(e).split(".");return h&&0!==parseFloat(h)?`${n}.${h} ${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,o,"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,o,"f").call(this,n,a,t(this,e,"f")),()=>clearTimeout(t(this,s,"f"))}add(e=1,r=Date.now()){return t(this,i,"f").call(this,r)+60*e*60*1e3}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;
|
package/build/helper.es.js
CHANGED
|
@@ -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,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
|
+
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>0&&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"))}add(e=1,r=Date.now()){return t(this,i,"f").call(this,r)+60*e*60*1e3}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};
|
package/build/types/index.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ declare class Helper {
|
|
|
35
35
|
format_num2date(timestamp?: number): FormatNum2Date;
|
|
36
36
|
count_down_by_remain_seconds(fn?: CountDownCallback, seconds?: number): Function;
|
|
37
37
|
count_down(date?: DateType, fn?: CountDownCallback): Function;
|
|
38
|
+
add(hours?: number, start?: DateType): number;
|
|
38
39
|
format_thousandth(num: number | string): string;
|
|
39
40
|
is_empty(data: any): boolean;
|
|
40
41
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fish-helper",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.13",
|
|
5
5
|
"main": "build/helper.cjs.js",
|
|
6
6
|
"module": "build/helper.es.js",
|
|
7
7
|
"types": "build/types/index.d.ts",
|
|
@@ -19,9 +19,7 @@
|
|
|
19
19
|
"files": [
|
|
20
20
|
"build"
|
|
21
21
|
],
|
|
22
|
-
"scripts": {
|
|
23
|
-
"dev": "rollup -w -c rolluo.config.js"
|
|
24
|
-
},
|
|
22
|
+
"scripts": {},
|
|
25
23
|
"author": {
|
|
26
24
|
"name": "weixin_38726348"
|
|
27
25
|
},
|