@jhqn/utils-core 0.0.2-beta.5 → 0.0.2-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +46 -38
- package/dist/index.d.cts +23 -4
- package/dist/index.d.mts +23 -4
- package/dist/index.d.ts +23 -4
- package/dist/index.mjs +43 -38
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const detectBrowserEs = require('detect-browser-es');
|
|
4
3
|
const dayjs = require('dayjs');
|
|
5
4
|
const localeData = require('dayjs/plugin/localeData');
|
|
6
5
|
const duration = require('dayjs/plugin/duration');
|
|
@@ -8,6 +7,7 @@ const relativeTime = require('dayjs/plugin/relativeTime');
|
|
|
8
7
|
const customParseFormat = require('dayjs/plugin/customParseFormat');
|
|
9
8
|
const objectSupport = require('dayjs/plugin/objectSupport');
|
|
10
9
|
const zhCN = require('dayjs/locale/zh-cn');
|
|
10
|
+
const detectBrowser = require('detect-browser');
|
|
11
11
|
|
|
12
12
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
13
13
|
|
|
@@ -310,42 +310,6 @@ const hideBankCard = (bankCard) => {
|
|
|
310
310
|
return "";
|
|
311
311
|
};
|
|
312
312
|
|
|
313
|
-
const inBrowser = typeof window !== "undefined";
|
|
314
|
-
const waitTime = (time = 100) => {
|
|
315
|
-
return new Promise((resolve) => {
|
|
316
|
-
setTimeout(() => {
|
|
317
|
-
resolve(true);
|
|
318
|
-
}, time);
|
|
319
|
-
});
|
|
320
|
-
};
|
|
321
|
-
const fixiOSInputAutoZoomIn = () => {
|
|
322
|
-
if (CSS.supports("(font:-apple-system-body) and (-webkit-touch-callout:none) and (-webkit-tap-highlight-color:hotpink)")) {
|
|
323
|
-
const viewport = document.querySelector('meta[name="viewport"]');
|
|
324
|
-
if (viewport !== null) {
|
|
325
|
-
viewport.content = `${viewport.content}, user-scalable=no`;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
};
|
|
329
|
-
const userAgent = inBrowser ? window.navigator.userAgent : "";
|
|
330
|
-
const getHostEnv = () => {
|
|
331
|
-
const ua = userAgent.toLowerCase();
|
|
332
|
-
const zlb = ua.includes("@zlb");
|
|
333
|
-
const zyd = ua.includes("saas");
|
|
334
|
-
const zzd = ua.includes("zhejiang") || ua.includes("tauruszjd");
|
|
335
|
-
const wx = ua.includes("micromessenger");
|
|
336
|
-
const zfb = ua.includes("alipay");
|
|
337
|
-
const mini = ua.includes("miniprogram");
|
|
338
|
-
const info = {
|
|
339
|
-
zlb,
|
|
340
|
-
zyd,
|
|
341
|
-
zzd,
|
|
342
|
-
wx,
|
|
343
|
-
zfb,
|
|
344
|
-
mini
|
|
345
|
-
};
|
|
346
|
-
return info;
|
|
347
|
-
};
|
|
348
|
-
|
|
349
313
|
const parseToJSON = (str, reviver2) => isJSONStr(str) ? JSON.parse(str, reviver2) : null;
|
|
350
314
|
const replacer = (_, value) => {
|
|
351
315
|
if (value instanceof Map) {
|
|
@@ -473,8 +437,49 @@ const attachFmt = (data) => {
|
|
|
473
437
|
return attachList.map(recoverFile);
|
|
474
438
|
};
|
|
475
439
|
|
|
476
|
-
|
|
440
|
+
const inBrowser = typeof window !== "undefined";
|
|
441
|
+
const waitTime = (time = 100) => {
|
|
442
|
+
return new Promise((resolve) => {
|
|
443
|
+
setTimeout(() => {
|
|
444
|
+
resolve(true);
|
|
445
|
+
}, time);
|
|
446
|
+
});
|
|
447
|
+
};
|
|
448
|
+
const fixiOSInputAutoZoomIn = () => {
|
|
449
|
+
if (CSS.supports("(font:-apple-system-body) and (-webkit-touch-callout:none) and (-webkit-tap-highlight-color:hotpink)")) {
|
|
450
|
+
const viewport = document.querySelector('meta[name="viewport"]');
|
|
451
|
+
if (viewport !== null) {
|
|
452
|
+
viewport.content = `${viewport.content}, user-scalable=no`;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
const userAgent = inBrowser ? window.navigator.userAgent : "";
|
|
457
|
+
const getHostEnv = () => {
|
|
458
|
+
const ua = userAgent.toLowerCase();
|
|
459
|
+
const zlb = ua.includes("@zlb");
|
|
460
|
+
const zyd = ua.includes("saas");
|
|
461
|
+
const zzd = ua.includes("zhejiang") || ua.includes("tauruszjd");
|
|
462
|
+
const wx = ua.includes("micromessenger");
|
|
463
|
+
const zfb = ua.includes("alipay");
|
|
464
|
+
const mini = ua.includes("miniprogram");
|
|
465
|
+
const info = {
|
|
466
|
+
zlb,
|
|
467
|
+
zyd,
|
|
468
|
+
zzd,
|
|
469
|
+
wx,
|
|
470
|
+
zfb,
|
|
471
|
+
mini
|
|
472
|
+
};
|
|
473
|
+
return info;
|
|
474
|
+
};
|
|
475
|
+
const XOR_VAL = 1111;
|
|
476
|
+
const getCodeOfTime = (time) => Math.abs(new Date(time).getTime() ^ XOR_VAL);
|
|
477
|
+
const getCodeOfHour = () => getCodeOfTime(`${dateFmt( new Date(), "YYYY-MM-DD HH")}:00:00`);
|
|
478
|
+
const getCodeOfDate = () => getCodeOfTime(dateFmt(/* @__PURE__ */ new Date(), "date"));
|
|
479
|
+
const getCodeOfMonth = () => getCodeOfTime(dateFmt(dayjs__default().endOf("month"), "date"));
|
|
480
|
+
|
|
477
481
|
exports.dayjs = dayjs__default;
|
|
482
|
+
exports.detect = detectBrowser.detect;
|
|
478
483
|
exports.attachFmt = attachFmt;
|
|
479
484
|
exports.camel2Kebab = camel2Kebab;
|
|
480
485
|
exports.camel2Pascal = camel2Pascal;
|
|
@@ -487,6 +492,9 @@ exports.dateFmt = dateFmt;
|
|
|
487
492
|
exports.filterObj = filterObj;
|
|
488
493
|
exports.fixiOSInputAutoZoomIn = fixiOSInputAutoZoomIn;
|
|
489
494
|
exports.getBaseAttachUrl = getBaseAttachUrl;
|
|
495
|
+
exports.getCodeOfDate = getCodeOfDate;
|
|
496
|
+
exports.getCodeOfHour = getCodeOfHour;
|
|
497
|
+
exports.getCodeOfMonth = getCodeOfMonth;
|
|
490
498
|
exports.getHostEnv = getHostEnv;
|
|
491
499
|
exports.getVariableType = getVariableType;
|
|
492
500
|
exports.hideBankCard = hideBankCard;
|
package/dist/index.d.cts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/// <reference types="dayjs/plugin/objectSupport" />
|
|
6
6
|
import { ConfigType } from 'dayjs';
|
|
7
7
|
export { Dayjs, default as dayjs } from 'dayjs';
|
|
8
|
-
export { detect } from 'detect-browser
|
|
8
|
+
export { detect } from 'detect-browser';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* snake2Kebab
|
|
@@ -183,7 +183,10 @@ declare const jGroupC: (...args: any[]) => void;
|
|
|
183
183
|
/**
|
|
184
184
|
* jade console.groupEnd
|
|
185
185
|
*/
|
|
186
|
-
declare const jGroupE:
|
|
186
|
+
declare const jGroupE: {
|
|
187
|
+
(): void;
|
|
188
|
+
(): void;
|
|
189
|
+
};
|
|
187
190
|
/**
|
|
188
191
|
* jade console.time
|
|
189
192
|
* @param str
|
|
@@ -197,7 +200,10 @@ declare const jTimeEnd: (str: string) => void;
|
|
|
197
200
|
/**
|
|
198
201
|
* jade console.clear
|
|
199
202
|
*/
|
|
200
|
-
declare const jClear:
|
|
203
|
+
declare const jClear: {
|
|
204
|
+
(): void;
|
|
205
|
+
(): void;
|
|
206
|
+
};
|
|
201
207
|
|
|
202
208
|
/**
|
|
203
209
|
* 不连续打印相同的值
|
|
@@ -359,6 +365,19 @@ declare const userAgent: string;
|
|
|
359
365
|
*/
|
|
360
366
|
declare const getHostEnv: () => HostEnv;
|
|
361
367
|
|
|
368
|
+
/**
|
|
369
|
+
* 获取当小时的时间戳的异或值的绝对值, 当小时内获取的值是唯一的
|
|
370
|
+
*/
|
|
371
|
+
declare const getCodeOfHour: () => number;
|
|
372
|
+
/**
|
|
373
|
+
* 获取当天的时间戳的异或值的绝对值, 当天内获取的值是唯一的
|
|
374
|
+
*/
|
|
375
|
+
declare const getCodeOfDate: () => number;
|
|
376
|
+
/**
|
|
377
|
+
* 获取当月的时间戳的异或值的绝对值, 当月内获取的值是唯一的
|
|
378
|
+
*/
|
|
379
|
+
declare const getCodeOfMonth: () => number;
|
|
380
|
+
|
|
362
381
|
/**
|
|
363
382
|
* Json字符串转对象
|
|
364
383
|
* @param str
|
|
@@ -722,4 +741,4 @@ declare const nonASCII: (text: string) => boolean;
|
|
|
722
741
|
*/
|
|
723
742
|
declare const isValidFileType: (file: File, type: string) => boolean;
|
|
724
743
|
|
|
725
|
-
export { type MaybeArray, type NullOrUndefinable, type Nullable, type Numeric, type PageRes, type PageResData, type Res, type UnDef, type Undefinable, attachFmt, camel2Kebab, camel2Pascal, camel2Snake, camel2Title, checkImg, currencyFmt, dateDuration, dateFmt, filterObj, fixiOSInputAutoZoomIn, getBaseAttachUrl, getHostEnv, getVariableType, hideBankCard, hideCardNo, hideEmail, hideFirstName, hideHead, hideMiddle, hideName, hidePhone, hideSurname, hideTail, hideThird, inBrowser, isArrStr, isArray, isBlob, isBoolean, isDate, isDef, isEmail, isEmpty, isError, isFile, isFunction, isIdCard, isJSONStr, isMap, isNull, isNumber, isNumeric, isObject, isPhone, isPromise, isRegExp, isSet, isString, isSymbol, isTel, isURL, isUndefined, isValidArrRes, isValidFileType, isValidKey, isValidPageRes, isValidRes, isValidResCode, isWeakMap, isWeakSet, jClear, jDebug, jError, jGroup, jGroupC, jGroupE, jInfo, jLog, jLogDedupe, jLogOnce, jTime, jTimeEnd, jWarn, kebab2Camel, kebab2Pascal, kebab2Snake, kebab2Title, nonASCII, parseToJSON, pascal2Camel, pascal2Kebab, pascal2Snake, pascal2Title, recoverFile, replacer, resUrl, reviver, setBaseAttachUrl, snake2Camel, snake2Kebab, snake2Pascal, snake2Title, title2Camel, title2Kebab, title2Pascal, title2Snake, toThousands, userAgent, waitTime };
|
|
744
|
+
export { type MaybeArray, type NullOrUndefinable, type Nullable, type Numeric, type PageRes, type PageResData, type Res, type UnDef, type Undefinable, attachFmt, camel2Kebab, camel2Pascal, camel2Snake, camel2Title, checkImg, currencyFmt, dateDuration, dateFmt, filterObj, fixiOSInputAutoZoomIn, getBaseAttachUrl, getCodeOfDate, getCodeOfHour, getCodeOfMonth, getHostEnv, getVariableType, hideBankCard, hideCardNo, hideEmail, hideFirstName, hideHead, hideMiddle, hideName, hidePhone, hideSurname, hideTail, hideThird, inBrowser, isArrStr, isArray, isBlob, isBoolean, isDate, isDef, isEmail, isEmpty, isError, isFile, isFunction, isIdCard, isJSONStr, isMap, isNull, isNumber, isNumeric, isObject, isPhone, isPromise, isRegExp, isSet, isString, isSymbol, isTel, isURL, isUndefined, isValidArrRes, isValidFileType, isValidKey, isValidPageRes, isValidRes, isValidResCode, isWeakMap, isWeakSet, jClear, jDebug, jError, jGroup, jGroupC, jGroupE, jInfo, jLog, jLogDedupe, jLogOnce, jTime, jTimeEnd, jWarn, kebab2Camel, kebab2Pascal, kebab2Snake, kebab2Title, nonASCII, parseToJSON, pascal2Camel, pascal2Kebab, pascal2Snake, pascal2Title, recoverFile, replacer, resUrl, reviver, setBaseAttachUrl, snake2Camel, snake2Kebab, snake2Pascal, snake2Title, title2Camel, title2Kebab, title2Pascal, title2Snake, toThousands, userAgent, waitTime };
|
package/dist/index.d.mts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/// <reference types="dayjs/plugin/objectSupport" />
|
|
6
6
|
import { ConfigType } from 'dayjs';
|
|
7
7
|
export { Dayjs, default as dayjs } from 'dayjs';
|
|
8
|
-
export { detect } from 'detect-browser
|
|
8
|
+
export { detect } from 'detect-browser';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* snake2Kebab
|
|
@@ -183,7 +183,10 @@ declare const jGroupC: (...args: any[]) => void;
|
|
|
183
183
|
/**
|
|
184
184
|
* jade console.groupEnd
|
|
185
185
|
*/
|
|
186
|
-
declare const jGroupE:
|
|
186
|
+
declare const jGroupE: {
|
|
187
|
+
(): void;
|
|
188
|
+
(): void;
|
|
189
|
+
};
|
|
187
190
|
/**
|
|
188
191
|
* jade console.time
|
|
189
192
|
* @param str
|
|
@@ -197,7 +200,10 @@ declare const jTimeEnd: (str: string) => void;
|
|
|
197
200
|
/**
|
|
198
201
|
* jade console.clear
|
|
199
202
|
*/
|
|
200
|
-
declare const jClear:
|
|
203
|
+
declare const jClear: {
|
|
204
|
+
(): void;
|
|
205
|
+
(): void;
|
|
206
|
+
};
|
|
201
207
|
|
|
202
208
|
/**
|
|
203
209
|
* 不连续打印相同的值
|
|
@@ -359,6 +365,19 @@ declare const userAgent: string;
|
|
|
359
365
|
*/
|
|
360
366
|
declare const getHostEnv: () => HostEnv;
|
|
361
367
|
|
|
368
|
+
/**
|
|
369
|
+
* 获取当小时的时间戳的异或值的绝对值, 当小时内获取的值是唯一的
|
|
370
|
+
*/
|
|
371
|
+
declare const getCodeOfHour: () => number;
|
|
372
|
+
/**
|
|
373
|
+
* 获取当天的时间戳的异或值的绝对值, 当天内获取的值是唯一的
|
|
374
|
+
*/
|
|
375
|
+
declare const getCodeOfDate: () => number;
|
|
376
|
+
/**
|
|
377
|
+
* 获取当月的时间戳的异或值的绝对值, 当月内获取的值是唯一的
|
|
378
|
+
*/
|
|
379
|
+
declare const getCodeOfMonth: () => number;
|
|
380
|
+
|
|
362
381
|
/**
|
|
363
382
|
* Json字符串转对象
|
|
364
383
|
* @param str
|
|
@@ -722,4 +741,4 @@ declare const nonASCII: (text: string) => boolean;
|
|
|
722
741
|
*/
|
|
723
742
|
declare const isValidFileType: (file: File, type: string) => boolean;
|
|
724
743
|
|
|
725
|
-
export { type MaybeArray, type NullOrUndefinable, type Nullable, type Numeric, type PageRes, type PageResData, type Res, type UnDef, type Undefinable, attachFmt, camel2Kebab, camel2Pascal, camel2Snake, camel2Title, checkImg, currencyFmt, dateDuration, dateFmt, filterObj, fixiOSInputAutoZoomIn, getBaseAttachUrl, getHostEnv, getVariableType, hideBankCard, hideCardNo, hideEmail, hideFirstName, hideHead, hideMiddle, hideName, hidePhone, hideSurname, hideTail, hideThird, inBrowser, isArrStr, isArray, isBlob, isBoolean, isDate, isDef, isEmail, isEmpty, isError, isFile, isFunction, isIdCard, isJSONStr, isMap, isNull, isNumber, isNumeric, isObject, isPhone, isPromise, isRegExp, isSet, isString, isSymbol, isTel, isURL, isUndefined, isValidArrRes, isValidFileType, isValidKey, isValidPageRes, isValidRes, isValidResCode, isWeakMap, isWeakSet, jClear, jDebug, jError, jGroup, jGroupC, jGroupE, jInfo, jLog, jLogDedupe, jLogOnce, jTime, jTimeEnd, jWarn, kebab2Camel, kebab2Pascal, kebab2Snake, kebab2Title, nonASCII, parseToJSON, pascal2Camel, pascal2Kebab, pascal2Snake, pascal2Title, recoverFile, replacer, resUrl, reviver, setBaseAttachUrl, snake2Camel, snake2Kebab, snake2Pascal, snake2Title, title2Camel, title2Kebab, title2Pascal, title2Snake, toThousands, userAgent, waitTime };
|
|
744
|
+
export { type MaybeArray, type NullOrUndefinable, type Nullable, type Numeric, type PageRes, type PageResData, type Res, type UnDef, type Undefinable, attachFmt, camel2Kebab, camel2Pascal, camel2Snake, camel2Title, checkImg, currencyFmt, dateDuration, dateFmt, filterObj, fixiOSInputAutoZoomIn, getBaseAttachUrl, getCodeOfDate, getCodeOfHour, getCodeOfMonth, getHostEnv, getVariableType, hideBankCard, hideCardNo, hideEmail, hideFirstName, hideHead, hideMiddle, hideName, hidePhone, hideSurname, hideTail, hideThird, inBrowser, isArrStr, isArray, isBlob, isBoolean, isDate, isDef, isEmail, isEmpty, isError, isFile, isFunction, isIdCard, isJSONStr, isMap, isNull, isNumber, isNumeric, isObject, isPhone, isPromise, isRegExp, isSet, isString, isSymbol, isTel, isURL, isUndefined, isValidArrRes, isValidFileType, isValidKey, isValidPageRes, isValidRes, isValidResCode, isWeakMap, isWeakSet, jClear, jDebug, jError, jGroup, jGroupC, jGroupE, jInfo, jLog, jLogDedupe, jLogOnce, jTime, jTimeEnd, jWarn, kebab2Camel, kebab2Pascal, kebab2Snake, kebab2Title, nonASCII, parseToJSON, pascal2Camel, pascal2Kebab, pascal2Snake, pascal2Title, recoverFile, replacer, resUrl, reviver, setBaseAttachUrl, snake2Camel, snake2Kebab, snake2Pascal, snake2Title, title2Camel, title2Kebab, title2Pascal, title2Snake, toThousands, userAgent, waitTime };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/// <reference types="dayjs/plugin/objectSupport" />
|
|
6
6
|
import { ConfigType } from 'dayjs';
|
|
7
7
|
export { Dayjs, default as dayjs } from 'dayjs';
|
|
8
|
-
export { detect } from 'detect-browser
|
|
8
|
+
export { detect } from 'detect-browser';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* snake2Kebab
|
|
@@ -183,7 +183,10 @@ declare const jGroupC: (...args: any[]) => void;
|
|
|
183
183
|
/**
|
|
184
184
|
* jade console.groupEnd
|
|
185
185
|
*/
|
|
186
|
-
declare const jGroupE:
|
|
186
|
+
declare const jGroupE: {
|
|
187
|
+
(): void;
|
|
188
|
+
(): void;
|
|
189
|
+
};
|
|
187
190
|
/**
|
|
188
191
|
* jade console.time
|
|
189
192
|
* @param str
|
|
@@ -197,7 +200,10 @@ declare const jTimeEnd: (str: string) => void;
|
|
|
197
200
|
/**
|
|
198
201
|
* jade console.clear
|
|
199
202
|
*/
|
|
200
|
-
declare const jClear:
|
|
203
|
+
declare const jClear: {
|
|
204
|
+
(): void;
|
|
205
|
+
(): void;
|
|
206
|
+
};
|
|
201
207
|
|
|
202
208
|
/**
|
|
203
209
|
* 不连续打印相同的值
|
|
@@ -359,6 +365,19 @@ declare const userAgent: string;
|
|
|
359
365
|
*/
|
|
360
366
|
declare const getHostEnv: () => HostEnv;
|
|
361
367
|
|
|
368
|
+
/**
|
|
369
|
+
* 获取当小时的时间戳的异或值的绝对值, 当小时内获取的值是唯一的
|
|
370
|
+
*/
|
|
371
|
+
declare const getCodeOfHour: () => number;
|
|
372
|
+
/**
|
|
373
|
+
* 获取当天的时间戳的异或值的绝对值, 当天内获取的值是唯一的
|
|
374
|
+
*/
|
|
375
|
+
declare const getCodeOfDate: () => number;
|
|
376
|
+
/**
|
|
377
|
+
* 获取当月的时间戳的异或值的绝对值, 当月内获取的值是唯一的
|
|
378
|
+
*/
|
|
379
|
+
declare const getCodeOfMonth: () => number;
|
|
380
|
+
|
|
362
381
|
/**
|
|
363
382
|
* Json字符串转对象
|
|
364
383
|
* @param str
|
|
@@ -722,4 +741,4 @@ declare const nonASCII: (text: string) => boolean;
|
|
|
722
741
|
*/
|
|
723
742
|
declare const isValidFileType: (file: File, type: string) => boolean;
|
|
724
743
|
|
|
725
|
-
export { type MaybeArray, type NullOrUndefinable, type Nullable, type Numeric, type PageRes, type PageResData, type Res, type UnDef, type Undefinable, attachFmt, camel2Kebab, camel2Pascal, camel2Snake, camel2Title, checkImg, currencyFmt, dateDuration, dateFmt, filterObj, fixiOSInputAutoZoomIn, getBaseAttachUrl, getHostEnv, getVariableType, hideBankCard, hideCardNo, hideEmail, hideFirstName, hideHead, hideMiddle, hideName, hidePhone, hideSurname, hideTail, hideThird, inBrowser, isArrStr, isArray, isBlob, isBoolean, isDate, isDef, isEmail, isEmpty, isError, isFile, isFunction, isIdCard, isJSONStr, isMap, isNull, isNumber, isNumeric, isObject, isPhone, isPromise, isRegExp, isSet, isString, isSymbol, isTel, isURL, isUndefined, isValidArrRes, isValidFileType, isValidKey, isValidPageRes, isValidRes, isValidResCode, isWeakMap, isWeakSet, jClear, jDebug, jError, jGroup, jGroupC, jGroupE, jInfo, jLog, jLogDedupe, jLogOnce, jTime, jTimeEnd, jWarn, kebab2Camel, kebab2Pascal, kebab2Snake, kebab2Title, nonASCII, parseToJSON, pascal2Camel, pascal2Kebab, pascal2Snake, pascal2Title, recoverFile, replacer, resUrl, reviver, setBaseAttachUrl, snake2Camel, snake2Kebab, snake2Pascal, snake2Title, title2Camel, title2Kebab, title2Pascal, title2Snake, toThousands, userAgent, waitTime };
|
|
744
|
+
export { type MaybeArray, type NullOrUndefinable, type Nullable, type Numeric, type PageRes, type PageResData, type Res, type UnDef, type Undefinable, attachFmt, camel2Kebab, camel2Pascal, camel2Snake, camel2Title, checkImg, currencyFmt, dateDuration, dateFmt, filterObj, fixiOSInputAutoZoomIn, getBaseAttachUrl, getCodeOfDate, getCodeOfHour, getCodeOfMonth, getHostEnv, getVariableType, hideBankCard, hideCardNo, hideEmail, hideFirstName, hideHead, hideMiddle, hideName, hidePhone, hideSurname, hideTail, hideThird, inBrowser, isArrStr, isArray, isBlob, isBoolean, isDate, isDef, isEmail, isEmpty, isError, isFile, isFunction, isIdCard, isJSONStr, isMap, isNull, isNumber, isNumeric, isObject, isPhone, isPromise, isRegExp, isSet, isString, isSymbol, isTel, isURL, isUndefined, isValidArrRes, isValidFileType, isValidKey, isValidPageRes, isValidRes, isValidResCode, isWeakMap, isWeakSet, jClear, jDebug, jError, jGroup, jGroupC, jGroupE, jInfo, jLog, jLogDedupe, jLogOnce, jTime, jTimeEnd, jWarn, kebab2Camel, kebab2Pascal, kebab2Snake, kebab2Title, nonASCII, parseToJSON, pascal2Camel, pascal2Kebab, pascal2Snake, pascal2Title, recoverFile, replacer, resUrl, reviver, setBaseAttachUrl, snake2Camel, snake2Kebab, snake2Pascal, snake2Title, title2Camel, title2Kebab, title2Pascal, title2Snake, toThousands, userAgent, waitTime };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { detect } from 'detect-browser-es';
|
|
2
1
|
import dayjs from 'dayjs';
|
|
3
2
|
export { default as dayjs } from 'dayjs';
|
|
4
3
|
import localeData from 'dayjs/plugin/localeData';
|
|
@@ -7,6 +6,7 @@ import relativeTime from 'dayjs/plugin/relativeTime';
|
|
|
7
6
|
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
8
7
|
import objectSupport from 'dayjs/plugin/objectSupport';
|
|
9
8
|
import zhCN from 'dayjs/locale/zh-cn';
|
|
9
|
+
export { detect } from 'detect-browser';
|
|
10
10
|
|
|
11
11
|
const snake2Kebab = (str) => str.replace(/_([a-z])/g, (_, letter) => `-${letter.toLowerCase()}`);
|
|
12
12
|
const snake2Pascal = (str) => str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase()).replace(/^[a-z]/, (letter) => letter.toUpperCase());
|
|
@@ -299,42 +299,6 @@ const hideBankCard = (bankCard) => {
|
|
|
299
299
|
return "";
|
|
300
300
|
};
|
|
301
301
|
|
|
302
|
-
const inBrowser = typeof window !== "undefined";
|
|
303
|
-
const waitTime = (time = 100) => {
|
|
304
|
-
return new Promise((resolve) => {
|
|
305
|
-
setTimeout(() => {
|
|
306
|
-
resolve(true);
|
|
307
|
-
}, time);
|
|
308
|
-
});
|
|
309
|
-
};
|
|
310
|
-
const fixiOSInputAutoZoomIn = () => {
|
|
311
|
-
if (CSS.supports("(font:-apple-system-body) and (-webkit-touch-callout:none) and (-webkit-tap-highlight-color:hotpink)")) {
|
|
312
|
-
const viewport = document.querySelector('meta[name="viewport"]');
|
|
313
|
-
if (viewport !== null) {
|
|
314
|
-
viewport.content = `${viewport.content}, user-scalable=no`;
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
};
|
|
318
|
-
const userAgent = inBrowser ? window.navigator.userAgent : "";
|
|
319
|
-
const getHostEnv = () => {
|
|
320
|
-
const ua = userAgent.toLowerCase();
|
|
321
|
-
const zlb = ua.includes("@zlb");
|
|
322
|
-
const zyd = ua.includes("saas");
|
|
323
|
-
const zzd = ua.includes("zhejiang") || ua.includes("tauruszjd");
|
|
324
|
-
const wx = ua.includes("micromessenger");
|
|
325
|
-
const zfb = ua.includes("alipay");
|
|
326
|
-
const mini = ua.includes("miniprogram");
|
|
327
|
-
const info = {
|
|
328
|
-
zlb,
|
|
329
|
-
zyd,
|
|
330
|
-
zzd,
|
|
331
|
-
wx,
|
|
332
|
-
zfb,
|
|
333
|
-
mini
|
|
334
|
-
};
|
|
335
|
-
return info;
|
|
336
|
-
};
|
|
337
|
-
|
|
338
302
|
const parseToJSON = (str, reviver2) => isJSONStr(str) ? JSON.parse(str, reviver2) : null;
|
|
339
303
|
const replacer = (_, value) => {
|
|
340
304
|
if (value instanceof Map) {
|
|
@@ -462,4 +426,45 @@ const attachFmt = (data) => {
|
|
|
462
426
|
return attachList.map(recoverFile);
|
|
463
427
|
};
|
|
464
428
|
|
|
465
|
-
|
|
429
|
+
const inBrowser = typeof window !== "undefined";
|
|
430
|
+
const waitTime = (time = 100) => {
|
|
431
|
+
return new Promise((resolve) => {
|
|
432
|
+
setTimeout(() => {
|
|
433
|
+
resolve(true);
|
|
434
|
+
}, time);
|
|
435
|
+
});
|
|
436
|
+
};
|
|
437
|
+
const fixiOSInputAutoZoomIn = () => {
|
|
438
|
+
if (CSS.supports("(font:-apple-system-body) and (-webkit-touch-callout:none) and (-webkit-tap-highlight-color:hotpink)")) {
|
|
439
|
+
const viewport = document.querySelector('meta[name="viewport"]');
|
|
440
|
+
if (viewport !== null) {
|
|
441
|
+
viewport.content = `${viewport.content}, user-scalable=no`;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
const userAgent = inBrowser ? window.navigator.userAgent : "";
|
|
446
|
+
const getHostEnv = () => {
|
|
447
|
+
const ua = userAgent.toLowerCase();
|
|
448
|
+
const zlb = ua.includes("@zlb");
|
|
449
|
+
const zyd = ua.includes("saas");
|
|
450
|
+
const zzd = ua.includes("zhejiang") || ua.includes("tauruszjd");
|
|
451
|
+
const wx = ua.includes("micromessenger");
|
|
452
|
+
const zfb = ua.includes("alipay");
|
|
453
|
+
const mini = ua.includes("miniprogram");
|
|
454
|
+
const info = {
|
|
455
|
+
zlb,
|
|
456
|
+
zyd,
|
|
457
|
+
zzd,
|
|
458
|
+
wx,
|
|
459
|
+
zfb,
|
|
460
|
+
mini
|
|
461
|
+
};
|
|
462
|
+
return info;
|
|
463
|
+
};
|
|
464
|
+
const XOR_VAL = 1111;
|
|
465
|
+
const getCodeOfTime = (time) => Math.abs(new Date(time).getTime() ^ XOR_VAL);
|
|
466
|
+
const getCodeOfHour = () => getCodeOfTime(`${dateFmt( new Date(), "YYYY-MM-DD HH")}:00:00`);
|
|
467
|
+
const getCodeOfDate = () => getCodeOfTime(dateFmt(/* @__PURE__ */ new Date(), "date"));
|
|
468
|
+
const getCodeOfMonth = () => getCodeOfTime(dateFmt(dayjs().endOf("month"), "date"));
|
|
469
|
+
|
|
470
|
+
export { attachFmt, camel2Kebab, camel2Pascal, camel2Snake, camel2Title, checkImg, currencyFmt, dateDuration, dateFmt, filterObj, fixiOSInputAutoZoomIn, getBaseAttachUrl, getCodeOfDate, getCodeOfHour, getCodeOfMonth, getHostEnv, getVariableType, hideBankCard, hideCardNo, hideEmail, hideFirstName, hideHead, hideMiddle, hideName, hidePhone, hideSurname, hideTail, hideThird, inBrowser, isArrStr, isArray, isBlob, isBoolean, isDate, isDef, isEmail, isEmpty, isError, isFile, isFunction, isIdCard, isJSONStr, isMap, isNull, isNumber, isNumeric, isObject, isPhone, isPromise, isRegExp, isSet, isString, isSymbol, isTel, isURL, isUndefined, isValidArrRes, isValidFileType, isValidKey, isValidPageRes, isValidRes, isValidResCode, isWeakMap, isWeakSet, jClear, jDebug, jError, jGroup, jGroupC, jGroupE, jInfo, jLog, jLogDedupe, jLogOnce, jTime, jTimeEnd, jWarn, kebab2Camel, kebab2Pascal, kebab2Snake, kebab2Title, nonASCII, parseToJSON, pascal2Camel, pascal2Kebab, pascal2Snake, pascal2Title, recoverFile, replacer, resUrl, reviver, setBaseAttachUrl, snake2Camel, snake2Kebab, snake2Pascal, snake2Title, title2Camel, title2Kebab, title2Pascal, title2Snake, toThousands, userAgent, waitTime };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jhqn/utils-core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.2-beta.
|
|
4
|
+
"version": "0.0.2-beta.7",
|
|
5
5
|
"author": "jade-gjz <jiangang.zhang@jaderd.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/jaderd-jh/utils/tree/main/packages/core#readme",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"dayjs": "^1.11.10",
|
|
41
|
-
"detect-browser
|
|
41
|
+
"detect-browser": "^5.3.0"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"test": "vitest",
|