ddan-js 1.1.2 → 1.1.3
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/hook/index.js +1 -16
- package/bin/lib/modules/list.js +24 -0
- package/bin/lib/util/is.js +4 -0
- package/bin/types/index.d.ts +1 -1
- package/bin/types/modules/hook/index.d.ts +0 -3
- package/bin/types/modules/list.d.ts +7 -0
- package/bin/types/util/index.d.ts +1 -0
- package/bin/types/util/is.d.ts +2 -0
- package/package.json +1 -1
package/bin/ddan-js.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var t={gbkLength:function(t){var n=0;if(!t)return 0;for(var r=0;r<t.length;r++)t.charCodeAt(r)>127||94===t.charCodeAt(r)?n+=2:n++;return n},gbkCut:function(t,n){if(!t||n<=0)return"";for(var r=0,e=0,o=0;o<t.length&&(t.charCodeAt(o)>127||94===t.charCodeAt(o)?r+=2:r++,!(r>n));o++)e=o;return t.substr(0,e+1)}},n="object"==typeof global&&global&&global.Object===Object&&global,r="object"==typeof self&&self&&self.Object===Object&&self,e=n||r||Function("return this")(),o=function(t,n){void 0===n&&(n="yyyy-MM-dd hh:mm:ss");var r="string"==typeof t||"number"==typeof t?new Date(t):t,e={};return e.yyyy=r.getFullYear(),e.yy="".concat(e.yyyy).substr(2),e.M=r.getMonth()+1,e.MM=(e.M<10?"0":"")+e.M,e.d=r.getDate(),e.dd=(e.d<10?"0":"")+e.d,e.h=r.getHours(),e.hh=(e.h<10?"0":"")+e.h,e.m=r.getMinutes(),e.mm=(e.m<10?"0":"")+e.m,e.s=r.getSeconds(),e.ss=(e.s<10?"0":"")+e.s,e.S=r.getMilliseconds(),e.SS=(e.S<10?"0":"")+e.S,e.SSS=e.S.toString().padStart(3,0),n.replace(/\byyyy|yy|MM|M|dd|d|hh|h|mm|m|ss|s|SSS|SS|S\b/g,(function(t){return e[t]}))};var i={now:function(){return e.Date.now()},isToday:function(t){return(new Date).toDateString()===new Date(t).toDateString()},format:o,parseTime:function(t){var n=t.year,r=void 0===n?0:n,e=t.month,i=void 0===e?0:e,u=t.date,a=void 0===u?0:u,c=t.hour,f=void 0===c?0:c,s=t.minute,l=void 0===s?0:s,y=t.second,h=void 0===y?0:y,p="".concat(r||"yyyy","/").concat(i||"MM","/").concat(a||"dd"," ").concat(f,":").concat(l,":").concat(h);return new Date(o(Date.now(),p)).getTime()}},u=e.Symbol,a=Object.prototype,c=a.toString,f=a.hasOwnProperty,s=a.propertyIsEnumerable,l=u?u.toStringTag:void 0;function y(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":l&&l in Object(t)?function(t){var n=f.call(t,l),r=t[l],e=!1;try{t[l]=void 0,e=!0}catch(t){}var o=c.call(t);return e&&(n?t[l]=r:delete t[l]),o}(t):c.call(t)}var h={getTag:y,getType:function(t){return(y(t).match(/\w+/g)||["object","Undefined"])[1]||""},toString:c,hasOwnProperty:f,propertyIsEnumerable:s},p="[object Function]",v="[object GeneratorFunction]",g="[object AsyncFunction]",d=9007199254740991,m=/^(?:0|[1-9]\d*)$/;function b(t){var n=typeof t;return null!=t&&("object"==n||"function"==n)}function
|
|
1
|
+
var t={gbkLength:function(t){var n=0;if(!t)return 0;for(var r=0;r<t.length;r++)t.charCodeAt(r)>127||94===t.charCodeAt(r)?n+=2:n++;return n},gbkCut:function(t,n){if(!t||n<=0)return"";for(var r=0,e=0,o=0;o<t.length&&(t.charCodeAt(o)>127||94===t.charCodeAt(o)?r+=2:r++,!(r>n));o++)e=o;return t.substr(0,e+1)}},n="object"==typeof global&&global&&global.Object===Object&&global,r="object"==typeof self&&self&&self.Object===Object&&self,e=n||r||Function("return this")(),o=function(t,n){void 0===n&&(n="yyyy-MM-dd hh:mm:ss");var r="string"==typeof t||"number"==typeof t?new Date(t):t,e={};return e.yyyy=r.getFullYear(),e.yy="".concat(e.yyyy).substr(2),e.M=r.getMonth()+1,e.MM=(e.M<10?"0":"")+e.M,e.d=r.getDate(),e.dd=(e.d<10?"0":"")+e.d,e.h=r.getHours(),e.hh=(e.h<10?"0":"")+e.h,e.m=r.getMinutes(),e.mm=(e.m<10?"0":"")+e.m,e.s=r.getSeconds(),e.ss=(e.s<10?"0":"")+e.s,e.S=r.getMilliseconds(),e.SS=(e.S<10?"0":"")+e.S,e.SSS=e.S.toString().padStart(3,0),n.replace(/\byyyy|yy|MM|M|dd|d|hh|h|mm|m|ss|s|SSS|SS|S\b/g,(function(t){return e[t]}))};var i={now:function(){return e.Date.now()},isToday:function(t){return(new Date).toDateString()===new Date(t).toDateString()},format:o,parseTime:function(t){var n=t.year,r=void 0===n?0:n,e=t.month,i=void 0===e?0:e,u=t.date,a=void 0===u?0:u,c=t.hour,f=void 0===c?0:c,s=t.minute,l=void 0===s?0:s,y=t.second,h=void 0===y?0:y,p="".concat(r||"yyyy","/").concat(i||"MM","/").concat(a||"dd"," ").concat(f,":").concat(l,":").concat(h);return new Date(o(Date.now(),p)).getTime()}},u=e.Symbol,a=Object.prototype,c=a.toString,f=a.hasOwnProperty,s=a.propertyIsEnumerable,l=u?u.toStringTag:void 0;function y(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":l&&l in Object(t)?function(t){var n=f.call(t,l),r=t[l],e=!1;try{t[l]=void 0,e=!0}catch(t){}var o=c.call(t);return e&&(n?t[l]=r:delete t[l]),o}(t):c.call(t)}var h={getTag:y,getType:function(t){return(y(t).match(/\w+/g)||["object","Undefined"])[1]||""},toString:c,hasOwnProperty:f,propertyIsEnumerable:s},p="[object Function]",v="[object GeneratorFunction]",g="[object AsyncFunction]",d=9007199254740991,m=/^(?:0|[1-9]\d*)$/;function b(t){var n=typeof t;return null!=t&&("object"==n||"function"==n)}function j(t){return null!=t&&"object"==typeof t}var S=Array.isArray;function O(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=d}(t.length)&&!M(t)}function w(t){return j(t)&&O(t)}function M(t){var n=b(t)?h.getTag(t):"";return n===p||n===v||n===g}var A={is:function(t,n){return h.getTag(t)==="[object ".concat(n,"]")},isNumber:function(t){return"[object Number]"===h.getTag(t)},isString:function(t){return"string"==typeof t||!S(t)&&j(t)&&"[object String]"==h.getTag(t)},isChinese:function(t){return!!t&&!!/^[\u4E00-\u9FA5]+$/.test(t)},isObject:b,isObjectLike:j,isSymbol:function(t){return"symbol"==typeof t||j(t)&&"[object Symbol]"===h.getTag(t)},isFunction:M,isArray:S,isArrayLikeObject:w,isIndex:function(t,n){return!!(n=null==n?d:n)&&("number"==typeof t||m.test(t))&&t>-1&&t%1==0&&t<n},isArrayLike:O,isPrototype:function(t){var n=t&&t.constructor;return t===("function"==typeof n&&n.prototype||Object.prototype)},isArguments:function(t){return w(t)&&h.hasOwnProperty.call(t,"callee")&&(!h.propertyIsEnumerable.call(t,"callee")||"[object Arguments]"==h.toString.call(t))},isPromise:function(t){return"[object Promise]"===(b(t)?h.getTag(t):"")}},T=NaN,P=/^\s+|\s+$/g,D=/^[-+]0x[0-9a-f]+$/i,x=/^0b[01]+$/i,k=/^0o[0-7]+$/i,E=parseInt,F=1/0,_=17976931348623157e292;function I(t){if("number"==typeof t)return t;if(A.isSymbol(t))return T;if(A.isObject(t)){var n="function"==typeof t.valueOf?t.valueOf():t;t=A.isObject(n)?n+"":n}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(P,"");var r=x.test(t);return r||k.test(t)?E(t.slice(2),r?2:8):D.test(t)?T:+t}function N(t){return t?(t=I(t))===F||t===-F?(t<0?-1:1)*_:t==t?t:0:0===t?t:0}var C={toNumber:I,toFinite:N,toInteger:function(t){var n=N(t),r=n%1;return n==n?r?n-r:n:0}},L="Expected a function",$=Math.max,W=Math.min;function U(t,n,r){void 0===n&&(n=0),void 0===r&&(r={});var e,o,i,u,a,c,f=0,s=!1,l=!1,y=!0;if("function"!=typeof t)throw new TypeError(L);function h(n){var r=e,i=o;return e=o=void 0,f=n,u=t.apply(i,r)}function p(t){var r=t-c;return void 0===c||r>=n||r<0||l&&t-f>=i}function v(){var t=Date.now();if(p(t))return g(t);a=setTimeout(v,function(t){var r=n-(t-c);return l?W(r,i-(t-f)):r}(t))}function g(t){return a=void 0,y&&e?h(t):(e=o=void 0,u)}function d(){var t=Date.now(),r=p(t);if(e=arguments,o=this,c=t,r){if(void 0===a)return function(t){return f=t,a=setTimeout(v,n),s?h(t):u}(c);if(l)return a=setTimeout(v,n),h(c)}return void 0===a&&(a=setTimeout(v,n)),u}return n=C.toNumber(n)||0,A.isObject(r)&&(s=!!r.leading,i=(l="maxWait"in r)?$(C.toNumber(r.maxWait)||0,n):i,y="trailing"in r?!!r.trailing:y),d.cancel=function(){void 0!==a&&clearTimeout(a),f=0,e=c=o=a=void 0},d.flush=function(){return void 0===a?u:g(Date.now())},d}var G=function(){function t(t){this.source=t}return t.prototype.run=function(){try{var t=void 0;return t=A.isFunction(this.source)?this.source():this.source,(A.isPromise(t)?t:Promise.resolve(t)).then((function(t){return[null,t]})).catch((function(t){return[t,void 0]}))}catch(t){return Promise.resolve([t,void 0])}},t}(),H={sleep:function(t){return void 0===t&&(t=1e3),new Promise((function(n){setTimeout(n,t)}))},run:function(t){return new G(t).run()},debounce:U,throttle:function(t,n,r){void 0===n&&(n=0),void 0===r&&(r={});var e=!1,o=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return A.isObject(r)&&(e=r.leading?!!r.leading:e,o=r.trailing?!!r.trailing:o),U(t,n,{leading:e,maxWait:n,trailing:o})}};var R={random:function(t){return Math.floor(Math.random()*t)},randomRange:function(t,n){return Math.floor(Math.random()*(n-t+1)+t)},lerp:function(t,n,r){return t*(1-r)+n*r}},Y=function(){return Y=Object.assign||function(t){for(var n,r=1,e=arguments.length;r<e;r++)for(var o in n=arguments[r])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},Y.apply(this,arguments)};function q(t){return t!=t}function z(t,n){return function(t,n){for(var r=-1,e=t?t.length:0,o=Array(e);++r<e;)o[r]=n(t[r],r,t);return o}(n,(function(n){return t[n]}))}var B,J,K=(B=Object.keys,J=Object,function(t){return B(J(t))}),Q=Math.max;function V(t,n){var r=A.isArray(t)||A.isArguments(t)?function(t,n){for(var r=-1,e=Array(t);++r<t;)e[r]=n(r);return e}(t.length,String):[],e=r.length,o=!!e;for(var i in t)!n&&!h.hasOwnProperty.call(t,i)||o&&("length"==i||A.isIndex(i,e))||r.push(i);return r}var X=Y(Y(Y({},A),h),{includes:function(t,n,r,e){var o;t=A.isArrayLike(t)?t:(o=t)?z(o,function(t){return A.isArrayLike(t)?V(t):function(t){if(!A.isPrototype(t))return K(t);var n=[];for(var r in Object(t))h.hasOwnProperty.call(t,r)&&"constructor"!=r&&n.push(r);return n}(t)}(o)):[],r=r&&!e?C.toInteger(r):0;var i=t.length;return r<0&&(r=Q(i+r,0)),A.isString(t)?r<=i&&t.indexOf(n,r)>-1:!!i&&function(t,n,r){if(n!=n)return function(t,n,r,e){for(var o=t.length,i=r+(e?1:-1);e?i--:++i<o;)if(n(t[i],i,t))return i;return-1}(t,q,r);for(var e=r-1,o=t.length;++e<o;)if(t[e]===n)return e;return-1}(t,n,r)>-1}}),Z=function(){function t(){this._map=new Map}return t.prototype.clear=function(){return this._map.clear(),this},t.prototype.on=function(t,n){if(!n)return this;var r=this._map.get(t);return r||(r=new Set,this._map.set(t,r)),r.add(n),this},t.prototype.emit=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var e=this._map.get(t);if(!e)return this;var o=function(t,n,r){if(r||2===arguments.length)for(var e,o=0,i=n.length;o<i;o++)!e&&o in n||(e||(e=Array.prototype.slice.call(n,0,o)),e[o]=n[o]);return t.concat(e||Array.prototype.slice.call(n))}([],e,!0);return o.forEach((function(t){return t.apply(void 0,n)})),this},t.prototype.off=function(t,n){if(void 0===t&&(t=""),!t)return this._map.clear(),this;if(!n)return this._map.delete(t.toString()),this;var r=this._map.get(t);return r?(r.delete(n),this):this},t.prototype.once=function(t,n){var r=this,e=function(){for(var o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];n.apply(void 0,o),r.off(t,e)};return this.on(t,e),this},t.prototype.has=function(t){return this._map.has(t)},t}(),tt={gbk:t,time:i,hook:H,math:R,util:X,DEvent:Z};export{Z as DEvent,tt as default,t as gbk,H as hook,R as math,i as time,X as util};
|
package/bin/ddan-js.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).ddan={})}(this,(function(t){"use strict";var n={gbkLength:function(t){var n=0;if(!t)return 0;for(var r=0;r<t.length;r++)t.charCodeAt(r)>127||94===t.charCodeAt(r)?n+=2:n++;return n},gbkCut:function(t,n){if(!t||n<=0)return"";for(var r=0,e=0,o=0;o<t.length&&(t.charCodeAt(o)>127||94===t.charCodeAt(o)?r+=2:r++,!(r>n));o++)e=o;return t.substr(0,e+1)}},r="object"==typeof global&&global&&global.Object===Object&&global,e="object"==typeof self&&self&&self.Object===Object&&self,o=r||e||Function("return this")(),i=function(t,n){void 0===n&&(n="yyyy-MM-dd hh:mm:ss");var r="string"==typeof t||"number"==typeof t?new Date(t):t,e={};return e.yyyy=r.getFullYear(),e.yy="".concat(e.yyyy).substr(2),e.M=r.getMonth()+1,e.MM=(e.M<10?"0":"")+e.M,e.d=r.getDate(),e.dd=(e.d<10?"0":"")+e.d,e.h=r.getHours(),e.hh=(e.h<10?"0":"")+e.h,e.m=r.getMinutes(),e.mm=(e.m<10?"0":"")+e.m,e.s=r.getSeconds(),e.ss=(e.s<10?"0":"")+e.s,e.S=r.getMilliseconds(),e.SS=(e.S<10?"0":"")+e.S,e.SSS=e.S.toString().padStart(3,0),n.replace(/\byyyy|yy|MM|M|dd|d|hh|h|mm|m|ss|s|SSS|SS|S\b/g,(function(t){return e[t]}))};var u={now:function(){return o.Date.now()},isToday:function(t){return(new Date).toDateString()===new Date(t).toDateString()},format:i,parseTime:function(t){var n=t.year,r=void 0===n?0:n,e=t.month,o=void 0===e?0:e,u=t.date,a=void 0===u?0:u,c=t.hour,f=void 0===c?0:c,s=t.minute,l=void 0===s?0:s,y=t.second,h=void 0===y?0:y,p="".concat(r||"yyyy","/").concat(o||"MM","/").concat(a||"dd"," ").concat(f,":").concat(l,":").concat(h);return new Date(i(Date.now(),p)).getTime()}},a=o.Symbol,c=Object.prototype,f=c.toString,s=c.hasOwnProperty,l=c.propertyIsEnumerable,y=a?a.toStringTag:void 0;function h(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":y&&y in Object(t)?function(t){var n=s.call(t,y),r=t[y],e=!1;try{t[y]=void 0,e=!0}catch(t){}var o=f.call(t);return e&&(n?t[y]=r:delete t[y]),o}(t):f.call(t)}var p={getTag:h,getType:function(t){return(h(t).match(/\w+/g)||["object","Undefined"])[1]||""},toString:f,hasOwnProperty:s,propertyIsEnumerable:l},d="[object Function]",v="[object GeneratorFunction]",g="[object AsyncFunction]",m=9007199254740991,b=/^(?:0|[1-9]\d*)$/;function j(t){var n=typeof t;return null!=t&&("object"==n||"function"==n)}function S(t){return null!=t&&"object"==typeof t}var O=Array.isArray;function w(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=m}(t.length)&&!
|
|
1
|
+
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).ddan={})}(this,(function(t){"use strict";var n={gbkLength:function(t){var n=0;if(!t)return 0;for(var r=0;r<t.length;r++)t.charCodeAt(r)>127||94===t.charCodeAt(r)?n+=2:n++;return n},gbkCut:function(t,n){if(!t||n<=0)return"";for(var r=0,e=0,o=0;o<t.length&&(t.charCodeAt(o)>127||94===t.charCodeAt(o)?r+=2:r++,!(r>n));o++)e=o;return t.substr(0,e+1)}},r="object"==typeof global&&global&&global.Object===Object&&global,e="object"==typeof self&&self&&self.Object===Object&&self,o=r||e||Function("return this")(),i=function(t,n){void 0===n&&(n="yyyy-MM-dd hh:mm:ss");var r="string"==typeof t||"number"==typeof t?new Date(t):t,e={};return e.yyyy=r.getFullYear(),e.yy="".concat(e.yyyy).substr(2),e.M=r.getMonth()+1,e.MM=(e.M<10?"0":"")+e.M,e.d=r.getDate(),e.dd=(e.d<10?"0":"")+e.d,e.h=r.getHours(),e.hh=(e.h<10?"0":"")+e.h,e.m=r.getMinutes(),e.mm=(e.m<10?"0":"")+e.m,e.s=r.getSeconds(),e.ss=(e.s<10?"0":"")+e.s,e.S=r.getMilliseconds(),e.SS=(e.S<10?"0":"")+e.S,e.SSS=e.S.toString().padStart(3,0),n.replace(/\byyyy|yy|MM|M|dd|d|hh|h|mm|m|ss|s|SSS|SS|S\b/g,(function(t){return e[t]}))};var u={now:function(){return o.Date.now()},isToday:function(t){return(new Date).toDateString()===new Date(t).toDateString()},format:i,parseTime:function(t){var n=t.year,r=void 0===n?0:n,e=t.month,o=void 0===e?0:e,u=t.date,a=void 0===u?0:u,c=t.hour,f=void 0===c?0:c,s=t.minute,l=void 0===s?0:s,y=t.second,h=void 0===y?0:y,p="".concat(r||"yyyy","/").concat(o||"MM","/").concat(a||"dd"," ").concat(f,":").concat(l,":").concat(h);return new Date(i(Date.now(),p)).getTime()}},a=o.Symbol,c=Object.prototype,f=c.toString,s=c.hasOwnProperty,l=c.propertyIsEnumerable,y=a?a.toStringTag:void 0;function h(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":y&&y in Object(t)?function(t){var n=s.call(t,y),r=t[y],e=!1;try{t[y]=void 0,e=!0}catch(t){}var o=f.call(t);return e&&(n?t[y]=r:delete t[y]),o}(t):f.call(t)}var p={getTag:h,getType:function(t){return(h(t).match(/\w+/g)||["object","Undefined"])[1]||""},toString:f,hasOwnProperty:s,propertyIsEnumerable:l},d="[object Function]",v="[object GeneratorFunction]",g="[object AsyncFunction]",m=9007199254740991,b=/^(?:0|[1-9]\d*)$/;function j(t){var n=typeof t;return null!=t&&("object"==n||"function"==n)}function S(t){return null!=t&&"object"==typeof t}var O=Array.isArray;function w(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=m}(t.length)&&!T(t)}function M(t){return S(t)&&w(t)}function T(t){var n=j(t)?p.getTag(t):"";return n===d||n===v||n===g}var A={is:function(t,n){return p.getTag(t)==="[object ".concat(n,"]")},isNumber:function(t){return"[object Number]"===p.getTag(t)},isString:function(t){return"string"==typeof t||!O(t)&&S(t)&&"[object String]"==p.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]"===p.getTag(t)},isFunction:T,isArray:O,isArrayLikeObject:M,isIndex:function(t,n){return!!(n=null==n?m:n)&&("number"==typeof t||b.test(t))&&t>-1&&t%1==0&&t<n},isArrayLike:w,isPrototype:function(t){var n=t&&t.constructor;return t===("function"==typeof n&&n.prototype||Object.prototype)},isArguments:function(t){return M(t)&&p.hasOwnProperty.call(t,"callee")&&(!p.propertyIsEnumerable.call(t,"callee")||"[object Arguments]"==p.toString.call(t))},isPromise:function(t){return"[object Promise]"===(j(t)?p.getTag(t):"")}},P=NaN,x=/^\s+|\s+$/g,D=/^[-+]0x[0-9a-f]+$/i,k=/^0b[01]+$/i,E=/^0o[0-7]+$/i,_=parseInt,F=1/0,I=17976931348623157e292;function N(t){if("number"==typeof t)return t;if(A.isSymbol(t))return P;if(A.isObject(t)){var n="function"==typeof t.valueOf?t.valueOf():t;t=A.isObject(n)?n+"":n}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(x,"");var r=k.test(t);return r||E.test(t)?_(t.slice(2),r?2:8):D.test(t)?P:+t}function C(t){return t?(t=N(t))===F||t===-F?(t<0?-1:1)*I:t==t?t:0:0===t?t:0}var L={toNumber:N,toFinite:C,toInteger:function(t){var n=C(t),r=n%1;return n==n?r?n-r:n:0}},$="Expected a function",W=Math.max,U=Math.min;function G(t,n,r){void 0===n&&(n=0),void 0===r&&(r={});var e,o,i,u,a,c,f=0,s=!1,l=!1,y=!0;if("function"!=typeof t)throw new TypeError($);function h(n){var r=e,i=o;return e=o=void 0,f=n,u=t.apply(i,r)}function p(t){var r=t-c;return void 0===c||r>=n||r<0||l&&t-f>=i}function d(){var t=Date.now();if(p(t))return v(t);a=setTimeout(d,function(t){var r=n-(t-c);return l?U(r,i-(t-f)):r}(t))}function v(t){return a=void 0,y&&e?h(t):(e=o=void 0,u)}function g(){var t=Date.now(),r=p(t);if(e=arguments,o=this,c=t,r){if(void 0===a)return function(t){return f=t,a=setTimeout(d,n),s?h(t):u}(c);if(l)return a=setTimeout(d,n),h(c)}return void 0===a&&(a=setTimeout(d,n)),u}return n=L.toNumber(n)||0,A.isObject(r)&&(s=!!r.leading,i=(l="maxWait"in r)?W(L.toNumber(r.maxWait)||0,n):i,y="trailing"in r?!!r.trailing:y),g.cancel=function(){void 0!==a&&clearTimeout(a),f=0,e=c=o=a=void 0},g.flush=function(){return void 0===a?u:v(Date.now())},g}var H=function(){function t(t){this.source=t}return t.prototype.run=function(){try{var t=void 0;return t=A.isFunction(this.source)?this.source():this.source,(A.isPromise(t)?t:Promise.resolve(t)).then((function(t){return[null,t]})).catch((function(t){return[t,void 0]}))}catch(t){return Promise.resolve([t,void 0])}},t}(),R={sleep:function(t){return void 0===t&&(t=1e3),new Promise((function(n){setTimeout(n,t)}))},run:function(t){return new H(t).run()},debounce:G,throttle:function(t,n,r){void 0===n&&(n=0),void 0===r&&(r={});var e=!1,o=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return A.isObject(r)&&(e=r.leading?!!r.leading:e,o=r.trailing?!!r.trailing:o),G(t,n,{leading:e,maxWait:n,trailing:o})}};var Y={random:function(t){return Math.floor(Math.random()*t)},randomRange:function(t,n){return Math.floor(Math.random()*(n-t+1)+t)},lerp:function(t,n,r){return t*(1-r)+n*r}},q=function(){return q=Object.assign||function(t){for(var n,r=1,e=arguments.length;r<e;r++)for(var o in n=arguments[r])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},q.apply(this,arguments)};function z(t){return t!=t}function B(t,n){return function(t,n){for(var r=-1,e=t?t.length:0,o=Array(e);++r<e;)o[r]=n(t[r],r,t);return o}(n,(function(n){return t[n]}))}var J,K,Q=(J=Object.keys,K=Object,function(t){return J(K(t))}),V=Math.max;function X(t,n){var r=A.isArray(t)||A.isArguments(t)?function(t,n){for(var r=-1,e=Array(t);++r<t;)e[r]=n(r);return e}(t.length,String):[],e=r.length,o=!!e;for(var i in t)!n&&!p.hasOwnProperty.call(t,i)||o&&("length"==i||A.isIndex(i,e))||r.push(i);return r}var Z=q(q(q({},A),p),{includes:function(t,n,r,e){var o;t=A.isArrayLike(t)?t:(o=t)?B(o,function(t){return A.isArrayLike(t)?X(t):function(t){if(!A.isPrototype(t))return Q(t);var n=[];for(var r in Object(t))p.hasOwnProperty.call(t,r)&&"constructor"!=r&&n.push(r);return n}(t)}(o)):[],r=r&&!e?L.toInteger(r):0;var i=t.length;return r<0&&(r=V(i+r,0)),A.isString(t)?r<=i&&t.indexOf(n,r)>-1:!!i&&function(t,n,r){if(n!=n)return function(t,n,r,e){for(var o=t.length,i=r+(e?1:-1);e?i--:++i<o;)if(n(t[i],i,t))return i;return-1}(t,z,r);for(var e=r-1,o=t.length;++e<o;)if(t[e]===n)return e;return-1}(t,n,r)>-1}}),tt=function(){function t(){this._map=new Map}return t.prototype.clear=function(){return this._map.clear(),this},t.prototype.on=function(t,n){if(!n)return this;var r=this._map.get(t);return r||(r=new Set,this._map.set(t,r)),r.add(n),this},t.prototype.emit=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var e=this._map.get(t);if(!e)return this;var o=function(t,n,r){if(r||2===arguments.length)for(var e,o=0,i=n.length;o<i;o++)!e&&o in n||(e||(e=Array.prototype.slice.call(n,0,o)),e[o]=n[o]);return t.concat(e||Array.prototype.slice.call(n))}([],e,!0);return o.forEach((function(t){return t.apply(void 0,n)})),this},t.prototype.off=function(t,n){if(void 0===t&&(t=""),!t)return this._map.clear(),this;if(!n)return this._map.delete(t.toString()),this;var r=this._map.get(t);return r?(r.delete(n),this):this},t.prototype.once=function(t,n){var r=this,e=function(){for(var o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];n.apply(void 0,o),r.off(t,e)};return this.on(t,e),this},t.prototype.has=function(t){return this._map.has(t)},t}(),nt={gbk:n,time:u,hook:R,math:Y,util:Z,DEvent:tt};t.DEvent=tt,t.default=nt,t.gbk=n,t.hook=R,t.math=Y,t.time=u,t.util=Z,Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
@@ -2,25 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var debounce_1 = require("./debounce");
|
|
4
4
|
var throttle_1 = require("./throttle");
|
|
5
|
-
var is_1 = require("../../util/is");
|
|
6
5
|
var task_1 = require("../../class/task");
|
|
7
6
|
var sleep = function (time) {
|
|
8
7
|
if (time === void 0) { time = 1000; }
|
|
9
8
|
return new Promise(function (resolve) { setTimeout(resolve, time); });
|
|
10
9
|
};
|
|
11
10
|
var run = function (task) { return new task_1.default(task).run(); };
|
|
12
|
-
|
|
13
|
-
if (stepCount === void 0) { stepCount = 100; }
|
|
14
|
-
if (!is_1.default.isFunction(func))
|
|
15
|
-
return;
|
|
16
|
-
if (!is_1.default.isArray(list) || list.length <= 0)
|
|
17
|
-
return;
|
|
18
|
-
var start = 0;
|
|
19
|
-
while (list.length > start) {
|
|
20
|
-
var endIndex = stepCount + start;
|
|
21
|
-
var arr = list.slice(start, endIndex);
|
|
22
|
-
func && func(arr);
|
|
23
|
-
start = endIndex;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
exports.default = { sleep: sleep, run: run, debounce: debounce_1.default, throttle: throttle_1.default, listStep: stepList };
|
|
11
|
+
exports.default = { sleep: sleep, run: run, debounce: debounce_1.default, throttle: throttle_1.default };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var is_1 = require("../util/is");
|
|
4
|
+
var groupBy = function (list, key) {
|
|
5
|
+
return list.reduce(function (pre, current) {
|
|
6
|
+
(pre[current[key]] = pre[current[key]] || []).push(current);
|
|
7
|
+
return pre;
|
|
8
|
+
}, {});
|
|
9
|
+
};
|
|
10
|
+
function listStep(list, func, stepCount) {
|
|
11
|
+
if (stepCount === void 0) { stepCount = 100; }
|
|
12
|
+
if (!is_1.default.isFunction(func))
|
|
13
|
+
return;
|
|
14
|
+
if (!is_1.default.isArray(list) || list.length <= 0)
|
|
15
|
+
return;
|
|
16
|
+
var start = 0;
|
|
17
|
+
while (list.length > start) {
|
|
18
|
+
var endIndex = stepCount + start;
|
|
19
|
+
var arr = list.slice(start, endIndex);
|
|
20
|
+
func && func(arr);
|
|
21
|
+
start = endIndex;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.default = { groupBy: groupBy, listStep: listStep };
|
package/bin/lib/util/is.js
CHANGED
|
@@ -6,6 +6,9 @@ var argsTag = '[object Arguments]', funcTag = '[object Function]', genTag = '[ob
|
|
|
6
6
|
var MAX_SAFE_INTEGER = 9007199254740991, NAN = 0 / 0;
|
|
7
7
|
/** Used to detect unsigned integer values. */
|
|
8
8
|
var reIsUint = /^(?:0|[1-9]\d*)$/;
|
|
9
|
+
function is(val, type) {
|
|
10
|
+
return _object_1.default.getTag(val) === "[object ".concat(type, "]");
|
|
11
|
+
}
|
|
9
12
|
function isNumber(value) {
|
|
10
13
|
return _object_1.default.getTag(value) === "[object Number]";
|
|
11
14
|
}
|
|
@@ -66,6 +69,7 @@ function isArguments(value) {
|
|
|
66
69
|
(!_object_1.default.propertyIsEnumerable.call(value, 'callee') || _object_1.default.toString.call(value) == argsTag);
|
|
67
70
|
}
|
|
68
71
|
exports.default = {
|
|
72
|
+
is: is,
|
|
69
73
|
isNumber: isNumber,
|
|
70
74
|
isString: isString,
|
|
71
75
|
isChinese: isChinese,
|
package/bin/types/index.d.ts
CHANGED
|
@@ -28,7 +28,6 @@ declare const _default: {
|
|
|
28
28
|
run: (task?: Function | Promise<any> | undefined) => Promise<any[]>;
|
|
29
29
|
debounce: typeof import("./modules/hook/debounce").default;
|
|
30
30
|
throttle: typeof import("./modules/hook/throttle").default;
|
|
31
|
-
listStep: <T>(list: T[], func: import("./typings").TArrayFunction<T>, stepCount?: number) => void;
|
|
32
31
|
};
|
|
33
32
|
math: {
|
|
34
33
|
random: (max: number) => number;
|
|
@@ -42,6 +41,7 @@ declare const _default: {
|
|
|
42
41
|
toString: () => string;
|
|
43
42
|
hasOwnProperty: (v: PropertyKey) => boolean;
|
|
44
43
|
propertyIsEnumerable: (v: PropertyKey) => boolean;
|
|
44
|
+
is: (val: any, type: string) => boolean;
|
|
45
45
|
isNumber: (value: any) => boolean;
|
|
46
46
|
isString: (value: any) => boolean;
|
|
47
47
|
isChinese: (content: string) => boolean;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import debounce from "./debounce";
|
|
2
2
|
import throttle from "./throttle";
|
|
3
|
-
import { TArrayFunction } from "../../typings";
|
|
4
|
-
declare function stepList<T>(list: T[], func: TArrayFunction<T>, stepCount?: number): void;
|
|
5
3
|
declare const _default: {
|
|
6
4
|
sleep: (time?: number) => Promise<unknown>;
|
|
7
5
|
run: (task?: Function | Promise<any> | undefined) => Promise<any[]>;
|
|
8
6
|
debounce: typeof debounce;
|
|
9
7
|
throttle: typeof throttle;
|
|
10
|
-
listStep: typeof stepList;
|
|
11
8
|
};
|
|
12
9
|
export default _default;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TArrayFunction } from "../typings";
|
|
2
|
+
declare function listStep<T>(list: T[], func: TArrayFunction<T>, stepCount?: number): void;
|
|
3
|
+
declare const _default: {
|
|
4
|
+
groupBy: (list: any[], key: string) => Record<string, any[]>;
|
|
5
|
+
listStep: typeof listStep;
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|
|
@@ -6,6 +6,7 @@ declare const _default: {
|
|
|
6
6
|
toString: () => string;
|
|
7
7
|
hasOwnProperty: (v: PropertyKey) => boolean;
|
|
8
8
|
propertyIsEnumerable: (v: PropertyKey) => boolean;
|
|
9
|
+
is: (val: any, type: string) => boolean;
|
|
9
10
|
isNumber: (value: any) => boolean;
|
|
10
11
|
isString: (value: any) => boolean;
|
|
11
12
|
isChinese: (content: string) => boolean;
|
package/bin/types/util/is.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
declare function is(val: any, type: string): boolean;
|
|
1
2
|
declare function isNumber(value: any): boolean;
|
|
2
3
|
declare function isString(value: any): boolean;
|
|
3
4
|
declare function isChinese(content: string): boolean;
|
|
@@ -12,6 +13,7 @@ declare function isIndex(value: any, length: number): boolean;
|
|
|
12
13
|
declare function isPrototype(value: any): boolean;
|
|
13
14
|
declare function isArguments(value: any): boolean;
|
|
14
15
|
declare const _default: {
|
|
16
|
+
is: typeof is;
|
|
15
17
|
isNumber: typeof isNumber;
|
|
16
18
|
isString: typeof isString;
|
|
17
19
|
isChinese: typeof isChinese;
|