mazey 3.6.3 → 3.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -17
- package/lib/index.cjs.js +292 -157
- package/lib/index.d.ts +73 -26
- package/lib/index.d.ts.map +1 -1
- package/lib/index.esm.js +287 -157
- package/lib/mazey.min.js +2 -2
- package/package.json +1 -1
package/lib/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* mazey v3.6.
|
|
2
|
+
* mazey v3.6.5
|
|
3
3
|
* (c) 2018-2023 Mazey Chu
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -2650,8 +2650,99 @@ _export({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== obje
|
|
|
2650
2650
|
assign: objectAssign
|
|
2651
2651
|
});
|
|
2652
2652
|
|
|
2653
|
+
var path = global_1;
|
|
2654
|
+
|
|
2655
|
+
var getOwnPropertyNames = objectGetOwnPropertyNames.f;
|
|
2656
|
+
var getOwnPropertyDescriptor$2 = objectGetOwnPropertyDescriptor.f;
|
|
2653
2657
|
var defineProperty$1 = objectDefineProperty.f;
|
|
2654
2658
|
|
|
2659
|
+
var trim = stringTrim.trim;
|
|
2660
|
+
|
|
2661
|
+
var NUMBER = 'Number';
|
|
2662
|
+
var NativeNumber = global_1[NUMBER];
|
|
2663
|
+
path[NUMBER];
|
|
2664
|
+
var NumberPrototype = NativeNumber.prototype;
|
|
2665
|
+
var TypeError$2 = global_1.TypeError;
|
|
2666
|
+
var stringSlice = functionUncurryThis(''.slice);
|
|
2667
|
+
var charCodeAt = functionUncurryThis(''.charCodeAt);
|
|
2668
|
+
|
|
2669
|
+
// `ToNumeric` abstract operation
|
|
2670
|
+
// https://tc39.es/ecma262/#sec-tonumeric
|
|
2671
|
+
var toNumeric = function (value) {
|
|
2672
|
+
var primValue = toPrimitive(value, 'number');
|
|
2673
|
+
return typeof primValue == 'bigint' ? primValue : toNumber(primValue);
|
|
2674
|
+
};
|
|
2675
|
+
|
|
2676
|
+
// `ToNumber` abstract operation
|
|
2677
|
+
// https://tc39.es/ecma262/#sec-tonumber
|
|
2678
|
+
var toNumber = function (argument) {
|
|
2679
|
+
var it = toPrimitive(argument, 'number');
|
|
2680
|
+
var first, third, radix, maxCode, digits, length, index, code;
|
|
2681
|
+
if (isSymbol(it)) throw TypeError$2('Cannot convert a Symbol value to a number');
|
|
2682
|
+
if (typeof it == 'string' && it.length > 2) {
|
|
2683
|
+
it = trim(it);
|
|
2684
|
+
first = charCodeAt(it, 0);
|
|
2685
|
+
if (first === 43 || first === 45) {
|
|
2686
|
+
third = charCodeAt(it, 2);
|
|
2687
|
+
if (third === 88 || third === 120) return NaN; // Number('+0x1') should be NaN, old V8 fix
|
|
2688
|
+
} else if (first === 48) {
|
|
2689
|
+
switch (charCodeAt(it, 1)) {
|
|
2690
|
+
case 66: case 98: radix = 2; maxCode = 49; break; // fast equal of /^0b[01]+$/i
|
|
2691
|
+
case 79: case 111: radix = 8; maxCode = 55; break; // fast equal of /^0o[0-7]+$/i
|
|
2692
|
+
default: return +it;
|
|
2693
|
+
}
|
|
2694
|
+
digits = stringSlice(it, 2);
|
|
2695
|
+
length = digits.length;
|
|
2696
|
+
for (index = 0; index < length; index++) {
|
|
2697
|
+
code = charCodeAt(digits, index);
|
|
2698
|
+
// parseInt parses a string to a first unavailable symbol
|
|
2699
|
+
// but ToNumber should return NaN if a string contains unavailable symbols
|
|
2700
|
+
if (code < 48 || code > maxCode) return NaN;
|
|
2701
|
+
} return parseInt(digits, radix);
|
|
2702
|
+
}
|
|
2703
|
+
} return +it;
|
|
2704
|
+
};
|
|
2705
|
+
|
|
2706
|
+
var FORCED$1 = isForced_1(NUMBER, !NativeNumber(' 0o1') || !NativeNumber('0b1') || NativeNumber('+0x1'));
|
|
2707
|
+
|
|
2708
|
+
var calledWithNew = function (dummy) {
|
|
2709
|
+
// includes check on 1..constructor(foo) case
|
|
2710
|
+
return objectIsPrototypeOf(NumberPrototype, dummy) && fails(function () { thisNumberValue(dummy); });
|
|
2711
|
+
};
|
|
2712
|
+
|
|
2713
|
+
// `Number` constructor
|
|
2714
|
+
// https://tc39.es/ecma262/#sec-number-constructor
|
|
2715
|
+
var NumberWrapper = function Number(value) {
|
|
2716
|
+
var n = arguments.length < 1 ? 0 : NativeNumber(toNumeric(value));
|
|
2717
|
+
return calledWithNew(this) ? inheritIfRequired(Object(n), this, NumberWrapper) : n;
|
|
2718
|
+
};
|
|
2719
|
+
|
|
2720
|
+
NumberWrapper.prototype = NumberPrototype;
|
|
2721
|
+
if (FORCED$1 && !isPure) NumberPrototype.constructor = NumberWrapper;
|
|
2722
|
+
|
|
2723
|
+
_export({ global: true, constructor: true, wrap: true, forced: FORCED$1 }, {
|
|
2724
|
+
Number: NumberWrapper
|
|
2725
|
+
});
|
|
2726
|
+
|
|
2727
|
+
// Use `internal/copy-constructor-properties` helper in `core-js@4`
|
|
2728
|
+
var copyConstructorProperties = function (target, source) {
|
|
2729
|
+
for (var keys = descriptors ? getOwnPropertyNames(source) : (
|
|
2730
|
+
// ES3:
|
|
2731
|
+
'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' +
|
|
2732
|
+
// ES2015 (in case, if modules with ES2015 Number statics required before):
|
|
2733
|
+
'EPSILON,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseInt,' +
|
|
2734
|
+
// ESNext
|
|
2735
|
+
'fromString,range'
|
|
2736
|
+
).split(','), j = 0, key; keys.length > j; j++) {
|
|
2737
|
+
if (hasOwnProperty_1(source, key = keys[j]) && !hasOwnProperty_1(target, key)) {
|
|
2738
|
+
defineProperty$1(target, key, getOwnPropertyDescriptor$2(source, key));
|
|
2739
|
+
}
|
|
2740
|
+
}
|
|
2741
|
+
};
|
|
2742
|
+
if (FORCED$1 || isPure) copyConstructorProperties(path[NUMBER], NativeNumber);
|
|
2743
|
+
|
|
2744
|
+
var defineProperty = objectDefineProperty.f;
|
|
2745
|
+
|
|
2655
2746
|
|
|
2656
2747
|
|
|
2657
2748
|
var TO_STRING_TAG = wellKnownSymbol('toStringTag');
|
|
@@ -2659,7 +2750,7 @@ var TO_STRING_TAG = wellKnownSymbol('toStringTag');
|
|
|
2659
2750
|
var setToStringTag = function (target, TAG, STATIC) {
|
|
2660
2751
|
if (target && !STATIC) target = target.prototype;
|
|
2661
2752
|
if (target && !hasOwnProperty_1(target, TO_STRING_TAG)) {
|
|
2662
|
-
defineProperty
|
|
2753
|
+
defineProperty(target, TO_STRING_TAG, { configurable: true, value: TAG });
|
|
2663
2754
|
}
|
|
2664
2755
|
};
|
|
2665
2756
|
|
|
@@ -2823,7 +2914,7 @@ var engineIsIosPebble = /ipad|iphone|ipod/i.test(engineUserAgent) && typeof Pebb
|
|
|
2823
2914
|
|
|
2824
2915
|
var engineIsWebosWebkit = /web0s(?!.*chrome)/i.test(engineUserAgent);
|
|
2825
2916
|
|
|
2826
|
-
var getOwnPropertyDescriptor$
|
|
2917
|
+
var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
|
|
2827
2918
|
var macrotask = task$1.set;
|
|
2828
2919
|
|
|
2829
2920
|
|
|
@@ -2836,7 +2927,7 @@ var document$2 = global_1.document;
|
|
|
2836
2927
|
var process$2 = global_1.process;
|
|
2837
2928
|
var Promise$1 = global_1.Promise;
|
|
2838
2929
|
// Node.js 11 shows ExperimentalWarning on getting `queueMicrotask`
|
|
2839
|
-
var queueMicrotaskDescriptor = getOwnPropertyDescriptor$
|
|
2930
|
+
var queueMicrotaskDescriptor = getOwnPropertyDescriptor$1(global_1, 'queueMicrotask');
|
|
2840
2931
|
var microtask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value;
|
|
2841
2932
|
var notify$1, toggle, node, promise, then;
|
|
2842
2933
|
|
|
@@ -3003,7 +3094,7 @@ var setInternalState = internalState.set;
|
|
|
3003
3094
|
var NativePromisePrototype$1 = promiseNativeConstructor && promiseNativeConstructor.prototype;
|
|
3004
3095
|
var PromiseConstructor = promiseNativeConstructor;
|
|
3005
3096
|
var PromisePrototype = NativePromisePrototype$1;
|
|
3006
|
-
var TypeError$
|
|
3097
|
+
var TypeError$1 = global_1.TypeError;
|
|
3007
3098
|
var document$1 = global_1.document;
|
|
3008
3099
|
var process$1 = global_1.process;
|
|
3009
3100
|
var newPromiseCapability = newPromiseCapability$1.f;
|
|
@@ -3050,7 +3141,7 @@ var callReaction = function (reaction, state) {
|
|
|
3050
3141
|
}
|
|
3051
3142
|
}
|
|
3052
3143
|
if (result === reaction.promise) {
|
|
3053
|
-
reject(TypeError$
|
|
3144
|
+
reject(TypeError$1('Promise-chain cycle'));
|
|
3054
3145
|
} else if (then = isThenable(result)) {
|
|
3055
3146
|
functionCall(then, result, resolve, reject);
|
|
3056
3147
|
} else resolve(result);
|
|
@@ -3140,7 +3231,7 @@ var internalResolve = function (state, value, unwrap) {
|
|
|
3140
3231
|
state.done = true;
|
|
3141
3232
|
if (unwrap) state = unwrap;
|
|
3142
3233
|
try {
|
|
3143
|
-
if (state.facade === value) throw TypeError$
|
|
3234
|
+
if (state.facade === value) throw TypeError$1("Promise can't be resolved itself");
|
|
3144
3235
|
var then = isThenable(value);
|
|
3145
3236
|
if (then) {
|
|
3146
3237
|
microtask_1(function () {
|
|
@@ -3540,11 +3631,11 @@ if (descriptors && !FUNCTION_NAME_EXISTS) {
|
|
|
3540
3631
|
var nativeJoin = functionUncurryThis([].join);
|
|
3541
3632
|
|
|
3542
3633
|
var ES3_STRINGS = indexedObject != Object;
|
|
3543
|
-
var FORCED
|
|
3634
|
+
var FORCED = ES3_STRINGS || !arrayMethodIsStrict('join', ',');
|
|
3544
3635
|
|
|
3545
3636
|
// `Array.prototype.join` method
|
|
3546
3637
|
// https://tc39.es/ecma262/#sec-array.prototype.join
|
|
3547
|
-
_export({ target: 'Array', proto: true, forced: FORCED
|
|
3638
|
+
_export({ target: 'Array', proto: true, forced: FORCED }, {
|
|
3548
3639
|
join: function join(separator) {
|
|
3549
3640
|
return nativeJoin(toIndexedObject(this), separator === undefined ? ',' : separator);
|
|
3550
3641
|
}
|
|
@@ -3797,97 +3888,6 @@ _export({ target: 'String', proto: true, forced: !correctIsRegexpLogic('includes
|
|
|
3797
3888
|
}
|
|
3798
3889
|
});
|
|
3799
3890
|
|
|
3800
|
-
var path = global_1;
|
|
3801
|
-
|
|
3802
|
-
var getOwnPropertyNames = objectGetOwnPropertyNames.f;
|
|
3803
|
-
var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
|
|
3804
|
-
var defineProperty = objectDefineProperty.f;
|
|
3805
|
-
|
|
3806
|
-
var trim = stringTrim.trim;
|
|
3807
|
-
|
|
3808
|
-
var NUMBER = 'Number';
|
|
3809
|
-
var NativeNumber = global_1[NUMBER];
|
|
3810
|
-
path[NUMBER];
|
|
3811
|
-
var NumberPrototype = NativeNumber.prototype;
|
|
3812
|
-
var TypeError$1 = global_1.TypeError;
|
|
3813
|
-
var stringSlice = functionUncurryThis(''.slice);
|
|
3814
|
-
var charCodeAt = functionUncurryThis(''.charCodeAt);
|
|
3815
|
-
|
|
3816
|
-
// `ToNumeric` abstract operation
|
|
3817
|
-
// https://tc39.es/ecma262/#sec-tonumeric
|
|
3818
|
-
var toNumeric = function (value) {
|
|
3819
|
-
var primValue = toPrimitive(value, 'number');
|
|
3820
|
-
return typeof primValue == 'bigint' ? primValue : toNumber(primValue);
|
|
3821
|
-
};
|
|
3822
|
-
|
|
3823
|
-
// `ToNumber` abstract operation
|
|
3824
|
-
// https://tc39.es/ecma262/#sec-tonumber
|
|
3825
|
-
var toNumber = function (argument) {
|
|
3826
|
-
var it = toPrimitive(argument, 'number');
|
|
3827
|
-
var first, third, radix, maxCode, digits, length, index, code;
|
|
3828
|
-
if (isSymbol(it)) throw TypeError$1('Cannot convert a Symbol value to a number');
|
|
3829
|
-
if (typeof it == 'string' && it.length > 2) {
|
|
3830
|
-
it = trim(it);
|
|
3831
|
-
first = charCodeAt(it, 0);
|
|
3832
|
-
if (first === 43 || first === 45) {
|
|
3833
|
-
third = charCodeAt(it, 2);
|
|
3834
|
-
if (third === 88 || third === 120) return NaN; // Number('+0x1') should be NaN, old V8 fix
|
|
3835
|
-
} else if (first === 48) {
|
|
3836
|
-
switch (charCodeAt(it, 1)) {
|
|
3837
|
-
case 66: case 98: radix = 2; maxCode = 49; break; // fast equal of /^0b[01]+$/i
|
|
3838
|
-
case 79: case 111: radix = 8; maxCode = 55; break; // fast equal of /^0o[0-7]+$/i
|
|
3839
|
-
default: return +it;
|
|
3840
|
-
}
|
|
3841
|
-
digits = stringSlice(it, 2);
|
|
3842
|
-
length = digits.length;
|
|
3843
|
-
for (index = 0; index < length; index++) {
|
|
3844
|
-
code = charCodeAt(digits, index);
|
|
3845
|
-
// parseInt parses a string to a first unavailable symbol
|
|
3846
|
-
// but ToNumber should return NaN if a string contains unavailable symbols
|
|
3847
|
-
if (code < 48 || code > maxCode) return NaN;
|
|
3848
|
-
} return parseInt(digits, radix);
|
|
3849
|
-
}
|
|
3850
|
-
} return +it;
|
|
3851
|
-
};
|
|
3852
|
-
|
|
3853
|
-
var FORCED = isForced_1(NUMBER, !NativeNumber(' 0o1') || !NativeNumber('0b1') || NativeNumber('+0x1'));
|
|
3854
|
-
|
|
3855
|
-
var calledWithNew = function (dummy) {
|
|
3856
|
-
// includes check on 1..constructor(foo) case
|
|
3857
|
-
return objectIsPrototypeOf(NumberPrototype, dummy) && fails(function () { thisNumberValue(dummy); });
|
|
3858
|
-
};
|
|
3859
|
-
|
|
3860
|
-
// `Number` constructor
|
|
3861
|
-
// https://tc39.es/ecma262/#sec-number-constructor
|
|
3862
|
-
var NumberWrapper = function Number(value) {
|
|
3863
|
-
var n = arguments.length < 1 ? 0 : NativeNumber(toNumeric(value));
|
|
3864
|
-
return calledWithNew(this) ? inheritIfRequired(Object(n), this, NumberWrapper) : n;
|
|
3865
|
-
};
|
|
3866
|
-
|
|
3867
|
-
NumberWrapper.prototype = NumberPrototype;
|
|
3868
|
-
if (FORCED && !isPure) NumberPrototype.constructor = NumberWrapper;
|
|
3869
|
-
|
|
3870
|
-
_export({ global: true, constructor: true, wrap: true, forced: FORCED }, {
|
|
3871
|
-
Number: NumberWrapper
|
|
3872
|
-
});
|
|
3873
|
-
|
|
3874
|
-
// Use `internal/copy-constructor-properties` helper in `core-js@4`
|
|
3875
|
-
var copyConstructorProperties = function (target, source) {
|
|
3876
|
-
for (var keys = descriptors ? getOwnPropertyNames(source) : (
|
|
3877
|
-
// ES3:
|
|
3878
|
-
'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' +
|
|
3879
|
-
// ES2015 (in case, if modules with ES2015 Number statics required before):
|
|
3880
|
-
'EPSILON,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseInt,' +
|
|
3881
|
-
// ESNext
|
|
3882
|
-
'fromString,range'
|
|
3883
|
-
).split(','), j = 0, key; keys.length > j; j++) {
|
|
3884
|
-
if (hasOwnProperty_1(source, key = keys[j]) && !hasOwnProperty_1(target, key)) {
|
|
3885
|
-
defineProperty(target, key, getOwnPropertyDescriptor$1(source, key));
|
|
3886
|
-
}
|
|
3887
|
-
}
|
|
3888
|
-
};
|
|
3889
|
-
if (FORCED || isPure) copyConstructorProperties(path[NUMBER], NativeNumber);
|
|
3890
|
-
|
|
3891
3891
|
var $TypeError$1 = TypeError;
|
|
3892
3892
|
// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
|
|
3893
3893
|
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
@@ -3988,6 +3988,17 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
3988
3988
|
PERFORMANCE OF THIS SOFTWARE.
|
|
3989
3989
|
***************************************************************************** */
|
|
3990
3990
|
|
|
3991
|
+
var __assign = function() {
|
|
3992
|
+
__assign = Object.assign || function __assign(t) {
|
|
3993
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
3994
|
+
s = arguments[i];
|
|
3995
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
3996
|
+
}
|
|
3997
|
+
return t;
|
|
3998
|
+
};
|
|
3999
|
+
return __assign.apply(this, arguments);
|
|
4000
|
+
};
|
|
4001
|
+
|
|
3991
4002
|
function __spreadArray(to, from) {
|
|
3992
4003
|
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
3993
4004
|
to[j] = from[i];
|
|
@@ -4219,6 +4230,10 @@ function getHashQueryParam(param) {
|
|
|
4219
4230
|
* ```
|
|
4220
4231
|
* getDomain('http://example.com/?t1=1&t2=2&t3=3&t4=4');
|
|
4221
4232
|
* getDomain('http://example.com/test/thanks?t1=1&t2=2&t3=3&t4=4', ['hostname', 'pathname']);
|
|
4233
|
+
* getDomain('http://example.com:7890/test/thanks', ['hostname']);
|
|
4234
|
+
* getDomain('http://example.com:7890/test/thanks', ['host']); // With Port
|
|
4235
|
+
* getDomain('http://example.com:7890/test/thanks', ['origin']);
|
|
4236
|
+
* getDomain('http://example.com:7890/test/thanks?id=1', ['origin', 'pathname', 'search']);
|
|
4222
4237
|
* ```
|
|
4223
4238
|
*
|
|
4224
4239
|
* Output:
|
|
@@ -4226,10 +4241,14 @@ function getHashQueryParam(param) {
|
|
|
4226
4241
|
* ```
|
|
4227
4242
|
* example.com
|
|
4228
4243
|
* example.com/test/thanks
|
|
4244
|
+
* example.com
|
|
4245
|
+
* example.com:7890
|
|
4246
|
+
* http://example.com:7890
|
|
4247
|
+
* http://example.com:7890/test/thanks?id=1
|
|
4229
4248
|
* ```
|
|
4230
4249
|
*
|
|
4231
4250
|
* @param {string} url
|
|
4232
|
-
* @param {array} rules Object.keys(location), ['href', 'protocol', 'host', 'hostname', 'port', 'pathname', 'search', 'hash'], ['hostname', 'pathname'] = 'km.mazey.net/plugins/servlet/mobile'
|
|
4251
|
+
* @param {array} rules Object.keys(location), ['href', 'origin', 'protocol', 'host', 'hostname', 'port', 'pathname', 'search', 'hash'], ['hostname', 'pathname'] = 'km.mazey.net/plugins/servlet/mobile'
|
|
4233
4252
|
* @category URL
|
|
4234
4253
|
*/
|
|
4235
4254
|
function getDomain(url, rules) {
|
|
@@ -4247,34 +4266,50 @@ function getDomain(url, rules) {
|
|
|
4247
4266
|
* Transfer CamelCase to KebabCase.
|
|
4248
4267
|
*
|
|
4249
4268
|
* ```
|
|
4250
|
-
*
|
|
4251
|
-
*
|
|
4269
|
+
* convertCamelToKebab('ABC'); // a-b-c
|
|
4270
|
+
* convertCamelToKebab('aBC'); // a-b-c
|
|
4252
4271
|
* ```
|
|
4253
4272
|
*
|
|
4254
4273
|
* @param {string} camelCase 'aBC' or 'ABC'
|
|
4255
4274
|
* @returns {string} 'a-b-c'
|
|
4256
4275
|
* @category Util
|
|
4257
4276
|
*/
|
|
4258
|
-
function
|
|
4277
|
+
function convertCamelToKebab(camelCase) {
|
|
4259
4278
|
var kebabCase = camelCase.replace(/([A-Z])/g, '-$1').toLowerCase();
|
|
4260
4279
|
return kebabCase[0] === '-' ? kebabCase.substr(1) : kebabCase;
|
|
4261
4280
|
}
|
|
4281
|
+
/**
|
|
4282
|
+
* Alias of convertCamelToKebab
|
|
4283
|
+
*
|
|
4284
|
+
* @hidden
|
|
4285
|
+
*/
|
|
4286
|
+
function camelCaseToKebabCase(camelCase) {
|
|
4287
|
+
return convertCamelToKebab(camelCase);
|
|
4288
|
+
}
|
|
4262
4289
|
/**
|
|
4263
4290
|
* Transfer CamelCase to Underscore.
|
|
4264
4291
|
*
|
|
4265
4292
|
* ```
|
|
4266
|
-
*
|
|
4267
|
-
*
|
|
4293
|
+
* convertCamelToUnder('ABC'); // a_b_c
|
|
4294
|
+
* convertCamelToUnder('aBC'); // a_b_c
|
|
4268
4295
|
* ```
|
|
4269
4296
|
*
|
|
4270
4297
|
* @param {string} camelCase 'aBC' or 'ABC'
|
|
4271
4298
|
* @returns {string} 'a_b_c'
|
|
4272
4299
|
* @category Util
|
|
4273
4300
|
*/
|
|
4274
|
-
function
|
|
4301
|
+
function convertCamelToUnder(camelCase) {
|
|
4275
4302
|
var kebabCase = camelCase.replace(/([A-Z])/g, '_$1').toLowerCase();
|
|
4276
4303
|
return kebabCase[0] === '_' ? kebabCase.substr(1) : kebabCase;
|
|
4277
4304
|
}
|
|
4305
|
+
/**
|
|
4306
|
+
* Alias of convertCamelToUnder
|
|
4307
|
+
*
|
|
4308
|
+
* @hidden
|
|
4309
|
+
*/
|
|
4310
|
+
function camelCase2Underscore(camelCase) {
|
|
4311
|
+
return convertCamelToUnder(camelCase);
|
|
4312
|
+
}
|
|
4278
4313
|
/**
|
|
4279
4314
|
* Remove leading and trailing whitespace or specified characters from string.
|
|
4280
4315
|
*
|
|
@@ -4346,8 +4381,8 @@ function deepCopyObject(obj) {
|
|
|
4346
4381
|
* Usage:
|
|
4347
4382
|
*
|
|
4348
4383
|
* ```
|
|
4349
|
-
*
|
|
4350
|
-
*
|
|
4384
|
+
* isJSONString(`['a', 'b', 'c']`);
|
|
4385
|
+
* isJSONString(`["a", "b", "c"]`);
|
|
4351
4386
|
* ```
|
|
4352
4387
|
*
|
|
4353
4388
|
* Output:
|
|
@@ -4361,7 +4396,7 @@ function deepCopyObject(obj) {
|
|
|
4361
4396
|
* @returns {boolean} Return the result of checking.
|
|
4362
4397
|
* @category Util
|
|
4363
4398
|
*/
|
|
4364
|
-
function
|
|
4399
|
+
function isJSONString(str) {
|
|
4365
4400
|
try {
|
|
4366
4401
|
if (_typeof(JSON.parse(str)) === 'object') {
|
|
4367
4402
|
return true;
|
|
@@ -4371,6 +4406,14 @@ function isJsonString(str) {
|
|
|
4371
4406
|
}
|
|
4372
4407
|
return false;
|
|
4373
4408
|
}
|
|
4409
|
+
/**
|
|
4410
|
+
* Alias of isJSONString
|
|
4411
|
+
*
|
|
4412
|
+
* @hidden
|
|
4413
|
+
*/
|
|
4414
|
+
function isJsonString(str) {
|
|
4415
|
+
return isJSONString(str);
|
|
4416
|
+
}
|
|
4374
4417
|
/**
|
|
4375
4418
|
* Produce a random string of number, `generateRndNum(7)` => '7658495'.
|
|
4376
4419
|
*
|
|
@@ -4648,16 +4691,26 @@ function debounce(func, wait, immediate) {
|
|
|
4648
4691
|
return result;
|
|
4649
4692
|
};
|
|
4650
4693
|
}
|
|
4694
|
+
var defaultGetFriendlyIntervalOptions = {
|
|
4695
|
+
type: 'd'
|
|
4696
|
+
};
|
|
4651
4697
|
/**
|
|
4652
|
-
*
|
|
4653
|
-
*
|
|
4698
|
+
* 获取间隔时间
|
|
4699
|
+
*
|
|
4700
|
+
* @example
|
|
4701
|
+
* ```js
|
|
4702
|
+
* console.log('getFriendlyInterval:', getFriendlyInterval(new Date('2020-03-28 00:09:27'), new Date('2023-04-18 10:54:00'), { type: 'd' })); // 1116
|
|
4703
|
+
* console.log('getFriendlyInterval:', getFriendlyInterval(1585325367000, 1681786440000, { type: 'text' })); // 1116 天 10 时 44 分 33 秒
|
|
4704
|
+
* console.log('getFriendlyInterval:', getFriendlyInterval('2020-03-28 00:09:27', '2023-04-18 10:54:00', { type: 'text' })); // 1116 天 10 时 44 分 33 秒
|
|
4705
|
+
* ```
|
|
4706
|
+
*
|
|
4654
4707
|
* @param {number/Date} start 开始时间戳 1585325367122
|
|
4655
4708
|
* @param {number/Date} end 结束时间戳 1585325367122
|
|
4656
4709
|
* @param {string} options.type 返回类型 d: 2(天) text: 2 天 4 时...
|
|
4657
4710
|
* @returns {string/number} 取决于 type
|
|
4658
4711
|
* @category Util
|
|
4659
4712
|
*/
|
|
4660
|
-
function
|
|
4713
|
+
function getFriendlyInterval(start, end, options) {
|
|
4661
4714
|
if (start === void 0) {
|
|
4662
4715
|
start = 0;
|
|
4663
4716
|
}
|
|
@@ -4665,14 +4718,13 @@ function friendlyInterval(start, end, options) {
|
|
|
4665
4718
|
end = 0;
|
|
4666
4719
|
}
|
|
4667
4720
|
if (options === void 0) {
|
|
4668
|
-
options =
|
|
4669
|
-
type: 'd'
|
|
4670
|
-
};
|
|
4721
|
+
options = defaultGetFriendlyIntervalOptions;
|
|
4671
4722
|
}
|
|
4723
|
+
options = Object.assign(defaultGetFriendlyIntervalOptions, options);
|
|
4672
4724
|
var type = options.type;
|
|
4673
4725
|
if (!isNumber(start)) start = new Date(start).getTime();
|
|
4674
4726
|
if (!isNumber(end)) end = new Date(end).getTime();
|
|
4675
|
-
var t = end - start;
|
|
4727
|
+
var t = Number(end) - Number(start);
|
|
4676
4728
|
var ret = '';
|
|
4677
4729
|
var _a = new Array(4).fill(0),
|
|
4678
4730
|
d = _a[0],
|
|
@@ -5253,7 +5305,7 @@ function getCookie(name) {
|
|
|
5253
5305
|
* Results:
|
|
5254
5306
|
*
|
|
5255
5307
|
* | Attribute | Description | Type | Values |
|
|
5256
|
-
* |
|
|
5308
|
+
* | :------------ | :------------ | :------------ | :------------ |
|
|
5257
5309
|
* | dns_time | DNS Lookup | number | domainLookupEnd - domainLookupStart |
|
|
5258
5310
|
* | tcp_time | Connection Negotiation | number | connectEnd - connectStart |
|
|
5259
5311
|
* | response_time | Requests and Responses | number | responseStart - requestStart |
|
|
@@ -5586,7 +5638,7 @@ function isSafePWAEnv() {
|
|
|
5586
5638
|
* Results:
|
|
5587
5639
|
*
|
|
5588
5640
|
* | Attribute | Description | Type | Values |
|
|
5589
|
-
* |
|
|
5641
|
+
* | :------------ | :------------ | :------------ | :------------ |
|
|
5590
5642
|
* | **system** | System | string | android, ios, windows, macos, linux |
|
|
5591
5643
|
* | systemVs | System version | string | windows: 2000, xp, 2003, vista, 7, 8, 8.1, 10 <br />macos: ... |
|
|
5592
5644
|
* | platform | Platform | string | desktop, mobile |
|
|
@@ -5609,23 +5661,44 @@ function isSafePWAEnv() {
|
|
|
5609
5661
|
* @category Browser Information
|
|
5610
5662
|
*/
|
|
5611
5663
|
function getBrowserInfo() {
|
|
5664
|
+
// Cache
|
|
5665
|
+
if (window.MAZEY_BROWSER_INFO && _typeof(window.MAZEY_BROWSER_INFO) === 'object') {
|
|
5666
|
+
// console.log('getBrowserInfo cache');
|
|
5667
|
+
return window.MAZEY_BROWSER_INFO;
|
|
5668
|
+
}
|
|
5669
|
+
var browserInfo = {
|
|
5670
|
+
engine: '',
|
|
5671
|
+
engineVs: '',
|
|
5672
|
+
platform: '',
|
|
5673
|
+
supporter: '',
|
|
5674
|
+
supporterVs: '',
|
|
5675
|
+
system: '',
|
|
5676
|
+
systemVs: ''
|
|
5677
|
+
};
|
|
5612
5678
|
try {
|
|
5613
5679
|
// 权重:系统 + 系统版本 > 平台 > 内核 + 载体 + 内核版本 + 载体版本 > 外壳 + 外壳版本
|
|
5614
5680
|
var ua_1 = navigator.userAgent.toLowerCase();
|
|
5681
|
+
if (!ua_1) {
|
|
5682
|
+
return browserInfo;
|
|
5683
|
+
}
|
|
5615
5684
|
var testUa = function testUa(regexp) {
|
|
5616
5685
|
return regexp.test(ua_1);
|
|
5617
5686
|
};
|
|
5618
5687
|
var testVs = function testVs(regexp) {
|
|
5619
|
-
var matchRes = ua_1.match(regexp);
|
|
5620
5688
|
var ret = '';
|
|
5621
|
-
|
|
5622
|
-
|
|
5689
|
+
var matchRes = ua_1.match(regexp); // ['os 13_2_3']
|
|
5690
|
+
// Confirm the Safety of the match result
|
|
5691
|
+
if (matchRes && isNonEmptyArray(matchRes)) {
|
|
5692
|
+
ret = matchRes.toString();
|
|
5693
|
+
ret = ret.replace(/[^0-9|_.]/g, ''); // 1323
|
|
5694
|
+
ret = ret.replace(/_/g, '.'); // 13.2.3
|
|
5623
5695
|
}
|
|
5696
|
+
|
|
5624
5697
|
return ret;
|
|
5625
5698
|
};
|
|
5626
|
-
//
|
|
5699
|
+
// System
|
|
5627
5700
|
var system = '';
|
|
5628
|
-
// Apple
|
|
5701
|
+
// Apple Device Type
|
|
5629
5702
|
var appleType = '';
|
|
5630
5703
|
if (testUa(/windows|win32|win64|wow32|wow64/g)) {
|
|
5631
5704
|
system = 'windows'; // windows系统
|
|
@@ -5647,7 +5720,11 @@ function getBrowserInfo() {
|
|
|
5647
5720
|
appleType = 'ipod';
|
|
5648
5721
|
}
|
|
5649
5722
|
}
|
|
5650
|
-
|
|
5723
|
+
browserInfo = __assign(__assign({}, browserInfo), {
|
|
5724
|
+
system: system,
|
|
5725
|
+
appleType: appleType
|
|
5726
|
+
});
|
|
5727
|
+
// System Version
|
|
5651
5728
|
var systemVs = '';
|
|
5652
5729
|
if (system === 'windows') {
|
|
5653
5730
|
if (testUa(/windows nt 5.0|windows 2000/g)) {
|
|
@@ -5670,18 +5747,26 @@ function getBrowserInfo() {
|
|
|
5670
5747
|
} else if (system === 'macos') {
|
|
5671
5748
|
systemVs = testVs(/os x [\d._]+/g);
|
|
5672
5749
|
} else if (system === 'android') {
|
|
5673
|
-
systemVs = testVs(/android [\d._]+/g);
|
|
5750
|
+
systemVs = testVs(/android [\d._]+/g); // 8.0
|
|
5674
5751
|
} else if (system === 'ios') {
|
|
5675
|
-
systemVs = testVs(/os [\d._]+/g);
|
|
5752
|
+
systemVs = testVs(/os [\d._]+/g); // 13.2.3 13.3
|
|
5676
5753
|
}
|
|
5677
|
-
|
|
5754
|
+
|
|
5755
|
+
browserInfo = __assign(__assign({}, browserInfo), {
|
|
5756
|
+
systemVs: systemVs
|
|
5757
|
+
});
|
|
5758
|
+
// Platform
|
|
5678
5759
|
var platform = '';
|
|
5679
5760
|
if (system === 'windows' || system === 'macos' || system === 'linux') {
|
|
5680
5761
|
platform = 'desktop'; // 桌面端
|
|
5681
5762
|
} else if (system === 'android' || system === 'ios' || testUa(/mobile/g)) {
|
|
5682
5763
|
platform = 'mobile'; // 移动端
|
|
5683
5764
|
}
|
|
5684
|
-
|
|
5765
|
+
|
|
5766
|
+
browserInfo = __assign(__assign({}, browserInfo), {
|
|
5767
|
+
platform: platform
|
|
5768
|
+
});
|
|
5769
|
+
// Engine and Shell
|
|
5685
5770
|
var engine = '';
|
|
5686
5771
|
var supporter = '';
|
|
5687
5772
|
if (testUa(/applewebkit/g)) {
|
|
@@ -5705,7 +5790,12 @@ function getBrowserInfo() {
|
|
|
5705
5790
|
engine = 'trident'; // trident内核
|
|
5706
5791
|
supporter = 'iexplore'; // iexplore浏览器
|
|
5707
5792
|
}
|
|
5708
|
-
|
|
5793
|
+
|
|
5794
|
+
browserInfo = __assign(__assign({}, browserInfo), {
|
|
5795
|
+
engine: engine,
|
|
5796
|
+
supporter: supporter
|
|
5797
|
+
});
|
|
5798
|
+
// Engine Version
|
|
5709
5799
|
var engineVs = '';
|
|
5710
5800
|
if (engine === 'webkit') {
|
|
5711
5801
|
engineVs = testVs(/applewebkit\/[\d._]+/g);
|
|
@@ -5716,7 +5806,10 @@ function getBrowserInfo() {
|
|
|
5716
5806
|
} else if (engine === 'trident') {
|
|
5717
5807
|
engineVs = testVs(/trident\/[\d._]+/g);
|
|
5718
5808
|
}
|
|
5719
|
-
|
|
5809
|
+
browserInfo = __assign(__assign({}, browserInfo), {
|
|
5810
|
+
engineVs: engineVs
|
|
5811
|
+
});
|
|
5812
|
+
// Supporter Version
|
|
5720
5813
|
var supporterVs = '';
|
|
5721
5814
|
if (supporter === 'chrome') {
|
|
5722
5815
|
supporterVs = testVs(/chrome\/[\d._]+/g);
|
|
@@ -5731,7 +5824,10 @@ function getBrowserInfo() {
|
|
|
5731
5824
|
} else if (supporter === 'edge') {
|
|
5732
5825
|
supporterVs = testVs(/edge\/[\d._]+/g);
|
|
5733
5826
|
}
|
|
5734
|
-
|
|
5827
|
+
browserInfo = __assign(__assign({}, browserInfo), {
|
|
5828
|
+
supporterVs: supporterVs
|
|
5829
|
+
});
|
|
5830
|
+
// Shell Name and Shell Version
|
|
5735
5831
|
var shell = '';
|
|
5736
5832
|
var shellVs = '';
|
|
5737
5833
|
if (testUa(/micromessenger/g)) {
|
|
@@ -5761,30 +5857,15 @@ function getBrowserInfo() {
|
|
|
5761
5857
|
shell = 'bilibili'; // 哔哩哔哩
|
|
5762
5858
|
}
|
|
5763
5859
|
|
|
5764
|
-
|
|
5765
|
-
engine: engine,
|
|
5766
|
-
engineVs: engineVs,
|
|
5767
|
-
platform: platform,
|
|
5768
|
-
supporter: supporter,
|
|
5769
|
-
supporterVs: supporterVs,
|
|
5770
|
-
system: system,
|
|
5771
|
-
systemVs: systemVs
|
|
5772
|
-
}, {
|
|
5860
|
+
browserInfo = __assign(__assign({}, browserInfo), {
|
|
5773
5861
|
shell: shell,
|
|
5774
|
-
shellVs: shellVs
|
|
5775
|
-
appleType: appleType
|
|
5862
|
+
shellVs: shellVs
|
|
5776
5863
|
});
|
|
5864
|
+
window.MAZEY_BROWSER_INFO = browserInfo;
|
|
5865
|
+
return browserInfo;
|
|
5777
5866
|
} catch (err) {
|
|
5778
|
-
console.warn('
|
|
5779
|
-
return
|
|
5780
|
-
engine: '',
|
|
5781
|
-
engineVs: '',
|
|
5782
|
-
platform: '',
|
|
5783
|
-
supporter: '',
|
|
5784
|
-
supporterVs: '',
|
|
5785
|
-
system: '',
|
|
5786
|
-
systemVs: ''
|
|
5787
|
-
};
|
|
5867
|
+
console.warn('MazeyCon:', err);
|
|
5868
|
+
return browserInfo;
|
|
5788
5869
|
}
|
|
5789
5870
|
}
|
|
5790
5871
|
/**
|
|
@@ -5798,15 +5879,15 @@ function clearHtml(str) {
|
|
|
5798
5879
|
return str.replace(/<\/?.+?>/g, '').replace(/[\r\n]/g, '');
|
|
5799
5880
|
}
|
|
5800
5881
|
/**
|
|
5801
|
-
*
|
|
5802
|
-
*
|
|
5882
|
+
* 截取字符串,中文算 2 个字节
|
|
5883
|
+
*
|
|
5803
5884
|
* @param {string} str 要截取的字符串
|
|
5804
5885
|
* @param {number} len
|
|
5805
5886
|
* @param {boolean} hasDot
|
|
5806
5887
|
* @returns {string} 返回截取后的字符串
|
|
5807
5888
|
* @category Util
|
|
5808
5889
|
*/
|
|
5809
|
-
function
|
|
5890
|
+
function truncateZHString(str, len, hasDot) {
|
|
5810
5891
|
if (hasDot === void 0) {
|
|
5811
5892
|
hasDot = false;
|
|
5812
5893
|
}
|
|
@@ -5837,6 +5918,17 @@ function cutCHSString(str, len, hasDot) {
|
|
|
5837
5918
|
return newStr;
|
|
5838
5919
|
}
|
|
5839
5920
|
}
|
|
5921
|
+
/**
|
|
5922
|
+
* Alias of truncateZHString
|
|
5923
|
+
*
|
|
5924
|
+
* @hidden
|
|
5925
|
+
*/
|
|
5926
|
+
function cutCHSString(str, len, hasDot) {
|
|
5927
|
+
if (hasDot === void 0) {
|
|
5928
|
+
hasDot = false;
|
|
5929
|
+
}
|
|
5930
|
+
return truncateZHString(str, len, hasDot);
|
|
5931
|
+
}
|
|
5840
5932
|
/**
|
|
5841
5933
|
* EN: Check whether the page is loaded successfully (Keepe the compatibility in case that browser's `load` event has been triggered).
|
|
5842
5934
|
*
|
|
@@ -6474,5 +6566,43 @@ function convert10To26(num) {
|
|
|
6474
6566
|
}
|
|
6475
6567
|
return result;
|
|
6476
6568
|
}
|
|
6569
|
+
/**
|
|
6570
|
+
* EN: Get the file type of the url.
|
|
6571
|
+
*
|
|
6572
|
+
* ZH: 获取文件后缀名
|
|
6573
|
+
*
|
|
6574
|
+
* @example
|
|
6575
|
+
* ```js
|
|
6576
|
+
* console.log(getUrlFileType('https://example.com/a/b/c.png')); // png
|
|
6577
|
+
* console.log(getUrlFileType('https://example.com/a/b/c.jpg')); // jpg
|
|
6578
|
+
* console.log(getUrlFileType('https://example.com/a/b/c.jpeg')); // jpeg
|
|
6579
|
+
* console.log(getUrlFileType('/a/b/c.jpeg')); // jpeg
|
|
6580
|
+
* console.log(getUrlFileType('https://example.com/a/b/c.v/a')); // ''
|
|
6581
|
+
* ```
|
|
6582
|
+
*
|
|
6583
|
+
* @param url
|
|
6584
|
+
* @returns
|
|
6585
|
+
* @category URL
|
|
6586
|
+
*/
|
|
6587
|
+
function getUrlFileType(url) {
|
|
6588
|
+
var ret = '';
|
|
6589
|
+
if (typeof url != 'string' || url == '') {
|
|
6590
|
+
return ret;
|
|
6591
|
+
}
|
|
6592
|
+
var type = /\.[^/?#]+$/.exec(url);
|
|
6593
|
+
if (!type) {
|
|
6594
|
+
return ret;
|
|
6595
|
+
}
|
|
6596
|
+
if (type[0].length > 1) {
|
|
6597
|
+
ret = type[0].substring(1);
|
|
6598
|
+
}
|
|
6599
|
+
// if (ret.includes('?')) {
|
|
6600
|
+
// const arr = ret.split('?');
|
|
6601
|
+
// if (arr.length > 0) {
|
|
6602
|
+
// ret = arr[0];
|
|
6603
|
+
// }
|
|
6604
|
+
// }
|
|
6605
|
+
return ret;
|
|
6606
|
+
}
|
|
6477
6607
|
|
|
6478
|
-
export { addClass, addEvent, addStyle, calLongestCommonSubsequence, calLongestCommonSubstring, camelCase2Underscore, camelCaseToKebabCase, cancelBubble, clearHtml, convert10To26, cutCHSString, debounce, deepCopyObject, doFn, floatFixed, floatToPercent, formatDate,
|
|
6608
|
+
export { addClass, addEvent, addStyle, calLongestCommonSubsequence, calLongestCommonSubstring, camelCase2Underscore, camelCaseToKebabCase, cancelBubble, clearHtml, convert10To26, convertCamelToKebab, convertCamelToUnder, cutCHSString, debounce, deepCopyObject, doFn, floatFixed, floatToPercent, formatDate, genCustomConsole, genHashCode, generateRndNum, generateUniqueNum, getBrowserInfo, getCookie, getDefineListeners, getDomain, getFileSize, getFriendlyInterval, getHashQueryParam, getLocalStorage, getPerformance, getQueryParam, getSessionStorage, getUrlFileType, getUrlParam, hasClass, inRate, invokeEvent, isJSONString, isJsonString, isNonEmptyArray, isNumber, isSafePWAEnv, isSupportWebp, isValidData, isValidEmail, isValidPhoneNumber, isValidUrl, loadCSS, loadScript, mNow, mTrim, newLine, removeClass, removeEvent, setCookie, setLocalStorage, setSessionStorage, throttle, truncateZHString, updateQueryParam, windowLoaded, zAxiosIsValidRes };
|