ddan-js 1.1.8 → 1.1.9
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/bin/ddan-js.esm.js +1 -1
- package/bin/ddan-js.js +1 -1
- package/bin/lib/modules/time.js +6 -1
- package/bin/types/modules/time.d.ts +5 -0
- package/package.json +1 -1
package/bin/ddan-js.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var t={gbkLength:function(t){let e=0;if(!t)return 0;for(let n=0;n<t.length;n++)t.charCodeAt(n)>127||94===t.charCodeAt(n)?e+=2:e++;return e},gbkCut:function(t,e){if(!t||e<=0)return"";let n=0,r=0;for(let i=0;i<t.length&&(t.charCodeAt(i)>127||94===t.charCodeAt(i)?n+=2:n++,!(n>e));i++)r=i;return t.substr(0,r+1)}},e="object"==typeof global&&global&&global.Object===Object&&global,n="object"==typeof self&&self&&self.Object===Object&&self,r=e||n||Function("return this")();const i=(t,e="yyyy-MM-dd hh:mm:ss")=>{const n="string"==typeof t||"number"==typeof t?new Date(t):t,r={};return r.yyyy=n.getFullYear(),r.yy=`${r.yyyy}`.substr(2),r.M=n.getMonth()+1,r.MM=(r.M<10?"0":"")+r.M,r.d=n.getDate(),r.dd=(r.d<10?"0":"")+r.d,r.h=n.getHours(),r.hh=(r.h<10?"0":"")+r.h,r.m=n.getMinutes(),r.mm=(r.m<10?"0":"")+r.m,r.s=n.getSeconds(),r.ss=(r.s<10?"0":"")+r.s,r.S=n.getMilliseconds(),r.SS=(r.S<10?"0":"")+r.S,r.SSS=r.S.toString().padStart(3,0),e.replace(/\byyyy|yy|MM|M|dd|d|hh|h|mm|m|ss|s|SSS|SS|S\b/g,(t=>r[t]))};
|
|
1
|
+
var t={gbkLength:function(t){let e=0;if(!t)return 0;for(let n=0;n<t.length;n++)t.charCodeAt(n)>127||94===t.charCodeAt(n)?e+=2:e++;return e},gbkCut:function(t,e){if(!t||e<=0)return"";let n=0,r=0;for(let i=0;i<t.length&&(t.charCodeAt(i)>127||94===t.charCodeAt(i)?n+=2:n++,!(n>e));i++)r=i;return t.substr(0,r+1)}},e="object"==typeof global&&global&&global.Object===Object&&global,n="object"==typeof self&&self&&self.Object===Object&&self,r=e||n||Function("return this")();const i=(t,e="yyyy-MM-dd hh:mm:ss")=>{const n="string"==typeof t||"number"==typeof t?new Date(t):t,r={};return r.yyyy=n.getFullYear(),r.yy=`${r.yyyy}`.substr(2),r.M=n.getMonth()+1,r.MM=(r.M<10?"0":"")+r.M,r.d=n.getDate(),r.dd=(r.d<10?"0":"")+r.d,r.h=n.getHours(),r.hh=(r.h<10?"0":"")+r.h,r.m=n.getMinutes(),r.mm=(r.m<10?"0":"")+r.m,r.s=n.getSeconds(),r.ss=(r.s<10?"0":"")+r.s,r.S=n.getMilliseconds(),r.SS=(r.S<10?"0":"")+r.S,r.SSS=r.S.toString().padStart(3,0),e.replace(/\byyyy|yy|MM|M|dd|d|hh|h|mm|m|ss|s|SSS|SS|S\b/g,(t=>r[t]))};function o(){return r.Date.now()}var u={now:o,isToday:t=>(new Date).toDateString()===new Date(t).toDateString(),format:i,parseTime:function({year:t=0,month:e=0,date:n=0,hour:r=0,minute:o=0,second:u=0}){const s=`${t||"yyyy"}/${e||"MM"}/${n||"dd"} ${r}:${o}:${u}`;return new Date(i(Date.now(),s)).getTime()},todayZero:()=>new Date(i(o(),"yyyy/MM/dd 00:00:00")).getTime(),oneDay:864e5,oneHour:36e5,oneMinute:6e4,oneSecond:1e3};const s=r.Symbol,{toString:c,hasOwnProperty:a,propertyIsEnumerable:f}=Object.prototype,l=s?s.toStringTag:void 0;function h(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":l&&l in Object(t)?function(t){const e=a.call(t,l),n=t[l];let r=!1;try{t[l]=void 0,r=!0}catch(t){}const i=c.call(t);return r&&(e?t[l]=n:delete t[l]),i}(t):c.call(t)}var g={getTag:h,getType:function(t){return(h(t).match(/\w+/g)||["object","Undefined"])[1]||""},toString:c,hasOwnProperty:a,propertyIsEnumerable:f},y="[object Function]",d="[object GeneratorFunction]",m="[object AsyncFunction]",p=9007199254740991;const b=/^(?:0|[1-9]\d*)$/;function v(t){const e=typeof t;return null!=t&&("object"==e||"function"==e)}function S(t){return null!=t&&"object"==typeof t}const j=Array.isArray;function O(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=p}(t.length)&&!M(t)}function w(t){return S(t)&&O(t)}function M(t){var e=v(t)?g.getTag(t):"";return e===y||e===d||e===m}var A={is:function(t,e){return g.getTag(t)===`[object ${e}]`},isNumber:function(t){return"[object Number]"===g.getTag(t)},isString:function(t){return"string"==typeof t||!j(t)&&S(t)&&"[object String]"==g.getTag(t)},isChinese:function(t){return!!t&&!!/^[\u4E00-\u9FA5]+$/.test(t)},isObject:v,isObjectLike:S,isSymbol:function(t){return"symbol"==typeof t||S(t)&&"[object Symbol]"===g.getTag(t)},isFunction:M,isArray:j,isArrayLikeObject:w,isIndex:function(t,e){return!!(e=null==e?p:e)&&("number"==typeof t||b.test(t))&&t>-1&&t%1==0&&t<e},isArrayLike:O,isPrototype:function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Object.prototype)},isArguments:function(t){return w(t)&&g.hasOwnProperty.call(t,"callee")&&(!g.propertyIsEnumerable.call(t,"callee")||"[object Arguments]"==g.toString.call(t))},isPromise:function(t){return"[object Promise]"===(v(t)?g.getTag(t):"")}};const T=NaN,x=/^\s+|\s+$/g,D=/^[-+]0x[0-9a-f]+$/i,P=/^0b[01]+$/i,$=/^0o[0-7]+$/i,F=parseInt,k=1/0,E=17976931348623157e292;function N(t){if("number"==typeof t)return t;if(A.isSymbol(t))return T;if(A.isObject(t)){const e="function"==typeof t.valueOf?t.valueOf():t;t=A.isObject(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(x,"");const e=P.test(t);return e||$.test(t)?F(t.slice(2),e?2:8):D.test(t)?T:+t}function R(t){return t?(t=N(t))===k||t===-k?(t<0?-1:1)*E:t==t?t:0:0===t?t:0}var _={toNumber:N,toFinite:R,toInteger:function(t){var e=R(t),n=e%1;return e==e?n?e-n:e:0}};const I="Expected a function",C=Math.max,L=Math.min;function W(t,e=0,n={}){var r,i,o,u,s,c,a=0,f=!1,l=!1,h=!0;if("function"!=typeof t)throw new TypeError(I);function g(e){var n=r,o=i;return r=i=void 0,a=e,u=t.apply(o,n)}function y(t){var n=t-c;return void 0===c||n>=e||n<0||l&&t-a>=o}function d(){var t=Date.now();if(y(t))return m(t);s=setTimeout(d,function(t){var n=e-(t-c);return l?L(n,o-(t-a)):n}(t))}function m(t){return s=void 0,h&&r?g(t):(r=i=void 0,u)}function p(...t){var n=Date.now(),o=y(n);if(r=arguments,i=this,c=n,o){if(void 0===s)return function(t){return a=t,s=setTimeout(d,e),f?g(t):u}(c);if(l)return s=setTimeout(d,e),g(c)}return void 0===s&&(s=setTimeout(d,e)),u}return e=_.toNumber(e)||0,A.isObject(n)&&(f=!!n.leading,o=(l="maxWait"in n)?C(_.toNumber(n.maxWait)||0,e):o,h="trailing"in n?!!n.trailing:h),p.cancel=function(){void 0!==s&&clearTimeout(s),a=0,r=c=i=s=void 0},p.flush=function(){return void 0===s?u:m(Date.now())},p}class B{constructor(t){this.source=t}run(){let t;try{let e;return e=A.isFunction(this.source)?this.source():this.source,t=A.isPromise(e)?e:Promise.resolve(e),t.then((t=>[null,t])).catch((t=>[t,void 0]))}catch(t){return Promise.resolve([t,void 0])}}}var H={sleep:(t=1e3)=>new Promise((e=>{setTimeout(e,t)})),run:t=>new B(t).run(),debounce:W,throttle:function(t,e=0,n={}){var r=!1,i=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return A.isObject(n)&&(r=n.leading?!!n.leading:r,i=n.trailing?!!n.trailing:i),W(t,e,{leading:r,maxWait:e,trailing:i})}};var J={random:function(t){return Math.floor(Math.random()*t)},randomRange:function(t,e){return Math.floor(Math.random()*(e-t+1)+t)},lerp:function(t,e,n){return t*(1-n)+e*n}};function U(t){return t!=t}function G(t,e){return function(t,e){for(var n=-1,r=t?t.length:0,i=Array(r);++n<r;)i[n]=e(t[n],n,t);return i}(e,(function(e){return t[e]}))}var Y,Z,q=(Y=Object.keys,Z=Object,function(t){return Y(Z(t))}),z=Math.max;function K(t,e){var n=A.isArray(t)||A.isArguments(t)?function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}(t.length,String):[],r=n.length,i=!!r;for(var o in t)!e&&!g.hasOwnProperty.call(t,o)||i&&("length"==o||A.isIndex(o,r))||n.push(o);return n}var Q=Object.assign(Object.assign(Object.assign({},A),g),{includes:function(t,e,n,r){var i;t=A.isArrayLike(t)?t:(i=t)?G(i,function(t){return A.isArrayLike(t)?K(t):function(t){if(!A.isPrototype(t))return q(t);var e=[];for(var n in Object(t))g.hasOwnProperty.call(t,n)&&"constructor"!=n&&e.push(n);return e}(t)}(i)):[],n=n&&!r?_.toInteger(n):0;var o=t.length;return n<0&&(n=z(o+n,0)),A.isString(t)?n<=o&&t.indexOf(e,n)>-1:!!o&&function(t,e,n){if(e!=e)return function(t,e,n,r){for(var i=t.length,o=n+(r?1:-1);r?o--:++o<i;)if(e(t[o],o,t))return o;return-1}(t,U,n);for(var r=n-1,i=t.length;++r<i;)if(t[r]===e)return r;return-1}(t,e,n)>-1}});class V{constructor(){this._map=new Map}clear(){return this._map.clear(),this}on(t,e){if(!e)return this;let n=this._map.get(t);return n||(n=new Set,this._map.set(t,n)),n.add(e),this}emit(t,...e){const n=this._map.get(t);if(!n)return this;return[...n].forEach((t=>t(...e))),this}off(t="",e){if(!t)return this._map.clear(),this;if(!e)return this._map.delete(t.toString()),this;const n=this._map.get(t);return n?(n.delete(e),this):this}once(t,e){const n=(...r)=>{e(...r),this.off(t,n)};return this.on(t,n),this}has(t){return this._map.has(t)}}var X={groupBy:(t,e)=>t.reduce(((t,n)=>((t[n[e]]=t[n[e]]||[]).push(n),t)),{}),stepAction:function(t,e,n=100){if(!A.isFunction(e))return;if(!A.isArray(t)||t.length<=0)return;let r=0;for(;t.length>r;){let i=n+r,o=t.slice(r,i);e&&e(o),r=i}},skip:(t,e)=>{if(!A.isArray(t)||t.length<=0)return[];const n=e;return t.slice(n)},take:(t,e,n=0)=>{if(!A.isArray(t)||t.length<=0)return[];const r=n||0;if(r>=t.length)return[];const i=e+r;return t.slice(r,t.length<i?t.length:i)||[]},distinct:t=>!A.isArray(t)||t.length<=0?[]:[...new Set(t)]};function tt(t,e,n,r){return new(n||(n=Promise))((function(i,o){function u(t){try{c(r.next(t))}catch(t){o(t)}}function s(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,s)}c((r=r.apply(t,e||[])).next())}))}class et extends V{constructor(){super(),this.getters={},this.setters={},this.actions={}}dispatch(t,e=void 0){return tt(this,void 0,void 0,(function*(){const n=Reflect.get(this.actions,t);if(!A.isFunction(n))return;const[,r]=yield H.run(n(this,e));return r}))}getByOnce(t){return tt(this,void 0,void 0,(function*(){const e=Reflect.get(this,t);let n;return n=null!=e&&""!==e?JSON.parse(JSON.stringify(e)):yield this.dispatch(t),n}))}}const nt=t=>{const e=Object.assign(new et,t||{});return new Proxy(e,{get:(t,e,n)=>{const r=Reflect.get(t.getters,e);return A.isFunction(r)?r():Reflect.get(t,e,n)},set:(t,e,n,r)=>{const i=Reflect.get(t.setters,e);if(A.isFunction(i)&&!i(n))return!0;const o=Reflect.set(t,e,n,r);return o&&t.emit(e.toString(),n),o},has:(t,e)=>Reflect.has(t,e)})};var rt={gbk:t,time:u,hook:H,math:J,util:Q,list:X,DEvent:V,store:et,storeRef:nt};export{V as DEvent,rt as default,t as gbk,H as hook,X as list,J as math,et as store,nt as storeRef,u as time,Q as util};
|
package/bin/ddan-js.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ddan={})}(this,(function(t){"use strict";var e={gbkLength:function(t){let e=0;if(!t)return 0;for(let n=0;n<t.length;n++)t.charCodeAt(n)>127||94===t.charCodeAt(n)?e+=2:e++;return e},gbkCut:function(t,e){if(!t||e<=0)return"";let n=0,r=0;for(let
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ddan={})}(this,(function(t){"use strict";var e={gbkLength:function(t){let e=0;if(!t)return 0;for(let n=0;n<t.length;n++)t.charCodeAt(n)>127||94===t.charCodeAt(n)?e+=2:e++;return e},gbkCut:function(t,e){if(!t||e<=0)return"";let n=0,r=0;for(let o=0;o<t.length&&(t.charCodeAt(o)>127||94===t.charCodeAt(o)?n+=2:n++,!(n>e));o++)r=o;return t.substr(0,r+1)}},n="object"==typeof global&&global&&global.Object===Object&&global,r="object"==typeof self&&self&&self.Object===Object&&self,o=n||r||Function("return this")();const i=(t,e="yyyy-MM-dd hh:mm:ss")=>{const n="string"==typeof t||"number"==typeof t?new Date(t):t,r={};return r.yyyy=n.getFullYear(),r.yy=`${r.yyyy}`.substr(2),r.M=n.getMonth()+1,r.MM=(r.M<10?"0":"")+r.M,r.d=n.getDate(),r.dd=(r.d<10?"0":"")+r.d,r.h=n.getHours(),r.hh=(r.h<10?"0":"")+r.h,r.m=n.getMinutes(),r.mm=(r.m<10?"0":"")+r.m,r.s=n.getSeconds(),r.ss=(r.s<10?"0":"")+r.s,r.S=n.getMilliseconds(),r.SS=(r.S<10?"0":"")+r.S,r.SSS=r.S.toString().padStart(3,0),e.replace(/\byyyy|yy|MM|M|dd|d|hh|h|mm|m|ss|s|SSS|SS|S\b/g,(t=>r[t]))};function u(){return o.Date.now()}var s={now:u,isToday:t=>(new Date).toDateString()===new Date(t).toDateString(),format:i,parseTime:function({year:t=0,month:e=0,date:n=0,hour:r=0,minute:o=0,second:u=0}){const s=`${t||"yyyy"}/${e||"MM"}/${n||"dd"} ${r}:${o}:${u}`;return new Date(i(Date.now(),s)).getTime()},todayZero:()=>new Date(i(u(),"yyyy/MM/dd 00:00:00")).getTime(),oneDay:864e5,oneHour:36e5,oneMinute:6e4,oneSecond:1e3};const c=o.Symbol,{toString:a,hasOwnProperty:f,propertyIsEnumerable:l}=Object.prototype,h=c?c.toStringTag:void 0;function g(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":h&&h in Object(t)?function(t){const e=f.call(t,h),n=t[h];let r=!1;try{t[h]=void 0,r=!0}catch(t){}const o=a.call(t);return r&&(e?t[h]=n:delete t[h]),o}(t):a.call(t)}var y={getTag:g,getType:function(t){return(g(t).match(/\w+/g)||["object","Undefined"])[1]||""},toString:a,hasOwnProperty:f,propertyIsEnumerable:l},d="[object Function]",p="[object GeneratorFunction]",m="[object AsyncFunction]",b=9007199254740991;const v=/^(?:0|[1-9]\d*)$/;function j(t){const e=typeof t;return null!=t&&("object"==e||"function"==e)}function S(t){return null!=t&&"object"==typeof t}const O=Array.isArray;function w(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=b}(t.length)&&!A(t)}function M(t){return S(t)&&w(t)}function A(t){var e=j(t)?y.getTag(t):"";return e===d||e===p||e===m}var T={is:function(t,e){return y.getTag(t)===`[object ${e}]`},isNumber:function(t){return"[object Number]"===y.getTag(t)},isString:function(t){return"string"==typeof t||!O(t)&&S(t)&&"[object String]"==y.getTag(t)},isChinese:function(t){return!!t&&!!/^[\u4E00-\u9FA5]+$/.test(t)},isObject:j,isObjectLike:S,isSymbol:function(t){return"symbol"==typeof t||S(t)&&"[object Symbol]"===y.getTag(t)},isFunction:A,isArray:O,isArrayLikeObject:M,isIndex:function(t,e){return!!(e=null==e?b:e)&&("number"==typeof t||v.test(t))&&t>-1&&t%1==0&&t<e},isArrayLike:w,isPrototype:function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Object.prototype)},isArguments:function(t){return M(t)&&y.hasOwnProperty.call(t,"callee")&&(!y.propertyIsEnumerable.call(t,"callee")||"[object Arguments]"==y.toString.call(t))},isPromise:function(t){return"[object Promise]"===(j(t)?y.getTag(t):"")}};const x=NaN,D=/^\s+|\s+$/g,P=/^[-+]0x[0-9a-f]+$/i,k=/^0b[01]+$/i,$=/^0o[0-7]+$/i,F=parseInt,E=1/0,_=17976931348623157e292;function N(t){if("number"==typeof t)return t;if(T.isSymbol(t))return x;if(T.isObject(t)){const e="function"==typeof t.valueOf?t.valueOf():t;t=T.isObject(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(D,"");const e=k.test(t);return e||$.test(t)?F(t.slice(2),e?2:8):P.test(t)?x:+t}function R(t){return t?(t=N(t))===E||t===-E?(t<0?-1:1)*_:t==t?t:0:0===t?t:0}var I={toNumber:N,toFinite:R,toInteger:function(t){var e=R(t),n=e%1;return e==e?n?e-n:e:0}};const C="Expected a function",L=Math.max,W=Math.min;function B(t,e=0,n={}){var r,o,i,u,s,c,a=0,f=!1,l=!1,h=!0;if("function"!=typeof t)throw new TypeError(C);function g(e){var n=r,i=o;return r=o=void 0,a=e,u=t.apply(i,n)}function y(t){var n=t-c;return void 0===c||n>=e||n<0||l&&t-a>=i}function d(){var t=Date.now();if(y(t))return p(t);s=setTimeout(d,function(t){var n=e-(t-c);return l?W(n,i-(t-a)):n}(t))}function p(t){return s=void 0,h&&r?g(t):(r=o=void 0,u)}function m(...t){var n=Date.now(),i=y(n);if(r=arguments,o=this,c=n,i){if(void 0===s)return function(t){return a=t,s=setTimeout(d,e),f?g(t):u}(c);if(l)return s=setTimeout(d,e),g(c)}return void 0===s&&(s=setTimeout(d,e)),u}return e=I.toNumber(e)||0,T.isObject(n)&&(f=!!n.leading,i=(l="maxWait"in n)?L(I.toNumber(n.maxWait)||0,e):i,h="trailing"in n?!!n.trailing:h),m.cancel=function(){void 0!==s&&clearTimeout(s),a=0,r=c=o=s=void 0},m.flush=function(){return void 0===s?u:p(Date.now())},m}class H{constructor(t){this.source=t}run(){let t;try{let e;return e=T.isFunction(this.source)?this.source():this.source,t=T.isPromise(e)?e:Promise.resolve(e),t.then((t=>[null,t])).catch((t=>[t,void 0]))}catch(t){return Promise.resolve([t,void 0])}}}var J={sleep:(t=1e3)=>new Promise((e=>{setTimeout(e,t)})),run:t=>new H(t).run(),debounce:B,throttle:function(t,e=0,n={}){var r=!1,o=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return T.isObject(n)&&(r=n.leading?!!n.leading:r,o=n.trailing?!!n.trailing:o),B(t,e,{leading:r,maxWait:e,trailing:o})}};var U={random:function(t){return Math.floor(Math.random()*t)},randomRange:function(t,e){return Math.floor(Math.random()*(e-t+1)+t)},lerp:function(t,e,n){return t*(1-n)+e*n}};function G(t){return t!=t}function Y(t,e){return function(t,e){for(var n=-1,r=t?t.length:0,o=Array(r);++n<r;)o[n]=e(t[n],n,t);return o}(e,(function(e){return t[e]}))}var Z,q,z=(Z=Object.keys,q=Object,function(t){return Z(q(t))}),K=Math.max;function Q(t,e){var n=T.isArray(t)||T.isArguments(t)?function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}(t.length,String):[],r=n.length,o=!!r;for(var i in t)!e&&!y.hasOwnProperty.call(t,i)||o&&("length"==i||T.isIndex(i,r))||n.push(i);return n}var V=Object.assign(Object.assign(Object.assign({},T),y),{includes:function(t,e,n,r){var o;t=T.isArrayLike(t)?t:(o=t)?Y(o,function(t){return T.isArrayLike(t)?Q(t):function(t){if(!T.isPrototype(t))return z(t);var e=[];for(var n in Object(t))y.hasOwnProperty.call(t,n)&&"constructor"!=n&&e.push(n);return e}(t)}(o)):[],n=n&&!r?I.toInteger(n):0;var i=t.length;return n<0&&(n=K(i+n,0)),T.isString(t)?n<=i&&t.indexOf(e,n)>-1:!!i&&function(t,e,n){if(e!=e)return function(t,e,n,r){for(var o=t.length,i=n+(r?1:-1);r?i--:++i<o;)if(e(t[i],i,t))return i;return-1}(t,G,n);for(var r=n-1,o=t.length;++r<o;)if(t[r]===e)return r;return-1}(t,e,n)>-1}});class X{constructor(){this._map=new Map}clear(){return this._map.clear(),this}on(t,e){if(!e)return this;let n=this._map.get(t);return n||(n=new Set,this._map.set(t,n)),n.add(e),this}emit(t,...e){const n=this._map.get(t);if(!n)return this;return[...n].forEach((t=>t(...e))),this}off(t="",e){if(!t)return this._map.clear(),this;if(!e)return this._map.delete(t.toString()),this;const n=this._map.get(t);return n?(n.delete(e),this):this}once(t,e){const n=(...r)=>{e(...r),this.off(t,n)};return this.on(t,n),this}has(t){return this._map.has(t)}}var tt={groupBy:(t,e)=>t.reduce(((t,n)=>((t[n[e]]=t[n[e]]||[]).push(n),t)),{}),stepAction:function(t,e,n=100){if(!T.isFunction(e))return;if(!T.isArray(t)||t.length<=0)return;let r=0;for(;t.length>r;){let o=n+r,i=t.slice(r,o);e&&e(i),r=o}},skip:(t,e)=>{if(!T.isArray(t)||t.length<=0)return[];const n=e;return t.slice(n)},take:(t,e,n=0)=>{if(!T.isArray(t)||t.length<=0)return[];const r=n||0;if(r>=t.length)return[];const o=e+r;return t.slice(r,t.length<o?t.length:o)||[]},distinct:t=>!T.isArray(t)||t.length<=0?[]:[...new Set(t)]};function et(t,e,n,r){return new(n||(n=Promise))((function(o,i){function u(t){try{c(r.next(t))}catch(t){i(t)}}function s(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,s)}c((r=r.apply(t,e||[])).next())}))}class nt extends X{constructor(){super(),this.getters={},this.setters={},this.actions={}}dispatch(t,e=void 0){return et(this,void 0,void 0,(function*(){const n=Reflect.get(this.actions,t);if(!T.isFunction(n))return;const[,r]=yield J.run(n(this,e));return r}))}getByOnce(t){return et(this,void 0,void 0,(function*(){const e=Reflect.get(this,t);let n;return n=null!=e&&""!==e?JSON.parse(JSON.stringify(e)):yield this.dispatch(t),n}))}}const rt=t=>{const e=Object.assign(new nt,t||{});return new Proxy(e,{get:(t,e,n)=>{const r=Reflect.get(t.getters,e);return T.isFunction(r)?r():Reflect.get(t,e,n)},set:(t,e,n,r)=>{const o=Reflect.get(t.setters,e);if(T.isFunction(o)&&!o(n))return!0;const i=Reflect.set(t,e,n,r);return i&&t.emit(e.toString(),n),i},has:(t,e)=>Reflect.has(t,e)})};var ot={gbk:e,time:s,hook:J,math:U,util:V,list:tt,DEvent:X,store:nt,storeRef:rt};t.DEvent=X,t.default=ot,t.gbk=e,t.hook=J,t.list=tt,t.math=U,t.store=nt,t.storeRef=rt,t.time=s,t.util=V,Object.defineProperty(t,"__esModule",{value:!0})}));
|
package/bin/lib/modules/time.js
CHANGED
|
@@ -7,6 +7,11 @@ const _root_1 = require("../common/_root");
|
|
|
7
7
|
* @returns
|
|
8
8
|
*/
|
|
9
9
|
const isToday = (date) => new Date().toDateString() === new Date(date).toDateString();
|
|
10
|
+
const todayZero = () => new Date(format(now(), "yyyy/MM/dd 00:00:00")).getTime();
|
|
11
|
+
const oneDay = 86400000;
|
|
12
|
+
const oneHour = 3600000;
|
|
13
|
+
const oneMinute = 60000;
|
|
14
|
+
const oneSecond = 1000;
|
|
10
15
|
/**
|
|
11
16
|
* 时间格式化
|
|
12
17
|
* @param {string|number|Date} time
|
|
@@ -41,4 +46,4 @@ function now() {
|
|
|
41
46
|
return _root_1.default.Date.now();
|
|
42
47
|
}
|
|
43
48
|
;
|
|
44
|
-
exports.default = { now, isToday, format, parseTime };
|
|
49
|
+
exports.default = { now, isToday, format, parseTime, todayZero, oneDay, oneHour, oneMinute, oneSecond };
|
|
@@ -12,5 +12,10 @@ declare const _default: {
|
|
|
12
12
|
isToday: (date: any) => boolean;
|
|
13
13
|
format: (time: string | number | Date, reg?: string) => string;
|
|
14
14
|
parseTime: typeof parseTime;
|
|
15
|
+
todayZero: () => number;
|
|
16
|
+
oneDay: number;
|
|
17
|
+
oneHour: number;
|
|
18
|
+
oneMinute: number;
|
|
19
|
+
oneSecond: number;
|
|
15
20
|
};
|
|
16
21
|
export default _default;
|