mazey 3.6.3 → 3.6.4
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 +218 -123
- package/lib/index.d.ts +72 -14
- package/lib/index.d.ts.map +1 -1
- package/lib/index.esm.js +213 -123
- 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.4
|
|
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;
|
|
@@ -4219,6 +4219,10 @@ function getHashQueryParam(param) {
|
|
|
4219
4219
|
* ```
|
|
4220
4220
|
* getDomain('http://example.com/?t1=1&t2=2&t3=3&t4=4');
|
|
4221
4221
|
* getDomain('http://example.com/test/thanks?t1=1&t2=2&t3=3&t4=4', ['hostname', 'pathname']);
|
|
4222
|
+
* getDomain('http://example.com:7890/test/thanks', ['hostname']);
|
|
4223
|
+
* getDomain('http://example.com:7890/test/thanks', ['host']); // With Port
|
|
4224
|
+
* getDomain('http://example.com:7890/test/thanks', ['origin']);
|
|
4225
|
+
* getDomain('http://example.com:7890/test/thanks?id=1', ['origin', 'pathname', 'search']);
|
|
4222
4226
|
* ```
|
|
4223
4227
|
*
|
|
4224
4228
|
* Output:
|
|
@@ -4226,10 +4230,14 @@ function getHashQueryParam(param) {
|
|
|
4226
4230
|
* ```
|
|
4227
4231
|
* example.com
|
|
4228
4232
|
* example.com/test/thanks
|
|
4233
|
+
* example.com
|
|
4234
|
+
* example.com:7890
|
|
4235
|
+
* http://example.com:7890
|
|
4236
|
+
* http://example.com:7890/test/thanks?id=1
|
|
4229
4237
|
* ```
|
|
4230
4238
|
*
|
|
4231
4239
|
* @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'
|
|
4240
|
+
* @param {array} rules Object.keys(location), ['href', 'origin', 'protocol', 'host', 'hostname', 'port', 'pathname', 'search', 'hash'], ['hostname', 'pathname'] = 'km.mazey.net/plugins/servlet/mobile'
|
|
4233
4241
|
* @category URL
|
|
4234
4242
|
*/
|
|
4235
4243
|
function getDomain(url, rules) {
|
|
@@ -4247,34 +4255,50 @@ function getDomain(url, rules) {
|
|
|
4247
4255
|
* Transfer CamelCase to KebabCase.
|
|
4248
4256
|
*
|
|
4249
4257
|
* ```
|
|
4250
|
-
*
|
|
4251
|
-
*
|
|
4258
|
+
* convertCamelToKebab('ABC'); // a-b-c
|
|
4259
|
+
* convertCamelToKebab('aBC'); // a-b-c
|
|
4252
4260
|
* ```
|
|
4253
4261
|
*
|
|
4254
4262
|
* @param {string} camelCase 'aBC' or 'ABC'
|
|
4255
4263
|
* @returns {string} 'a-b-c'
|
|
4256
4264
|
* @category Util
|
|
4257
4265
|
*/
|
|
4258
|
-
function
|
|
4266
|
+
function convertCamelToKebab(camelCase) {
|
|
4259
4267
|
var kebabCase = camelCase.replace(/([A-Z])/g, '-$1').toLowerCase();
|
|
4260
4268
|
return kebabCase[0] === '-' ? kebabCase.substr(1) : kebabCase;
|
|
4261
4269
|
}
|
|
4270
|
+
/**
|
|
4271
|
+
* Alias of convertCamelToKebab
|
|
4272
|
+
*
|
|
4273
|
+
* @hidden
|
|
4274
|
+
*/
|
|
4275
|
+
function camelCaseToKebabCase(camelCase) {
|
|
4276
|
+
return convertCamelToKebab(camelCase);
|
|
4277
|
+
}
|
|
4262
4278
|
/**
|
|
4263
4279
|
* Transfer CamelCase to Underscore.
|
|
4264
4280
|
*
|
|
4265
4281
|
* ```
|
|
4266
|
-
*
|
|
4267
|
-
*
|
|
4282
|
+
* convertCamelToUnder('ABC'); // a_b_c
|
|
4283
|
+
* convertCamelToUnder('aBC'); // a_b_c
|
|
4268
4284
|
* ```
|
|
4269
4285
|
*
|
|
4270
4286
|
* @param {string} camelCase 'aBC' or 'ABC'
|
|
4271
4287
|
* @returns {string} 'a_b_c'
|
|
4272
4288
|
* @category Util
|
|
4273
4289
|
*/
|
|
4274
|
-
function
|
|
4290
|
+
function convertCamelToUnder(camelCase) {
|
|
4275
4291
|
var kebabCase = camelCase.replace(/([A-Z])/g, '_$1').toLowerCase();
|
|
4276
4292
|
return kebabCase[0] === '_' ? kebabCase.substr(1) : kebabCase;
|
|
4277
4293
|
}
|
|
4294
|
+
/**
|
|
4295
|
+
* Alias of convertCamelToUnder
|
|
4296
|
+
*
|
|
4297
|
+
* @hidden
|
|
4298
|
+
*/
|
|
4299
|
+
function camelCase2Underscore(camelCase) {
|
|
4300
|
+
return convertCamelToUnder(camelCase);
|
|
4301
|
+
}
|
|
4278
4302
|
/**
|
|
4279
4303
|
* Remove leading and trailing whitespace or specified characters from string.
|
|
4280
4304
|
*
|
|
@@ -4346,8 +4370,8 @@ function deepCopyObject(obj) {
|
|
|
4346
4370
|
* Usage:
|
|
4347
4371
|
*
|
|
4348
4372
|
* ```
|
|
4349
|
-
*
|
|
4350
|
-
*
|
|
4373
|
+
* isJSONString(`['a', 'b', 'c']`);
|
|
4374
|
+
* isJSONString(`["a", "b", "c"]`);
|
|
4351
4375
|
* ```
|
|
4352
4376
|
*
|
|
4353
4377
|
* Output:
|
|
@@ -4361,7 +4385,7 @@ function deepCopyObject(obj) {
|
|
|
4361
4385
|
* @returns {boolean} Return the result of checking.
|
|
4362
4386
|
* @category Util
|
|
4363
4387
|
*/
|
|
4364
|
-
function
|
|
4388
|
+
function isJSONString(str) {
|
|
4365
4389
|
try {
|
|
4366
4390
|
if (_typeof(JSON.parse(str)) === 'object') {
|
|
4367
4391
|
return true;
|
|
@@ -4371,6 +4395,14 @@ function isJsonString(str) {
|
|
|
4371
4395
|
}
|
|
4372
4396
|
return false;
|
|
4373
4397
|
}
|
|
4398
|
+
/**
|
|
4399
|
+
* Alias of isJSONString
|
|
4400
|
+
*
|
|
4401
|
+
* @hidden
|
|
4402
|
+
*/
|
|
4403
|
+
function isJsonString(str) {
|
|
4404
|
+
return isJSONString(str);
|
|
4405
|
+
}
|
|
4374
4406
|
/**
|
|
4375
4407
|
* Produce a random string of number, `generateRndNum(7)` => '7658495'.
|
|
4376
4408
|
*
|
|
@@ -4648,16 +4680,26 @@ function debounce(func, wait, immediate) {
|
|
|
4648
4680
|
return result;
|
|
4649
4681
|
};
|
|
4650
4682
|
}
|
|
4683
|
+
var defaultGetFriendlyIntervalOptions = {
|
|
4684
|
+
type: 'd'
|
|
4685
|
+
};
|
|
4651
4686
|
/**
|
|
4652
|
-
*
|
|
4653
|
-
*
|
|
4687
|
+
* 获取间隔时间
|
|
4688
|
+
*
|
|
4689
|
+
* @example
|
|
4690
|
+
* ```js
|
|
4691
|
+
* console.log('getFriendlyInterval:', getFriendlyInterval(new Date('2020-03-28 00:09:27'), new Date('2023-04-18 10:54:00'), { type: 'd' })); // 1116
|
|
4692
|
+
* console.log('getFriendlyInterval:', getFriendlyInterval(1585325367000, 1681786440000, { type: 'text' })); // 1116 天 10 时 44 分 33 秒
|
|
4693
|
+
* console.log('getFriendlyInterval:', getFriendlyInterval('2020-03-28 00:09:27', '2023-04-18 10:54:00', { type: 'text' })); // 1116 天 10 时 44 分 33 秒
|
|
4694
|
+
* ```
|
|
4695
|
+
*
|
|
4654
4696
|
* @param {number/Date} start 开始时间戳 1585325367122
|
|
4655
4697
|
* @param {number/Date} end 结束时间戳 1585325367122
|
|
4656
4698
|
* @param {string} options.type 返回类型 d: 2(天) text: 2 天 4 时...
|
|
4657
4699
|
* @returns {string/number} 取决于 type
|
|
4658
4700
|
* @category Util
|
|
4659
4701
|
*/
|
|
4660
|
-
function
|
|
4702
|
+
function getFriendlyInterval(start, end, options) {
|
|
4661
4703
|
if (start === void 0) {
|
|
4662
4704
|
start = 0;
|
|
4663
4705
|
}
|
|
@@ -4665,14 +4707,13 @@ function friendlyInterval(start, end, options) {
|
|
|
4665
4707
|
end = 0;
|
|
4666
4708
|
}
|
|
4667
4709
|
if (options === void 0) {
|
|
4668
|
-
options =
|
|
4669
|
-
type: 'd'
|
|
4670
|
-
};
|
|
4710
|
+
options = defaultGetFriendlyIntervalOptions;
|
|
4671
4711
|
}
|
|
4712
|
+
options = Object.assign(defaultGetFriendlyIntervalOptions, options);
|
|
4672
4713
|
var type = options.type;
|
|
4673
4714
|
if (!isNumber(start)) start = new Date(start).getTime();
|
|
4674
4715
|
if (!isNumber(end)) end = new Date(end).getTime();
|
|
4675
|
-
var t = end - start;
|
|
4716
|
+
var t = Number(end) - Number(start);
|
|
4676
4717
|
var ret = '';
|
|
4677
4718
|
var _a = new Array(4).fill(0),
|
|
4678
4719
|
d = _a[0],
|
|
@@ -5253,7 +5294,7 @@ function getCookie(name) {
|
|
|
5253
5294
|
* Results:
|
|
5254
5295
|
*
|
|
5255
5296
|
* | Attribute | Description | Type | Values |
|
|
5256
|
-
* |
|
|
5297
|
+
* | :------------ | :------------ | :------------ | :------------ |
|
|
5257
5298
|
* | dns_time | DNS Lookup | number | domainLookupEnd - domainLookupStart |
|
|
5258
5299
|
* | tcp_time | Connection Negotiation | number | connectEnd - connectStart |
|
|
5259
5300
|
* | response_time | Requests and Responses | number | responseStart - requestStart |
|
|
@@ -5586,7 +5627,7 @@ function isSafePWAEnv() {
|
|
|
5586
5627
|
* Results:
|
|
5587
5628
|
*
|
|
5588
5629
|
* | Attribute | Description | Type | Values |
|
|
5589
|
-
* |
|
|
5630
|
+
* | :------------ | :------------ | :------------ | :------------ |
|
|
5590
5631
|
* | **system** | System | string | android, ios, windows, macos, linux |
|
|
5591
5632
|
* | systemVs | System version | string | windows: 2000, xp, 2003, vista, 7, 8, 8.1, 10 <br />macos: ... |
|
|
5592
5633
|
* | platform | Platform | string | desktop, mobile |
|
|
@@ -5798,15 +5839,15 @@ function clearHtml(str) {
|
|
|
5798
5839
|
return str.replace(/<\/?.+?>/g, '').replace(/[\r\n]/g, '');
|
|
5799
5840
|
}
|
|
5800
5841
|
/**
|
|
5801
|
-
*
|
|
5802
|
-
*
|
|
5842
|
+
* 截取字符串,中文算 2 个字节
|
|
5843
|
+
*
|
|
5803
5844
|
* @param {string} str 要截取的字符串
|
|
5804
5845
|
* @param {number} len
|
|
5805
5846
|
* @param {boolean} hasDot
|
|
5806
5847
|
* @returns {string} 返回截取后的字符串
|
|
5807
5848
|
* @category Util
|
|
5808
5849
|
*/
|
|
5809
|
-
function
|
|
5850
|
+
function truncateZHString(str, len, hasDot) {
|
|
5810
5851
|
if (hasDot === void 0) {
|
|
5811
5852
|
hasDot = false;
|
|
5812
5853
|
}
|
|
@@ -5837,6 +5878,17 @@ function cutCHSString(str, len, hasDot) {
|
|
|
5837
5878
|
return newStr;
|
|
5838
5879
|
}
|
|
5839
5880
|
}
|
|
5881
|
+
/**
|
|
5882
|
+
* Alias of truncateZHString
|
|
5883
|
+
*
|
|
5884
|
+
* @hidden
|
|
5885
|
+
*/
|
|
5886
|
+
function cutCHSString(str, len, hasDot) {
|
|
5887
|
+
if (hasDot === void 0) {
|
|
5888
|
+
hasDot = false;
|
|
5889
|
+
}
|
|
5890
|
+
return truncateZHString(str, len, hasDot);
|
|
5891
|
+
}
|
|
5840
5892
|
/**
|
|
5841
5893
|
* EN: Check whether the page is loaded successfully (Keepe the compatibility in case that browser's `load` event has been triggered).
|
|
5842
5894
|
*
|
|
@@ -6474,5 +6526,43 @@ function convert10To26(num) {
|
|
|
6474
6526
|
}
|
|
6475
6527
|
return result;
|
|
6476
6528
|
}
|
|
6529
|
+
/**
|
|
6530
|
+
* EN: Get the file type of the url.
|
|
6531
|
+
*
|
|
6532
|
+
* ZH: 获取文件后缀名
|
|
6533
|
+
*
|
|
6534
|
+
* @example
|
|
6535
|
+
* ```js
|
|
6536
|
+
* console.log(getUrlFileType('https://example.com/a/b/c.png')); // png
|
|
6537
|
+
* console.log(getUrlFileType('https://example.com/a/b/c.jpg')); // jpg
|
|
6538
|
+
* console.log(getUrlFileType('https://example.com/a/b/c.jpeg')); // jpeg
|
|
6539
|
+
* console.log(getUrlFileType('/a/b/c.jpeg')); // jpeg
|
|
6540
|
+
* console.log(getUrlFileType('https://example.com/a/b/c.v/a')); // ''
|
|
6541
|
+
* ```
|
|
6542
|
+
*
|
|
6543
|
+
* @param url
|
|
6544
|
+
* @returns
|
|
6545
|
+
* @category URL
|
|
6546
|
+
*/
|
|
6547
|
+
function getUrlFileType(url) {
|
|
6548
|
+
var ret = '';
|
|
6549
|
+
if (typeof url != 'string' || url == '') {
|
|
6550
|
+
return ret;
|
|
6551
|
+
}
|
|
6552
|
+
var type = /\.[^/?#]+$/.exec(url);
|
|
6553
|
+
if (!type) {
|
|
6554
|
+
return ret;
|
|
6555
|
+
}
|
|
6556
|
+
if (type[0].length > 1) {
|
|
6557
|
+
ret = type[0].substring(1);
|
|
6558
|
+
}
|
|
6559
|
+
// if (ret.includes('?')) {
|
|
6560
|
+
// const arr = ret.split('?');
|
|
6561
|
+
// if (arr.length > 0) {
|
|
6562
|
+
// ret = arr[0];
|
|
6563
|
+
// }
|
|
6564
|
+
// }
|
|
6565
|
+
return ret;
|
|
6566
|
+
}
|
|
6477
6567
|
|
|
6478
|
-
export { addClass, addEvent, addStyle, calLongestCommonSubsequence, calLongestCommonSubstring, camelCase2Underscore, camelCaseToKebabCase, cancelBubble, clearHtml, convert10To26, cutCHSString, debounce, deepCopyObject, doFn, floatFixed, floatToPercent, formatDate,
|
|
6568
|
+
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 };
|