ddan-js 1.1.5 → 1.1.7
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/list.js +1 -1
- package/bin/types/index.d.ts +1 -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]))};var o={now:function(){return r.Date.now()},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()}};const u=r.Symbol,{toString:s,hasOwnProperty:c,propertyIsEnumerable:a}=Object.prototype,f=u?u.toStringTag:void 0;function l(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":f&&f in Object(t)?function(t){const e=c.call(t,f),n=t[f];let r=!1;try{t[f]=void 0,r=!0}catch(t){}const i=s.call(t);return r&&(e?t[f]=n:delete t[f]),i}(t):s.call(t)}var h={getTag:l,getType:function(t){return(l(t).match(/\w+/g)||["object","Undefined"])[1]||""},toString:s,hasOwnProperty:c,propertyIsEnumerable:a},g="[object Function]",y="[object GeneratorFunction]",m="[object AsyncFunction]",b=9007199254740991;const p=/^(?:0|[1-9]\d*)$/;function d(t){const e=typeof t;return null!=t&&("object"==e||"function"==e)}function v(t){return null!=t&&"object"==typeof t}const j=Array.isArray;function S(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=b}(t.length)&&!w(t)}function O(t){return v(t)&&S(t)}function w(t){var e=d(t)?h.getTag(t):"";return e===g||e===y||e===m}var A={is:function(t,e){return h.getTag(t)===`[object ${e}]`},isNumber:function(t){return"[object Number]"===h.getTag(t)},isString:function(t){return"string"==typeof t||!j(t)&&v(t)&&"[object String]"==h.getTag(t)},isChinese:function(t){return!!t&&!!/^[\u4E00-\u9FA5]+$/.test(t)},isObject:d,isObjectLike:v,isSymbol:function(t){return"symbol"==typeof t||v(t)&&"[object Symbol]"===h.getTag(t)},isFunction:w,isArray:j,isArrayLikeObject:O,isIndex:function(t,e){return!!(e=null==e?b:e)&&("number"==typeof t||p.test(t))&&t>-1&&t%1==0&&t<e},isArrayLike:S,isPrototype:function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Object.prototype)},isArguments:function(t){return O(t)&&h.hasOwnProperty.call(t,"callee")&&(!h.propertyIsEnumerable.call(t,"callee")||"[object Arguments]"==h.toString.call(t))},isPromise:function(t){return"[object Promise]"===(d(t)?h.getTag(t):"")}};const M=NaN,T=/^\s+|\s+$/g,$=/^[-+]0x[0-9a-f]+$/i,D=/^0b[01]+$/i,P=/^0o[0-7]+$/i,k=parseInt,x=1/0,E=17976931348623157e292;function F(t){if("number"==typeof t)return t;if(A.isSymbol(t))return M;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(T,"");const e=D.test(t);return e||P.test(t)?k(t.slice(2),e?2:8):$.test(t)?M:+t}function _(t){return t?(t=F(t))===x||t===-x?(t<0?-1:1)*E:t==t?t:0:0===t?t:0}var I={toNumber:F,toFinite:_,toInteger:function(t){var e=_(t),n=e%1;return e==e?n?e-n:e:0}};const N="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(N);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 m(){var t=Date.now();if(y(t))return b(t);s=setTimeout(m,function(t){var n=e-(t-c);return l?L(n,o-(t-a)):n}(t))}function b(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(m,e),f?g(t):u}(c);if(l)return s=setTimeout(m,e),g(c)}return void 0===s&&(s=setTimeout(m,e)),u}return e=I.toNumber(e)||0,A.isObject(n)&&(f=!!n.leading,o=(l="maxWait"in n)?C(I.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:b(Date.now())},p}class U{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 B={sleep:(t=1e3)=>new Promise((e=>{setTimeout(e,t)})),run:t=>new U(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 G={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 H(t){return t!=t}function R(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,q,z=(Y=Object.keys,q=Object,function(t){return Y(q(t))}),J=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&&!h.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),h),{includes:function(t,e,n,r){var i;t=A.isArrayLike(t)?t:(i=t)?R(i,function(t){return A.isArrayLike(t)?K(t):function(t){if(!A.isPrototype(t))return z(t);var e=[];for(var n in Object(t))h.hasOwnProperty.call(t,n)&&"constructor"!=n&&e.push(n);return e}(t)}(i)):[],n=n&&!r?I.toInteger(n):0;var o=t.length;return n<0&&(n=J(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,H,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
|
|
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]))};var o={now:function(){return r.Date.now()},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()}};const u=r.Symbol,{toString:s,hasOwnProperty:c,propertyIsEnumerable:a}=Object.prototype,f=u?u.toStringTag:void 0;function l(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":f&&f in Object(t)?function(t){const e=c.call(t,f),n=t[f];let r=!1;try{t[f]=void 0,r=!0}catch(t){}const i=s.call(t);return r&&(e?t[f]=n:delete t[f]),i}(t):s.call(t)}var h={getTag:l,getType:function(t){return(l(t).match(/\w+/g)||["object","Undefined"])[1]||""},toString:s,hasOwnProperty:c,propertyIsEnumerable:a},g="[object Function]",y="[object GeneratorFunction]",m="[object AsyncFunction]",b=9007199254740991;const p=/^(?:0|[1-9]\d*)$/;function d(t){const e=typeof t;return null!=t&&("object"==e||"function"==e)}function v(t){return null!=t&&"object"==typeof t}const j=Array.isArray;function S(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=b}(t.length)&&!w(t)}function O(t){return v(t)&&S(t)}function w(t){var e=d(t)?h.getTag(t):"";return e===g||e===y||e===m}var A={is:function(t,e){return h.getTag(t)===`[object ${e}]`},isNumber:function(t){return"[object Number]"===h.getTag(t)},isString:function(t){return"string"==typeof t||!j(t)&&v(t)&&"[object String]"==h.getTag(t)},isChinese:function(t){return!!t&&!!/^[\u4E00-\u9FA5]+$/.test(t)},isObject:d,isObjectLike:v,isSymbol:function(t){return"symbol"==typeof t||v(t)&&"[object Symbol]"===h.getTag(t)},isFunction:w,isArray:j,isArrayLikeObject:O,isIndex:function(t,e){return!!(e=null==e?b:e)&&("number"==typeof t||p.test(t))&&t>-1&&t%1==0&&t<e},isArrayLike:S,isPrototype:function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Object.prototype)},isArguments:function(t){return O(t)&&h.hasOwnProperty.call(t,"callee")&&(!h.propertyIsEnumerable.call(t,"callee")||"[object Arguments]"==h.toString.call(t))},isPromise:function(t){return"[object Promise]"===(d(t)?h.getTag(t):"")}};const M=NaN,T=/^\s+|\s+$/g,$=/^[-+]0x[0-9a-f]+$/i,D=/^0b[01]+$/i,P=/^0o[0-7]+$/i,k=parseInt,x=1/0,E=17976931348623157e292;function F(t){if("number"==typeof t)return t;if(A.isSymbol(t))return M;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(T,"");const e=D.test(t);return e||P.test(t)?k(t.slice(2),e?2:8):$.test(t)?M:+t}function _(t){return t?(t=F(t))===x||t===-x?(t<0?-1:1)*E:t==t?t:0:0===t?t:0}var I={toNumber:F,toFinite:_,toInteger:function(t){var e=_(t),n=e%1;return e==e?n?e-n:e:0}};const N="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(N);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 m(){var t=Date.now();if(y(t))return b(t);s=setTimeout(m,function(t){var n=e-(t-c);return l?L(n,o-(t-a)):n}(t))}function b(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(m,e),f?g(t):u}(c);if(l)return s=setTimeout(m,e),g(c)}return void 0===s&&(s=setTimeout(m,e)),u}return e=I.toNumber(e)||0,A.isObject(n)&&(f=!!n.leading,o=(l="maxWait"in n)?C(I.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:b(Date.now())},p}class U{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 B={sleep:(t=1e3)=>new Promise((e=>{setTimeout(e,t)})),run:t=>new U(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 G={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 H(t){return t!=t}function R(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,q,z=(Y=Object.keys,q=Object,function(t){return Y(q(t))}),J=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&&!h.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),h),{includes:function(t,e,n,r){var i;t=A.isArrayLike(t)?t:(i=t)?R(i,function(t){return A.isArrayLike(t)?K(t):function(t){if(!A.isPrototype(t))return z(t);var e=[];for(var n in Object(t))h.hasOwnProperty.call(t,n)&&"constructor"!=n&&e.push(n);return e}(t)}(i)):[],n=n&&!r?I.toInteger(n):0;var o=t.length;return n<0&&(n=J(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,H,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)]},Z={gbk:t,time:o,hook:B,math:G,util:Q,list:X,DEvent:V};export{V as DEvent,Z as default,t as gbk,B as hook,X as list,G as math,o 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 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)}},n="object"==typeof global&&global&&global.Object===Object&&global,r="object"==typeof self&&self&&self.Object===Object&&self,i=n||r||Function("return this")();const o=(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]))};var u={now:function(){return i.Date.now()},isToday:t=>(new Date).toDateString()===new Date(t).toDateString(),format:o,parseTime:function({year:t=0,month:e=0,date:n=0,hour:r=0,minute:i=0,second:u=0}){const s=`${t||"yyyy"}/${e||"MM"}/${n||"dd"} ${r}:${i}:${u}`;return new Date(o(Date.now(),s)).getTime()}};const s=i.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 j(t){return null!=t&&"object"==typeof t}const S=Array.isArray;function O(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=p}(t.length)&&!A(t)}function w(t){return j(t)&&O(t)}function A(t){var e=v(t)?g.getTag(t):"";return e===y||e===d||e===m}var M={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||!S(t)&&j(t)&&"[object String]"==g.getTag(t)},isChinese:function(t){return!!t&&!!/^[\u4E00-\u9FA5]+$/.test(t)},isObject:v,isObjectLike:j,isSymbol:function(t){return"symbol"==typeof t||j(t)&&"[object Symbol]"===g.getTag(t)},isFunction:A,isArray:S,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,k=/^\s+|\s+$/g,x=/^[-+]0x[0-9a-f]+$/i,D=/^0b[01]+$/i,P=/^0o[0-7]+$/i,$=parseInt,E=1/0,_=17976931348623157e292;function F(t){if("number"==typeof t)return t;if(M.isSymbol(t))return T;if(M.isObject(t)){const e="function"==typeof t.valueOf?t.valueOf():t;t=M.isObject(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(k,"");const e=D.test(t);return e||P.test(t)?$(t.slice(2),e?2:8):x.test(t)?T:+t}function I(t){return t?(t=F(t))===E||t===-E?(t<0?-1:1)*_:t==t?t:0:0===t?t:0}var N={toNumber:F,toFinite:I,toInteger:function(t){var e=I(t),n=e%1;return e==e?n?e-n:e:0}};const C="Expected a function",L=Math.max,W=Math.min;function U(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(C);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?W(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=N.toNumber(e)||0,M.isObject(n)&&(f=!!n.leading,o=(l="maxWait"in n)?L(N.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=M.isFunction(this.source)?this.source():this.source,t=M.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 G={sleep:(t=1e3)=>new Promise((e=>{setTimeout(e,t)})),run:t=>new B(t).run(),debounce:U,throttle:function(t,e=0,n={}){var r=!1,i=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return M.isObject(n)&&(r=n.leading?!!n.leading:r,i=n.trailing?!!n.trailing:i),U(t,e,{leading:r,maxWait:e,trailing:i})}};var H={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 R(t){return t!=t}function Y(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 q,z,J=(q=Object.keys,z=Object,function(t){return q(z(t))}),K=Math.max;function Q(t,e){var n=M.isArray(t)||M.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||M.isIndex(o,r))||n.push(o);return n}var V=Object.assign(Object.assign(Object.assign({},M),g),{includes:function(t,e,n,r){var i;t=M.isArrayLike(t)?t:(i=t)?Y(i,function(t){return M.isArrayLike(t)?Q(t):function(t){if(!M.isPrototype(t))return J(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?N.toInteger(n):0;var o=t.length;return n<0&&(n=K(o+n,0)),M.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,R,n);for(var r=n-1,i=t.length;++r<i;)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 Z={groupBy:(t,e)=>t.reduce(((t,n)=>((t[n[e]]=t[n[e]]||[]).push(n),t)),{}),stepAction:function(t,e,n=100){if(!M.isFunction(e))return;if(!M.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(!M.isArray(t)||t.length<=0)return[];const n=e;return t.slice(n)},take:(t,e,n=0)=>{if(!M.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
|
|
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 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)}},n="object"==typeof global&&global&&global.Object===Object&&global,r="object"==typeof self&&self&&self.Object===Object&&self,i=n||r||Function("return this")();const o=(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]))};var u={now:function(){return i.Date.now()},isToday:t=>(new Date).toDateString()===new Date(t).toDateString(),format:o,parseTime:function({year:t=0,month:e=0,date:n=0,hour:r=0,minute:i=0,second:u=0}){const s=`${t||"yyyy"}/${e||"MM"}/${n||"dd"} ${r}:${i}:${u}`;return new Date(o(Date.now(),s)).getTime()}};const s=i.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 j(t){return null!=t&&"object"==typeof t}const S=Array.isArray;function O(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=p}(t.length)&&!A(t)}function w(t){return j(t)&&O(t)}function A(t){var e=v(t)?g.getTag(t):"";return e===y||e===d||e===m}var M={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||!S(t)&&j(t)&&"[object String]"==g.getTag(t)},isChinese:function(t){return!!t&&!!/^[\u4E00-\u9FA5]+$/.test(t)},isObject:v,isObjectLike:j,isSymbol:function(t){return"symbol"==typeof t||j(t)&&"[object Symbol]"===g.getTag(t)},isFunction:A,isArray:S,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,k=/^\s+|\s+$/g,x=/^[-+]0x[0-9a-f]+$/i,D=/^0b[01]+$/i,P=/^0o[0-7]+$/i,$=parseInt,E=1/0,_=17976931348623157e292;function F(t){if("number"==typeof t)return t;if(M.isSymbol(t))return T;if(M.isObject(t)){const e="function"==typeof t.valueOf?t.valueOf():t;t=M.isObject(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(k,"");const e=D.test(t);return e||P.test(t)?$(t.slice(2),e?2:8):x.test(t)?T:+t}function I(t){return t?(t=F(t))===E||t===-E?(t<0?-1:1)*_:t==t?t:0:0===t?t:0}var N={toNumber:F,toFinite:I,toInteger:function(t){var e=I(t),n=e%1;return e==e?n?e-n:e:0}};const C="Expected a function",L=Math.max,W=Math.min;function U(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(C);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?W(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=N.toNumber(e)||0,M.isObject(n)&&(f=!!n.leading,o=(l="maxWait"in n)?L(N.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=M.isFunction(this.source)?this.source():this.source,t=M.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 G={sleep:(t=1e3)=>new Promise((e=>{setTimeout(e,t)})),run:t=>new B(t).run(),debounce:U,throttle:function(t,e=0,n={}){var r=!1,i=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return M.isObject(n)&&(r=n.leading?!!n.leading:r,i=n.trailing?!!n.trailing:i),U(t,e,{leading:r,maxWait:e,trailing:i})}};var H={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 R(t){return t!=t}function Y(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 q,z,J=(q=Object.keys,z=Object,function(t){return q(z(t))}),K=Math.max;function Q(t,e){var n=M.isArray(t)||M.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||M.isIndex(o,r))||n.push(o);return n}var V=Object.assign(Object.assign(Object.assign({},M),g),{includes:function(t,e,n,r){var i;t=M.isArrayLike(t)?t:(i=t)?Y(i,function(t){return M.isArrayLike(t)?Q(t):function(t){if(!M.isPrototype(t))return J(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?N.toInteger(n):0;var o=t.length;return n<0&&(n=K(o+n,0)),M.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,R,n);for(var r=n-1,i=t.length;++r<i;)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 Z={groupBy:(t,e)=>t.reduce(((t,n)=>((t[n[e]]=t[n[e]]||[]).push(n),t)),{}),stepAction:function(t,e,n=100){if(!M.isFunction(e))return;if(!M.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(!M.isArray(t)||t.length<=0)return[];const n=e;return t.slice(n)},take:(t,e,n=0)=>{if(!M.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=>!M.isArray(t)||t.length<=0?[]:[...new Set(t)]},tt={gbk:e,time:u,hook:G,math:H,util:V,list:Z,DEvent:X};t.DEvent=X,t.default=tt,t.gbk=e,t.hook=G,t.list=Z,t.math=H,t.time=u,t.util=V,Object.defineProperty(t,"__esModule",{value:!0})}));
|
package/bin/lib/modules/list.js
CHANGED
|
@@ -59,7 +59,7 @@ const take = (list, count, skip = 0) => {
|
|
|
59
59
|
if (start >= list.length)
|
|
60
60
|
return [];
|
|
61
61
|
const endIndex = count + start;
|
|
62
|
-
return list.slice(start, list.length
|
|
62
|
+
return list.slice(start, list.length < endIndex ? list.length : endIndex) || [];
|
|
63
63
|
};
|
|
64
64
|
const distinct = (list) => {
|
|
65
65
|
if (!is_1.default.isArray(list) || list.length <= 0)
|
package/bin/types/index.d.ts
CHANGED
|
@@ -63,6 +63,7 @@ declare const _default: {
|
|
|
63
63
|
stepAction: <T>(list: T[], func: import("./typings").TArrayFunction<T>, stepCount?: number) => void;
|
|
64
64
|
skip: (list: any[], count: number) => any[];
|
|
65
65
|
take: (list: any[], count: number, skip?: number) => any[];
|
|
66
|
+
distinct: (list: any[]) => any[];
|
|
66
67
|
};
|
|
67
68
|
DEvent: typeof DEvent;
|
|
68
69
|
};
|