mazey 3.6.2 → 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 +43 -31
- package/lib/index.cjs.js +259 -135
- package/lib/index.d.ts +101 -26
- package/lib/index.d.ts.map +1 -1
- package/lib/index.esm.js +253 -135
- package/lib/mazey.min.js +2 -2
- package/package.json +2 -1
- package/scripts/README.md +8 -0
- package/scripts/build-helper.js +23 -10
package/lib/index.cjs.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
|
*/
|
|
@@ -2654,8 +2654,99 @@ _export({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== obje
|
|
|
2654
2654
|
assign: objectAssign
|
|
2655
2655
|
});
|
|
2656
2656
|
|
|
2657
|
+
var path = global_1;
|
|
2658
|
+
|
|
2659
|
+
var getOwnPropertyNames = objectGetOwnPropertyNames.f;
|
|
2660
|
+
var getOwnPropertyDescriptor$2 = objectGetOwnPropertyDescriptor.f;
|
|
2657
2661
|
var defineProperty$1 = objectDefineProperty.f;
|
|
2658
2662
|
|
|
2663
|
+
var trim = stringTrim.trim;
|
|
2664
|
+
|
|
2665
|
+
var NUMBER = 'Number';
|
|
2666
|
+
var NativeNumber = global_1[NUMBER];
|
|
2667
|
+
path[NUMBER];
|
|
2668
|
+
var NumberPrototype = NativeNumber.prototype;
|
|
2669
|
+
var TypeError$2 = global_1.TypeError;
|
|
2670
|
+
var stringSlice = functionUncurryThis(''.slice);
|
|
2671
|
+
var charCodeAt = functionUncurryThis(''.charCodeAt);
|
|
2672
|
+
|
|
2673
|
+
// `ToNumeric` abstract operation
|
|
2674
|
+
// https://tc39.es/ecma262/#sec-tonumeric
|
|
2675
|
+
var toNumeric = function (value) {
|
|
2676
|
+
var primValue = toPrimitive(value, 'number');
|
|
2677
|
+
return typeof primValue == 'bigint' ? primValue : toNumber(primValue);
|
|
2678
|
+
};
|
|
2679
|
+
|
|
2680
|
+
// `ToNumber` abstract operation
|
|
2681
|
+
// https://tc39.es/ecma262/#sec-tonumber
|
|
2682
|
+
var toNumber = function (argument) {
|
|
2683
|
+
var it = toPrimitive(argument, 'number');
|
|
2684
|
+
var first, third, radix, maxCode, digits, length, index, code;
|
|
2685
|
+
if (isSymbol(it)) throw TypeError$2('Cannot convert a Symbol value to a number');
|
|
2686
|
+
if (typeof it == 'string' && it.length > 2) {
|
|
2687
|
+
it = trim(it);
|
|
2688
|
+
first = charCodeAt(it, 0);
|
|
2689
|
+
if (first === 43 || first === 45) {
|
|
2690
|
+
third = charCodeAt(it, 2);
|
|
2691
|
+
if (third === 88 || third === 120) return NaN; // Number('+0x1') should be NaN, old V8 fix
|
|
2692
|
+
} else if (first === 48) {
|
|
2693
|
+
switch (charCodeAt(it, 1)) {
|
|
2694
|
+
case 66: case 98: radix = 2; maxCode = 49; break; // fast equal of /^0b[01]+$/i
|
|
2695
|
+
case 79: case 111: radix = 8; maxCode = 55; break; // fast equal of /^0o[0-7]+$/i
|
|
2696
|
+
default: return +it;
|
|
2697
|
+
}
|
|
2698
|
+
digits = stringSlice(it, 2);
|
|
2699
|
+
length = digits.length;
|
|
2700
|
+
for (index = 0; index < length; index++) {
|
|
2701
|
+
code = charCodeAt(digits, index);
|
|
2702
|
+
// parseInt parses a string to a first unavailable symbol
|
|
2703
|
+
// but ToNumber should return NaN if a string contains unavailable symbols
|
|
2704
|
+
if (code < 48 || code > maxCode) return NaN;
|
|
2705
|
+
} return parseInt(digits, radix);
|
|
2706
|
+
}
|
|
2707
|
+
} return +it;
|
|
2708
|
+
};
|
|
2709
|
+
|
|
2710
|
+
var FORCED$1 = isForced_1(NUMBER, !NativeNumber(' 0o1') || !NativeNumber('0b1') || NativeNumber('+0x1'));
|
|
2711
|
+
|
|
2712
|
+
var calledWithNew = function (dummy) {
|
|
2713
|
+
// includes check on 1..constructor(foo) case
|
|
2714
|
+
return objectIsPrototypeOf(NumberPrototype, dummy) && fails(function () { thisNumberValue(dummy); });
|
|
2715
|
+
};
|
|
2716
|
+
|
|
2717
|
+
// `Number` constructor
|
|
2718
|
+
// https://tc39.es/ecma262/#sec-number-constructor
|
|
2719
|
+
var NumberWrapper = function Number(value) {
|
|
2720
|
+
var n = arguments.length < 1 ? 0 : NativeNumber(toNumeric(value));
|
|
2721
|
+
return calledWithNew(this) ? inheritIfRequired(Object(n), this, NumberWrapper) : n;
|
|
2722
|
+
};
|
|
2723
|
+
|
|
2724
|
+
NumberWrapper.prototype = NumberPrototype;
|
|
2725
|
+
if (FORCED$1 && !isPure) NumberPrototype.constructor = NumberWrapper;
|
|
2726
|
+
|
|
2727
|
+
_export({ global: true, constructor: true, wrap: true, forced: FORCED$1 }, {
|
|
2728
|
+
Number: NumberWrapper
|
|
2729
|
+
});
|
|
2730
|
+
|
|
2731
|
+
// Use `internal/copy-constructor-properties` helper in `core-js@4`
|
|
2732
|
+
var copyConstructorProperties = function (target, source) {
|
|
2733
|
+
for (var keys = descriptors ? getOwnPropertyNames(source) : (
|
|
2734
|
+
// ES3:
|
|
2735
|
+
'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' +
|
|
2736
|
+
// ES2015 (in case, if modules with ES2015 Number statics required before):
|
|
2737
|
+
'EPSILON,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseInt,' +
|
|
2738
|
+
// ESNext
|
|
2739
|
+
'fromString,range'
|
|
2740
|
+
).split(','), j = 0, key; keys.length > j; j++) {
|
|
2741
|
+
if (hasOwnProperty_1(source, key = keys[j]) && !hasOwnProperty_1(target, key)) {
|
|
2742
|
+
defineProperty$1(target, key, getOwnPropertyDescriptor$2(source, key));
|
|
2743
|
+
}
|
|
2744
|
+
}
|
|
2745
|
+
};
|
|
2746
|
+
if (FORCED$1 || isPure) copyConstructorProperties(path[NUMBER], NativeNumber);
|
|
2747
|
+
|
|
2748
|
+
var defineProperty = objectDefineProperty.f;
|
|
2749
|
+
|
|
2659
2750
|
|
|
2660
2751
|
|
|
2661
2752
|
var TO_STRING_TAG = wellKnownSymbol('toStringTag');
|
|
@@ -2663,7 +2754,7 @@ var TO_STRING_TAG = wellKnownSymbol('toStringTag');
|
|
|
2663
2754
|
var setToStringTag = function (target, TAG, STATIC) {
|
|
2664
2755
|
if (target && !STATIC) target = target.prototype;
|
|
2665
2756
|
if (target && !hasOwnProperty_1(target, TO_STRING_TAG)) {
|
|
2666
|
-
defineProperty
|
|
2757
|
+
defineProperty(target, TO_STRING_TAG, { configurable: true, value: TAG });
|
|
2667
2758
|
}
|
|
2668
2759
|
};
|
|
2669
2760
|
|
|
@@ -2827,7 +2918,7 @@ var engineIsIosPebble = /ipad|iphone|ipod/i.test(engineUserAgent) && typeof Pebb
|
|
|
2827
2918
|
|
|
2828
2919
|
var engineIsWebosWebkit = /web0s(?!.*chrome)/i.test(engineUserAgent);
|
|
2829
2920
|
|
|
2830
|
-
var getOwnPropertyDescriptor$
|
|
2921
|
+
var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
|
|
2831
2922
|
var macrotask = task$1.set;
|
|
2832
2923
|
|
|
2833
2924
|
|
|
@@ -2840,7 +2931,7 @@ var document$2 = global_1.document;
|
|
|
2840
2931
|
var process$2 = global_1.process;
|
|
2841
2932
|
var Promise$1 = global_1.Promise;
|
|
2842
2933
|
// Node.js 11 shows ExperimentalWarning on getting `queueMicrotask`
|
|
2843
|
-
var queueMicrotaskDescriptor = getOwnPropertyDescriptor$
|
|
2934
|
+
var queueMicrotaskDescriptor = getOwnPropertyDescriptor$1(global_1, 'queueMicrotask');
|
|
2844
2935
|
var microtask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value;
|
|
2845
2936
|
var notify$1, toggle, node, promise, then;
|
|
2846
2937
|
|
|
@@ -3007,7 +3098,7 @@ var setInternalState = internalState.set;
|
|
|
3007
3098
|
var NativePromisePrototype$1 = promiseNativeConstructor && promiseNativeConstructor.prototype;
|
|
3008
3099
|
var PromiseConstructor = promiseNativeConstructor;
|
|
3009
3100
|
var PromisePrototype = NativePromisePrototype$1;
|
|
3010
|
-
var TypeError$
|
|
3101
|
+
var TypeError$1 = global_1.TypeError;
|
|
3011
3102
|
var document$1 = global_1.document;
|
|
3012
3103
|
var process$1 = global_1.process;
|
|
3013
3104
|
var newPromiseCapability = newPromiseCapability$1.f;
|
|
@@ -3054,7 +3145,7 @@ var callReaction = function (reaction, state) {
|
|
|
3054
3145
|
}
|
|
3055
3146
|
}
|
|
3056
3147
|
if (result === reaction.promise) {
|
|
3057
|
-
reject(TypeError$
|
|
3148
|
+
reject(TypeError$1('Promise-chain cycle'));
|
|
3058
3149
|
} else if (then = isThenable(result)) {
|
|
3059
3150
|
functionCall(then, result, resolve, reject);
|
|
3060
3151
|
} else resolve(result);
|
|
@@ -3144,7 +3235,7 @@ var internalResolve = function (state, value, unwrap) {
|
|
|
3144
3235
|
state.done = true;
|
|
3145
3236
|
if (unwrap) state = unwrap;
|
|
3146
3237
|
try {
|
|
3147
|
-
if (state.facade === value) throw TypeError$
|
|
3238
|
+
if (state.facade === value) throw TypeError$1("Promise can't be resolved itself");
|
|
3148
3239
|
var then = isThenable(value);
|
|
3149
3240
|
if (then) {
|
|
3150
3241
|
microtask_1(function () {
|
|
@@ -3544,11 +3635,11 @@ if (descriptors && !FUNCTION_NAME_EXISTS) {
|
|
|
3544
3635
|
var nativeJoin = functionUncurryThis([].join);
|
|
3545
3636
|
|
|
3546
3637
|
var ES3_STRINGS = indexedObject != Object;
|
|
3547
|
-
var FORCED
|
|
3638
|
+
var FORCED = ES3_STRINGS || !arrayMethodIsStrict('join', ',');
|
|
3548
3639
|
|
|
3549
3640
|
// `Array.prototype.join` method
|
|
3550
3641
|
// https://tc39.es/ecma262/#sec-array.prototype.join
|
|
3551
|
-
_export({ target: 'Array', proto: true, forced: FORCED
|
|
3642
|
+
_export({ target: 'Array', proto: true, forced: FORCED }, {
|
|
3552
3643
|
join: function join(separator) {
|
|
3553
3644
|
return nativeJoin(toIndexedObject(this), separator === undefined ? ',' : separator);
|
|
3554
3645
|
}
|
|
@@ -3801,97 +3892,6 @@ _export({ target: 'String', proto: true, forced: !correctIsRegexpLogic('includes
|
|
|
3801
3892
|
}
|
|
3802
3893
|
});
|
|
3803
3894
|
|
|
3804
|
-
var path = global_1;
|
|
3805
|
-
|
|
3806
|
-
var getOwnPropertyNames = objectGetOwnPropertyNames.f;
|
|
3807
|
-
var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
|
|
3808
|
-
var defineProperty = objectDefineProperty.f;
|
|
3809
|
-
|
|
3810
|
-
var trim = stringTrim.trim;
|
|
3811
|
-
|
|
3812
|
-
var NUMBER = 'Number';
|
|
3813
|
-
var NativeNumber = global_1[NUMBER];
|
|
3814
|
-
path[NUMBER];
|
|
3815
|
-
var NumberPrototype = NativeNumber.prototype;
|
|
3816
|
-
var TypeError$1 = global_1.TypeError;
|
|
3817
|
-
var stringSlice = functionUncurryThis(''.slice);
|
|
3818
|
-
var charCodeAt = functionUncurryThis(''.charCodeAt);
|
|
3819
|
-
|
|
3820
|
-
// `ToNumeric` abstract operation
|
|
3821
|
-
// https://tc39.es/ecma262/#sec-tonumeric
|
|
3822
|
-
var toNumeric = function (value) {
|
|
3823
|
-
var primValue = toPrimitive(value, 'number');
|
|
3824
|
-
return typeof primValue == 'bigint' ? primValue : toNumber(primValue);
|
|
3825
|
-
};
|
|
3826
|
-
|
|
3827
|
-
// `ToNumber` abstract operation
|
|
3828
|
-
// https://tc39.es/ecma262/#sec-tonumber
|
|
3829
|
-
var toNumber = function (argument) {
|
|
3830
|
-
var it = toPrimitive(argument, 'number');
|
|
3831
|
-
var first, third, radix, maxCode, digits, length, index, code;
|
|
3832
|
-
if (isSymbol(it)) throw TypeError$1('Cannot convert a Symbol value to a number');
|
|
3833
|
-
if (typeof it == 'string' && it.length > 2) {
|
|
3834
|
-
it = trim(it);
|
|
3835
|
-
first = charCodeAt(it, 0);
|
|
3836
|
-
if (first === 43 || first === 45) {
|
|
3837
|
-
third = charCodeAt(it, 2);
|
|
3838
|
-
if (third === 88 || third === 120) return NaN; // Number('+0x1') should be NaN, old V8 fix
|
|
3839
|
-
} else if (first === 48) {
|
|
3840
|
-
switch (charCodeAt(it, 1)) {
|
|
3841
|
-
case 66: case 98: radix = 2; maxCode = 49; break; // fast equal of /^0b[01]+$/i
|
|
3842
|
-
case 79: case 111: radix = 8; maxCode = 55; break; // fast equal of /^0o[0-7]+$/i
|
|
3843
|
-
default: return +it;
|
|
3844
|
-
}
|
|
3845
|
-
digits = stringSlice(it, 2);
|
|
3846
|
-
length = digits.length;
|
|
3847
|
-
for (index = 0; index < length; index++) {
|
|
3848
|
-
code = charCodeAt(digits, index);
|
|
3849
|
-
// parseInt parses a string to a first unavailable symbol
|
|
3850
|
-
// but ToNumber should return NaN if a string contains unavailable symbols
|
|
3851
|
-
if (code < 48 || code > maxCode) return NaN;
|
|
3852
|
-
} return parseInt(digits, radix);
|
|
3853
|
-
}
|
|
3854
|
-
} return +it;
|
|
3855
|
-
};
|
|
3856
|
-
|
|
3857
|
-
var FORCED = isForced_1(NUMBER, !NativeNumber(' 0o1') || !NativeNumber('0b1') || NativeNumber('+0x1'));
|
|
3858
|
-
|
|
3859
|
-
var calledWithNew = function (dummy) {
|
|
3860
|
-
// includes check on 1..constructor(foo) case
|
|
3861
|
-
return objectIsPrototypeOf(NumberPrototype, dummy) && fails(function () { thisNumberValue(dummy); });
|
|
3862
|
-
};
|
|
3863
|
-
|
|
3864
|
-
// `Number` constructor
|
|
3865
|
-
// https://tc39.es/ecma262/#sec-number-constructor
|
|
3866
|
-
var NumberWrapper = function Number(value) {
|
|
3867
|
-
var n = arguments.length < 1 ? 0 : NativeNumber(toNumeric(value));
|
|
3868
|
-
return calledWithNew(this) ? inheritIfRequired(Object(n), this, NumberWrapper) : n;
|
|
3869
|
-
};
|
|
3870
|
-
|
|
3871
|
-
NumberWrapper.prototype = NumberPrototype;
|
|
3872
|
-
if (FORCED && !isPure) NumberPrototype.constructor = NumberWrapper;
|
|
3873
|
-
|
|
3874
|
-
_export({ global: true, constructor: true, wrap: true, forced: FORCED }, {
|
|
3875
|
-
Number: NumberWrapper
|
|
3876
|
-
});
|
|
3877
|
-
|
|
3878
|
-
// Use `internal/copy-constructor-properties` helper in `core-js@4`
|
|
3879
|
-
var copyConstructorProperties = function (target, source) {
|
|
3880
|
-
for (var keys = descriptors ? getOwnPropertyNames(source) : (
|
|
3881
|
-
// ES3:
|
|
3882
|
-
'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' +
|
|
3883
|
-
// ES2015 (in case, if modules with ES2015 Number statics required before):
|
|
3884
|
-
'EPSILON,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseInt,' +
|
|
3885
|
-
// ESNext
|
|
3886
|
-
'fromString,range'
|
|
3887
|
-
).split(','), j = 0, key; keys.length > j; j++) {
|
|
3888
|
-
if (hasOwnProperty_1(source, key = keys[j]) && !hasOwnProperty_1(target, key)) {
|
|
3889
|
-
defineProperty(target, key, getOwnPropertyDescriptor$1(source, key));
|
|
3890
|
-
}
|
|
3891
|
-
}
|
|
3892
|
-
};
|
|
3893
|
-
if (FORCED || isPure) copyConstructorProperties(path[NUMBER], NativeNumber);
|
|
3894
|
-
|
|
3895
3895
|
var $TypeError$1 = TypeError;
|
|
3896
3896
|
// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
|
|
3897
3897
|
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
@@ -4223,6 +4223,10 @@ function getHashQueryParam(param) {
|
|
|
4223
4223
|
* ```
|
|
4224
4224
|
* getDomain('http://example.com/?t1=1&t2=2&t3=3&t4=4');
|
|
4225
4225
|
* getDomain('http://example.com/test/thanks?t1=1&t2=2&t3=3&t4=4', ['hostname', 'pathname']);
|
|
4226
|
+
* getDomain('http://example.com:7890/test/thanks', ['hostname']);
|
|
4227
|
+
* getDomain('http://example.com:7890/test/thanks', ['host']); // With Port
|
|
4228
|
+
* getDomain('http://example.com:7890/test/thanks', ['origin']);
|
|
4229
|
+
* getDomain('http://example.com:7890/test/thanks?id=1', ['origin', 'pathname', 'search']);
|
|
4226
4230
|
* ```
|
|
4227
4231
|
*
|
|
4228
4232
|
* Output:
|
|
@@ -4230,10 +4234,14 @@ function getHashQueryParam(param) {
|
|
|
4230
4234
|
* ```
|
|
4231
4235
|
* example.com
|
|
4232
4236
|
* example.com/test/thanks
|
|
4237
|
+
* example.com
|
|
4238
|
+
* example.com:7890
|
|
4239
|
+
* http://example.com:7890
|
|
4240
|
+
* http://example.com:7890/test/thanks?id=1
|
|
4233
4241
|
* ```
|
|
4234
4242
|
*
|
|
4235
4243
|
* @param {string} url
|
|
4236
|
-
* @param {array} rules Object.keys(location), ['href', 'protocol', 'host', 'hostname', 'port', 'pathname', 'search', 'hash'], ['hostname', 'pathname'] = 'km.mazey.net/plugins/servlet/mobile'
|
|
4244
|
+
* @param {array} rules Object.keys(location), ['href', 'origin', 'protocol', 'host', 'hostname', 'port', 'pathname', 'search', 'hash'], ['hostname', 'pathname'] = 'km.mazey.net/plugins/servlet/mobile'
|
|
4237
4245
|
* @category URL
|
|
4238
4246
|
*/
|
|
4239
4247
|
function getDomain(url, rules) {
|
|
@@ -4251,34 +4259,50 @@ function getDomain(url, rules) {
|
|
|
4251
4259
|
* Transfer CamelCase to KebabCase.
|
|
4252
4260
|
*
|
|
4253
4261
|
* ```
|
|
4254
|
-
*
|
|
4255
|
-
*
|
|
4262
|
+
* convertCamelToKebab('ABC'); // a-b-c
|
|
4263
|
+
* convertCamelToKebab('aBC'); // a-b-c
|
|
4256
4264
|
* ```
|
|
4257
4265
|
*
|
|
4258
4266
|
* @param {string} camelCase 'aBC' or 'ABC'
|
|
4259
4267
|
* @returns {string} 'a-b-c'
|
|
4260
4268
|
* @category Util
|
|
4261
4269
|
*/
|
|
4262
|
-
function
|
|
4270
|
+
function convertCamelToKebab(camelCase) {
|
|
4263
4271
|
var kebabCase = camelCase.replace(/([A-Z])/g, '-$1').toLowerCase();
|
|
4264
4272
|
return kebabCase[0] === '-' ? kebabCase.substr(1) : kebabCase;
|
|
4265
4273
|
}
|
|
4274
|
+
/**
|
|
4275
|
+
* Alias of convertCamelToKebab
|
|
4276
|
+
*
|
|
4277
|
+
* @hidden
|
|
4278
|
+
*/
|
|
4279
|
+
function camelCaseToKebabCase(camelCase) {
|
|
4280
|
+
return convertCamelToKebab(camelCase);
|
|
4281
|
+
}
|
|
4266
4282
|
/**
|
|
4267
4283
|
* Transfer CamelCase to Underscore.
|
|
4268
4284
|
*
|
|
4269
4285
|
* ```
|
|
4270
|
-
*
|
|
4271
|
-
*
|
|
4286
|
+
* convertCamelToUnder('ABC'); // a_b_c
|
|
4287
|
+
* convertCamelToUnder('aBC'); // a_b_c
|
|
4272
4288
|
* ```
|
|
4273
4289
|
*
|
|
4274
4290
|
* @param {string} camelCase 'aBC' or 'ABC'
|
|
4275
4291
|
* @returns {string} 'a_b_c'
|
|
4276
4292
|
* @category Util
|
|
4277
4293
|
*/
|
|
4278
|
-
function
|
|
4294
|
+
function convertCamelToUnder(camelCase) {
|
|
4279
4295
|
var kebabCase = camelCase.replace(/([A-Z])/g, '_$1').toLowerCase();
|
|
4280
4296
|
return kebabCase[0] === '_' ? kebabCase.substr(1) : kebabCase;
|
|
4281
4297
|
}
|
|
4298
|
+
/**
|
|
4299
|
+
* Alias of convertCamelToUnder
|
|
4300
|
+
*
|
|
4301
|
+
* @hidden
|
|
4302
|
+
*/
|
|
4303
|
+
function camelCase2Underscore(camelCase) {
|
|
4304
|
+
return convertCamelToUnder(camelCase);
|
|
4305
|
+
}
|
|
4282
4306
|
/**
|
|
4283
4307
|
* Remove leading and trailing whitespace or specified characters from string.
|
|
4284
4308
|
*
|
|
@@ -4350,8 +4374,8 @@ function deepCopyObject(obj) {
|
|
|
4350
4374
|
* Usage:
|
|
4351
4375
|
*
|
|
4352
4376
|
* ```
|
|
4353
|
-
*
|
|
4354
|
-
*
|
|
4377
|
+
* isJSONString(`['a', 'b', 'c']`);
|
|
4378
|
+
* isJSONString(`["a", "b", "c"]`);
|
|
4355
4379
|
* ```
|
|
4356
4380
|
*
|
|
4357
4381
|
* Output:
|
|
@@ -4365,7 +4389,7 @@ function deepCopyObject(obj) {
|
|
|
4365
4389
|
* @returns {boolean} Return the result of checking.
|
|
4366
4390
|
* @category Util
|
|
4367
4391
|
*/
|
|
4368
|
-
function
|
|
4392
|
+
function isJSONString(str) {
|
|
4369
4393
|
try {
|
|
4370
4394
|
if (_typeof(JSON.parse(str)) === 'object') {
|
|
4371
4395
|
return true;
|
|
@@ -4375,6 +4399,14 @@ function isJsonString(str) {
|
|
|
4375
4399
|
}
|
|
4376
4400
|
return false;
|
|
4377
4401
|
}
|
|
4402
|
+
/**
|
|
4403
|
+
* Alias of isJSONString
|
|
4404
|
+
*
|
|
4405
|
+
* @hidden
|
|
4406
|
+
*/
|
|
4407
|
+
function isJsonString(str) {
|
|
4408
|
+
return isJSONString(str);
|
|
4409
|
+
}
|
|
4378
4410
|
/**
|
|
4379
4411
|
* Produce a random string of number, `generateRndNum(7)` => '7658495'.
|
|
4380
4412
|
*
|
|
@@ -4652,16 +4684,26 @@ function debounce(func, wait, immediate) {
|
|
|
4652
4684
|
return result;
|
|
4653
4685
|
};
|
|
4654
4686
|
}
|
|
4687
|
+
var defaultGetFriendlyIntervalOptions = {
|
|
4688
|
+
type: 'd'
|
|
4689
|
+
};
|
|
4655
4690
|
/**
|
|
4656
|
-
*
|
|
4657
|
-
*
|
|
4691
|
+
* 获取间隔时间
|
|
4692
|
+
*
|
|
4693
|
+
* @example
|
|
4694
|
+
* ```js
|
|
4695
|
+
* console.log('getFriendlyInterval:', getFriendlyInterval(new Date('2020-03-28 00:09:27'), new Date('2023-04-18 10:54:00'), { type: 'd' })); // 1116
|
|
4696
|
+
* console.log('getFriendlyInterval:', getFriendlyInterval(1585325367000, 1681786440000, { type: 'text' })); // 1116 天 10 时 44 分 33 秒
|
|
4697
|
+
* console.log('getFriendlyInterval:', getFriendlyInterval('2020-03-28 00:09:27', '2023-04-18 10:54:00', { type: 'text' })); // 1116 天 10 时 44 分 33 秒
|
|
4698
|
+
* ```
|
|
4699
|
+
*
|
|
4658
4700
|
* @param {number/Date} start 开始时间戳 1585325367122
|
|
4659
4701
|
* @param {number/Date} end 结束时间戳 1585325367122
|
|
4660
4702
|
* @param {string} options.type 返回类型 d: 2(天) text: 2 天 4 时...
|
|
4661
4703
|
* @returns {string/number} 取决于 type
|
|
4662
4704
|
* @category Util
|
|
4663
4705
|
*/
|
|
4664
|
-
function
|
|
4706
|
+
function getFriendlyInterval(start, end, options) {
|
|
4665
4707
|
if (start === void 0) {
|
|
4666
4708
|
start = 0;
|
|
4667
4709
|
}
|
|
@@ -4669,14 +4711,13 @@ function friendlyInterval(start, end, options) {
|
|
|
4669
4711
|
end = 0;
|
|
4670
4712
|
}
|
|
4671
4713
|
if (options === void 0) {
|
|
4672
|
-
options =
|
|
4673
|
-
type: 'd'
|
|
4674
|
-
};
|
|
4714
|
+
options = defaultGetFriendlyIntervalOptions;
|
|
4675
4715
|
}
|
|
4716
|
+
options = Object.assign(defaultGetFriendlyIntervalOptions, options);
|
|
4676
4717
|
var type = options.type;
|
|
4677
4718
|
if (!isNumber(start)) start = new Date(start).getTime();
|
|
4678
4719
|
if (!isNumber(end)) end = new Date(end).getTime();
|
|
4679
|
-
var t = end - start;
|
|
4720
|
+
var t = Number(end) - Number(start);
|
|
4680
4721
|
var ret = '';
|
|
4681
4722
|
var _a = new Array(4).fill(0),
|
|
4682
4723
|
d = _a[0],
|
|
@@ -5256,19 +5297,19 @@ function getCookie(name) {
|
|
|
5256
5297
|
*
|
|
5257
5298
|
* Results:
|
|
5258
5299
|
*
|
|
5259
|
-
* |
|
|
5260
|
-
* |
|
|
5261
|
-
* | DNS
|
|
5262
|
-
* | Connection
|
|
5263
|
-
* | Requests and
|
|
5264
|
-
* | White
|
|
5265
|
-
* | DomReady |
|
|
5266
|
-
* | Onload |
|
|
5267
|
-
* | EventEnd |
|
|
5268
|
-
* | Unload |
|
|
5269
|
-
* | Redirect |
|
|
5270
|
-
* | SSL |
|
|
5271
|
-
* | Download |
|
|
5300
|
+
* | Attribute | Description | Type | Values |
|
|
5301
|
+
* | :------------ | :------------ | :------------ | :------------ |
|
|
5302
|
+
* | dns_time | DNS Lookup | number | domainLookupEnd - domainLookupStart |
|
|
5303
|
+
* | tcp_time | Connection Negotiation | number | connectEnd - connectStart |
|
|
5304
|
+
* | response_time | Requests and Responses | number | responseStart - requestStart |
|
|
5305
|
+
* | white_time | White Screen | number | responseStart - navigationStart |
|
|
5306
|
+
* | domready_time | DomReady | number | domContentLoadedEventStart - navigationStart |
|
|
5307
|
+
* | onload_time | Onload | number | loadEventStart - navigationStart |
|
|
5308
|
+
* | render_time | EventEnd | number | loadEventEnd -navigationStart |
|
|
5309
|
+
* | unload_time | Unload | number | (Optional) unloadEventEnd - unloadEventStart |
|
|
5310
|
+
* | redirect_time | Redirect | number | (Optional) redirectEnd - redirectStart |
|
|
5311
|
+
* | ssl_time | SSL | number | (Optional) connectEnd - secureConnectionStart |
|
|
5312
|
+
* | download_time | Download | number | (Optional) responseEnd - responseStart |
|
|
5272
5313
|
*
|
|
5273
5314
|
* @param {boolean} camelCase -- false(默认) 以下划线形式返回数据 true 以驼峰形式返回数据
|
|
5274
5315
|
* @returns {Promise<object>} 加载数据
|
|
@@ -5590,7 +5631,7 @@ function isSafePWAEnv() {
|
|
|
5590
5631
|
* Results:
|
|
5591
5632
|
*
|
|
5592
5633
|
* | Attribute | Description | Type | Values |
|
|
5593
|
-
* |
|
|
5634
|
+
* | :------------ | :------------ | :------------ | :------------ |
|
|
5594
5635
|
* | **system** | System | string | android, ios, windows, macos, linux |
|
|
5595
5636
|
* | systemVs | System version | string | windows: 2000, xp, 2003, vista, 7, 8, 8.1, 10 <br />macos: ... |
|
|
5596
5637
|
* | platform | Platform | string | desktop, mobile |
|
|
@@ -5802,15 +5843,15 @@ function clearHtml(str) {
|
|
|
5802
5843
|
return str.replace(/<\/?.+?>/g, '').replace(/[\r\n]/g, '');
|
|
5803
5844
|
}
|
|
5804
5845
|
/**
|
|
5805
|
-
*
|
|
5806
|
-
*
|
|
5846
|
+
* 截取字符串,中文算 2 个字节
|
|
5847
|
+
*
|
|
5807
5848
|
* @param {string} str 要截取的字符串
|
|
5808
5849
|
* @param {number} len
|
|
5809
5850
|
* @param {boolean} hasDot
|
|
5810
5851
|
* @returns {string} 返回截取后的字符串
|
|
5811
5852
|
* @category Util
|
|
5812
5853
|
*/
|
|
5813
|
-
function
|
|
5854
|
+
function truncateZHString(str, len, hasDot) {
|
|
5814
5855
|
if (hasDot === void 0) {
|
|
5815
5856
|
hasDot = false;
|
|
5816
5857
|
}
|
|
@@ -5841,6 +5882,17 @@ function cutCHSString(str, len, hasDot) {
|
|
|
5841
5882
|
return newStr;
|
|
5842
5883
|
}
|
|
5843
5884
|
}
|
|
5885
|
+
/**
|
|
5886
|
+
* Alias of truncateZHString
|
|
5887
|
+
*
|
|
5888
|
+
* @hidden
|
|
5889
|
+
*/
|
|
5890
|
+
function cutCHSString(str, len, hasDot) {
|
|
5891
|
+
if (hasDot === void 0) {
|
|
5892
|
+
hasDot = false;
|
|
5893
|
+
}
|
|
5894
|
+
return truncateZHString(str, len, hasDot);
|
|
5895
|
+
}
|
|
5844
5896
|
/**
|
|
5845
5897
|
* EN: Check whether the page is loaded successfully (Keepe the compatibility in case that browser's `load` event has been triggered).
|
|
5846
5898
|
*
|
|
@@ -6450,6 +6502,72 @@ function isValidEmail(email) {
|
|
|
6450
6502
|
var reg = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
6451
6503
|
return reg.test(email);
|
|
6452
6504
|
}
|
|
6505
|
+
/**
|
|
6506
|
+
* Convert a given 10-hex number to a lowercase 26-hex string.
|
|
6507
|
+
*
|
|
6508
|
+
* @example
|
|
6509
|
+
* ```js
|
|
6510
|
+
* console.log(convert10To26(1)); // a
|
|
6511
|
+
* console.log(convert10To26(26)); // z
|
|
6512
|
+
* console.log(convert10To26(27)); // aa
|
|
6513
|
+
* console.log(convert10To26(52)); // az
|
|
6514
|
+
* console.log(convert10To26(53)); // ba
|
|
6515
|
+
* ```
|
|
6516
|
+
*
|
|
6517
|
+
* @param {number} num
|
|
6518
|
+
* @returns {string} Return a lowercase 26-hex string.
|
|
6519
|
+
* @category Util
|
|
6520
|
+
*/
|
|
6521
|
+
function convert10To26(num) {
|
|
6522
|
+
var result = '';
|
|
6523
|
+
while (num > 0) {
|
|
6524
|
+
var remainder = num % 26;
|
|
6525
|
+
if (remainder === 0) {
|
|
6526
|
+
remainder = 26;
|
|
6527
|
+
}
|
|
6528
|
+
result = String.fromCharCode(remainder + 96) + result;
|
|
6529
|
+
num = (num - remainder) / 26;
|
|
6530
|
+
}
|
|
6531
|
+
return result;
|
|
6532
|
+
}
|
|
6533
|
+
/**
|
|
6534
|
+
* EN: Get the file type of the url.
|
|
6535
|
+
*
|
|
6536
|
+
* ZH: 获取文件后缀名
|
|
6537
|
+
*
|
|
6538
|
+
* @example
|
|
6539
|
+
* ```js
|
|
6540
|
+
* console.log(getUrlFileType('https://example.com/a/b/c.png')); // png
|
|
6541
|
+
* console.log(getUrlFileType('https://example.com/a/b/c.jpg')); // jpg
|
|
6542
|
+
* console.log(getUrlFileType('https://example.com/a/b/c.jpeg')); // jpeg
|
|
6543
|
+
* console.log(getUrlFileType('/a/b/c.jpeg')); // jpeg
|
|
6544
|
+
* console.log(getUrlFileType('https://example.com/a/b/c.v/a')); // ''
|
|
6545
|
+
* ```
|
|
6546
|
+
*
|
|
6547
|
+
* @param url
|
|
6548
|
+
* @returns
|
|
6549
|
+
* @category URL
|
|
6550
|
+
*/
|
|
6551
|
+
function getUrlFileType(url) {
|
|
6552
|
+
var ret = '';
|
|
6553
|
+
if (typeof url != 'string' || url == '') {
|
|
6554
|
+
return ret;
|
|
6555
|
+
}
|
|
6556
|
+
var type = /\.[^/?#]+$/.exec(url);
|
|
6557
|
+
if (!type) {
|
|
6558
|
+
return ret;
|
|
6559
|
+
}
|
|
6560
|
+
if (type[0].length > 1) {
|
|
6561
|
+
ret = type[0].substring(1);
|
|
6562
|
+
}
|
|
6563
|
+
// if (ret.includes('?')) {
|
|
6564
|
+
// const arr = ret.split('?');
|
|
6565
|
+
// if (arr.length > 0) {
|
|
6566
|
+
// ret = arr[0];
|
|
6567
|
+
// }
|
|
6568
|
+
// }
|
|
6569
|
+
return ret;
|
|
6570
|
+
}
|
|
6453
6571
|
|
|
6454
6572
|
exports.addClass = addClass;
|
|
6455
6573
|
exports.addEvent = addEvent;
|
|
@@ -6460,6 +6578,9 @@ exports.camelCase2Underscore = camelCase2Underscore;
|
|
|
6460
6578
|
exports.camelCaseToKebabCase = camelCaseToKebabCase;
|
|
6461
6579
|
exports.cancelBubble = cancelBubble;
|
|
6462
6580
|
exports.clearHtml = clearHtml;
|
|
6581
|
+
exports.convert10To26 = convert10To26;
|
|
6582
|
+
exports.convertCamelToKebab = convertCamelToKebab;
|
|
6583
|
+
exports.convertCamelToUnder = convertCamelToUnder;
|
|
6463
6584
|
exports.cutCHSString = cutCHSString;
|
|
6464
6585
|
exports.debounce = debounce;
|
|
6465
6586
|
exports.deepCopyObject = deepCopyObject;
|
|
@@ -6467,7 +6588,6 @@ exports.doFn = doFn;
|
|
|
6467
6588
|
exports.floatFixed = floatFixed;
|
|
6468
6589
|
exports.floatToPercent = floatToPercent;
|
|
6469
6590
|
exports.formatDate = formatDate;
|
|
6470
|
-
exports.friendlyInterval = friendlyInterval;
|
|
6471
6591
|
exports.genCustomConsole = genCustomConsole;
|
|
6472
6592
|
exports.genHashCode = genHashCode;
|
|
6473
6593
|
exports.generateRndNum = generateRndNum;
|
|
@@ -6477,15 +6597,18 @@ exports.getCookie = getCookie;
|
|
|
6477
6597
|
exports.getDefineListeners = getDefineListeners;
|
|
6478
6598
|
exports.getDomain = getDomain;
|
|
6479
6599
|
exports.getFileSize = getFileSize;
|
|
6600
|
+
exports.getFriendlyInterval = getFriendlyInterval;
|
|
6480
6601
|
exports.getHashQueryParam = getHashQueryParam;
|
|
6481
6602
|
exports.getLocalStorage = getLocalStorage;
|
|
6482
6603
|
exports.getPerformance = getPerformance;
|
|
6483
6604
|
exports.getQueryParam = getQueryParam;
|
|
6484
6605
|
exports.getSessionStorage = getSessionStorage;
|
|
6606
|
+
exports.getUrlFileType = getUrlFileType;
|
|
6485
6607
|
exports.getUrlParam = getUrlParam;
|
|
6486
6608
|
exports.hasClass = hasClass;
|
|
6487
6609
|
exports.inRate = inRate;
|
|
6488
6610
|
exports.invokeEvent = invokeEvent;
|
|
6611
|
+
exports.isJSONString = isJSONString;
|
|
6489
6612
|
exports.isJsonString = isJsonString;
|
|
6490
6613
|
exports.isNonEmptyArray = isNonEmptyArray;
|
|
6491
6614
|
exports.isNumber = isNumber;
|
|
@@ -6506,6 +6629,7 @@ exports.setCookie = setCookie;
|
|
|
6506
6629
|
exports.setLocalStorage = setLocalStorage;
|
|
6507
6630
|
exports.setSessionStorage = setSessionStorage;
|
|
6508
6631
|
exports.throttle = throttle;
|
|
6632
|
+
exports.truncateZHString = truncateZHString;
|
|
6509
6633
|
exports.updateQueryParam = updateQueryParam;
|
|
6510
6634
|
exports.windowLoaded = windowLoaded;
|
|
6511
6635
|
exports.zAxiosIsValidRes = zAxiosIsValidRes;
|