utils-uniapp 1.2.8 → 1.2.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/lib/magic/index.d.ts +8 -2
- package/lib/magic/index.js +1 -1
- package/package.json +1 -1
package/lib/magic/index.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ export function pipeAsync<T extends [...NextFn[], FirstFn]>(...fns: T): T extend
|
|
|
50
50
|
export function debounce<A extends any[], R>(
|
|
51
51
|
fn: (...argvs: A) => R,
|
|
52
52
|
delay?: number
|
|
53
|
-
): ((...argvs: A) =>
|
|
53
|
+
): ((...argvs: A) => number) & {
|
|
54
54
|
stop(): void;
|
|
55
55
|
};
|
|
56
56
|
|
|
@@ -72,7 +72,13 @@ export function debouncePromise<A extends any[], R>(
|
|
|
72
72
|
* @param { number } wait 节流时间,默认500
|
|
73
73
|
* @param { boolean } immediate 是否立即执行,默认true
|
|
74
74
|
*/
|
|
75
|
-
export function throttle<
|
|
75
|
+
export function throttle<A extends any[], R>(
|
|
76
|
+
func: (...argvs: A) => R,
|
|
77
|
+
wait?: number,
|
|
78
|
+
immediate?: boolean
|
|
79
|
+
): ((...argvs: A) => number) & {
|
|
80
|
+
stop(): void;
|
|
81
|
+
};
|
|
76
82
|
|
|
77
83
|
/**
|
|
78
84
|
* 路径参数编码(JSON序列化后encodeURIComponent)
|
package/lib/magic/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../_rollupPluginBabelHelpers-63255c86.js");function M(){for(var e=arguments.length,
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../_rollupPluginBabelHelpers-63255c86.js");function M(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];if(t.some(function(r){return typeof r!="function"}))throw new TypeError("compose 参数必须是函数");return t.length===0?function(){for(var r=arguments.length,n=new Array(r),a=0;a<r;a++)n[a]=arguments[a];return n.length===1?n[0]:n}:t.reduce(function(r,n){return function(){for(var a=this,i=arguments.length,c=new Array(i),u=0;u<i;u++)c[u]=arguments[u];return n.call.apply(n,[this,function(){for(var s=arguments.length,m=new Array(s),h=0;h<s;h++)m[h]=arguments[h];return r.apply(a,m.concat(c))}].concat(c))}},function(r){return r})}function Q(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];if(t.some(function(r){return typeof r!="function"}))throw new TypeError("composeAsync 参数必须是函数");return t.length===0?l._asyncToGenerator(l._regenerator().m(function r(){var n,a,i,c=arguments;return l._regenerator().w(function(u){for(;;)switch(u.n){case 0:for(n=c.length,a=new Array(n),i=0;i<n;i++)a[i]=c[i];return u.a(2,a.length===1?a[0]:a)}},r)})):t.reduce(function(r,n){return l._asyncToGenerator(l._regenerator().m(function a(){var i=this,c,u,s,m=arguments;return l._regenerator().w(function(h){for(;;)switch(h.n){case 0:for(c=m.length,u=new Array(c),s=0;s<c;s++)u[s]=m[s];return h.a(2,n.call.apply(n,[this,l._asyncToGenerator(l._regenerator().m(function w(){var v,g,f,p=arguments;return l._regenerator().w(function(d){for(;;)switch(d.n){case 0:for(v=p.length,g=new Array(v),f=0;f<v;f++)g[f]=p[f];return d.a(2,r.apply(i,g.concat(u)))}},w)}))].concat(u)))}},a,this)}))},function(){var r=l._asyncToGenerator(l._regenerator().m(function n(a){return l._regenerator().w(function(i){for(;;)switch(i.n){case 0:return i.a(2,a)}},n)}));return function(n){return r.apply(this,arguments)}}())}function j(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];if(t.some(function(r){return typeof r!="function"}))throw new TypeError("pipe 参数必须是函数");return t.length===0?function(){for(var r=arguments.length,n=new Array(r),a=0;a<r;a++)n[a]=arguments[a];return n.length===1?n[0]:n}:t.reverse().reduce(function(r,n){return function(){for(var a=this,i=arguments.length,c=new Array(i),u=0;u<i;u++)c[u]=arguments[u];return n.call.apply(n,[this,function(){for(var s=arguments.length,m=new Array(s),h=0;h<s;h++)m[h]=arguments[h];return r.apply(a,m.concat(c))}].concat(c))}},function(r){return r})}function O(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];if(t.some(function(r){return typeof r!="function"}))throw new TypeError("pipeAsync 参数必须是函数");return t.length===0?l._asyncToGenerator(l._regenerator().m(function r(){var n,a,i,c=arguments;return l._regenerator().w(function(u){for(;;)switch(u.n){case 0:for(n=c.length,a=new Array(n),i=0;i<n;i++)a[i]=c[i];return u.a(2,a.length===1?a[0]:a)}},r)})):t.reverse().reduce(function(r,n){return l._asyncToGenerator(l._regenerator().m(function a(){var i=this,c,u,s,m=arguments;return l._regenerator().w(function(h){for(;;)switch(h.n){case 0:for(c=m.length,u=new Array(c),s=0;s<c;s++)u[s]=m[s];return h.a(2,n.call.apply(n,[this,l._asyncToGenerator(l._regenerator().m(function w(){var v,g,f,p=arguments;return l._regenerator().w(function(d){for(;;)switch(d.n){case 0:for(v=p.length,g=new Array(v),f=0;f<v;f++)g[f]=p[f];return d.a(2,r.apply(i,g.concat(u)))}},w)}))].concat(u)))}},a,this)}))},function(){var r=l._asyncToGenerator(l._regenerator().m(function n(a){return l._regenerator().w(function(i){for(;;)switch(i.n){case 0:return i.a(2,a)}},n)}));return function(n){return r.apply(this,arguments)}}())}function F(e,t){var o=null;r.stop=function(){return o&&clearTimeout(o)};function r(){for(var n=this,a=arguments.length,i=new Array(a),c=0;c<a;c++)i[c]=arguments[c];return r.stop(),o=setTimeout(function(){e.apply(n,i)},t),o}return r}function G(e,t){var o=null,r=[];n.stop=function(){if(o){var a;(a=r.shift())===null||a===void 0||a("cancel"),clearTimeout(o)}};function n(){for(var a=this,i=arguments.length,c=new Array(i),u=0;u<i;u++)c[u]=arguments[u];return new Promise(function(s,m){n.stop(),r.push(m),o=setTimeout(function(){s(e.apply(a,c))},t)})}return n}function _(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:500,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,r,n,a=o?function(){if(!n){n=!0;for(var i=arguments.length,c=new Array(i),u=0;u<i;u++)c[u]=arguments[u];return typeof e=="function"&&e.apply(this,c),r=setTimeout(function(){n=!1},t),r}}:function(){for(var i=this,c=arguments.length,u=new Array(c),s=0;s<c;s++)u[s]=arguments[s];if(!n)return n=!0,r=setTimeout(function(){n=!1,typeof e=="function"&&e.apply(i,u)},t),r};return a.stop=function(){return r&&clearTimeout(r)},a}function $(e){return encodeURIComponent(JSON.stringify(e||{}))}function H(e){return JSON.parse(decodeURIComponent(e||"{}"))}function R(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=t.silent,r=o===void 0?!1:o,n=t.decodePlus,a=n===void 0?!0:n,i=t.strict,c=i===void 0?!1:i,u={};if(typeof e!="string")return u;function s(U,I){var A=U;a&&(A=A.replace(/\+/g," "));try{return decodeURIComponent(A)}catch(E){return r||console.warn("Failed to decode ".concat(I?"key":"value",": ").concat(A),E),c?null:(I&&(A=A.replace(/%[0-9a-f]{2}/gi,"")),A)}}var m=e.split("#")[0],h=m.indexOf("?"),w=h>=0?m.slice(h+1):m;if(!w)return u;for(var v=w.split("&"),g=0;g<v.length;g++){var f=v[g];if(f){var p=f.indexOf("="),d=void 0,P=void 0;p===-1?(d=f,P=""):(d=f.slice(0,p),P=f.slice(p+1));var y=s(d,!0);if(!(y===null||!y)){var S=s(P,!1);if(S!==null){var T=y,b=!1;/\[\]$/.test(y)?(T=y.slice(0,-2),b=!0):/^(.+)\[\d+\]$/.test(y)&&(T=y.replace(/\[\d+\]$/,""),b=!0);var C=u[T];C===void 0?u[T]=b?[S]:S:Array.isArray(C)?C.push(S):u[T]=[C,S]}}}}return u}function L(e){return typeof window=="undefined"?{}:R(window.location.search,e)}function J(e){if(typeof window=="undefined")return{};var t=window.location.hash,o=t.indexOf("?");if(o===-1)return{};var r=t.substring(o);return R(r,e)}function q(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"-";return[Date.now().toString(),Math.random().toString(16).slice(2,10),Math.random().toString(16).slice(7),e.toString()].join(t)}function B(e){return e.replace(/([^-])([^-]*)/g,function(t,o,r){return o.toLocaleUpperCase()+r.toLocaleLowerCase()}).replace(/-/g,"")}function D(e,t){e=e.split("."),t=t.split(".");for(var o=Math.max(e.length,t.length);e.length<o;)e.push("0");for(;t.length<o;)t.push("0");for(var r=0;r<o;r++){var n=parseInt(e[r]),a=parseInt(t[r]);if(n>a)return 1;if(n<a)return-1}return 0}function N(){return"#"+Math.floor(Math.random()*16777215).toString(16).padEnd(6,"0")}function z(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:8,t=arguments.length>1?arguments[1]:void 0;e=e||32,t||(t="ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678");for(var o=t.length,r="",n=0;n<e;n++)r+=t.charAt(Math.floor(Math.random()*o));return r}function V(e){var t,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!e||l._typeof(e)!=="object")return"";var r=o.addQuestionMark,n=r===void 0?!1:r,a=o.arrayFormat,i=a===void 0?"comma":a,c=o.keepEmptyArray,u=c===void 0?!1:c,s=[],m={indices:function(g,f){f.forEach(function(p,d){s.push("".concat(g,"[").concat(d,"]=").concat(encodeURIComponent(p)))})},brackets:function(g,f){f.forEach(function(p){s.push("".concat(g,"[]=").concat(encodeURIComponent(p)))})},repeat:function(g,f){f.forEach(function(p){s.push("".concat(g,"=").concat(encodeURIComponent(p)))})},comma:function(g,f){var p=f.map(function(d){return encodeURIComponent(d)}).join(",");s.push("".concat(g,"=").concat(p))}},h=(t=m[i])!==null&&t!==void 0?t:m.comma;Object.keys(e).forEach(function(v){var g=e[v];if(g!=null){var f=encodeURIComponent(v);if(Array.isArray(g)){var p=g.filter(function(P){return P!=null});if(p.length===0){u&&s.push("".concat(f,"="));return}h(f,p);return}var d=g;l._typeof(d)==="object"&&d!==null&&(d=JSON.stringify(d)),s.push("".concat(f,"=").concat(encodeURIComponent(d)))}});var w=s.join("&");return n&&w?"?".concat(w):w}function W(e){var t=e.scene;return t&&(e=l._objectSpread2(l._objectSpread2({fromCode:!0},e),R(t))),e}exports.compareVersion=D;exports.compose=M;exports.composeAsync=Q;exports.debounce=F;exports.debouncePromise=G;exports.decodeURIParams=H;exports.encodeURIParams=$;exports.getOnLoadParams=W;exports.getPascalCase=B;exports.getQueryParams=R;exports.getQueryParamsFromHash=J;exports.getQueryParamsFromSearch=L;exports.getRandom=q;exports.getRandomStr=z;exports.pipe=j;exports.pipeAsync=O;exports.randomColor=N;exports.throttle=_;exports.toQueryString=V;
|