lyb-js 1.6.36 → 1.6.38

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.
@@ -1,8 +1,16 @@
1
1
  import dayjs from "dayjs";
2
2
  import duration from "dayjs/plugin/duration.js";
3
- dayjs.extend(duration);
3
+ let hasExtendedDuration = false;
4
+ const ensureDurationPlugin = () => {
5
+ if (hasExtendedDuration) {
6
+ return;
7
+ }
8
+ dayjs.extend(duration);
9
+ hasExtendedDuration = true;
10
+ };
4
11
  /** @description 将秒数格式化为中文时间描述 */
5
12
  export const libJsSecondsFormatterChinese = (seconds) => {
13
+ ensureDurationPlugin();
6
14
  const currentDuration = dayjs.duration(seconds, "seconds");
7
15
  const years = Math.floor(currentDuration.asYears());
8
16
  const months = Math.floor(currentDuration.asMonths() % 12);
@@ -1,8 +1,16 @@
1
1
  import dayjs from "dayjs";
2
2
  import duration from "dayjs/plugin/duration.js";
3
- dayjs.extend(duration);
3
+ let hasExtendedDuration = false;
4
+ const ensureDurationPlugin = () => {
5
+ if (hasExtendedDuration) {
6
+ return;
7
+ }
8
+ dayjs.extend(duration);
9
+ hasExtendedDuration = true;
10
+ };
4
11
  /** @description 倒计时,keepUnit 为保留单位时不再使用更高单位进位 */
5
12
  export const libJsCountdown = (endTime, keepUnit) => {
13
+ ensureDurationPlugin();
6
14
  const startTime = dayjs();
7
15
  const diff = dayjs(endTime).diff(startTime);
8
16
  const time = dayjs.duration(diff);
package/index.d.ts CHANGED
@@ -1,12 +1,3 @@
1
- import * as Base from "./Base/index.js";
2
- import * as Browser from "./Browser/index.js";
3
- import * as Data from "./Data/index.js";
4
- import * as File from "./File/index.js";
5
- import * as Formatter from "./Formatter/index.js";
6
- import * as Math from "./Math/index.js";
7
- import * as Misc from "./Misc/index.js";
8
- import * as Random from "./Random/index.js";
9
- import * as Time from "./Time/index.js";
10
1
  export * from "./Base/index.js";
11
2
  export * from "./Browser/index.js";
12
3
  export * from "./Data/index.js";
@@ -16,15 +7,4 @@ export * from "./Math/index.js";
16
7
  export * from "./Misc/index.js";
17
8
  export * from "./Random/index.js";
18
9
  export * from "./Time/index.js";
19
- export { Base, Browser, Data, File, Formatter, Math, Misc, Random, Time };
20
- export declare const LibJs: {
21
- Base: typeof Base;
22
- Browser: typeof Browser;
23
- Data: typeof Data;
24
- File: typeof File;
25
- Formatter: typeof Formatter;
26
- Math: typeof Math;
27
- Misc: typeof Misc;
28
- Random: typeof Random;
29
- Time: typeof Time;
30
- };
10
+ export { Base, Browser, Data, File, Formatter, Math, Misc, Random, Time, LibJs, } from "./legacy.js";
package/index.js CHANGED
@@ -1,12 +1,3 @@
1
- import * as Base from "./Base/index.js";
2
- import * as Browser from "./Browser/index.js";
3
- import * as Data from "./Data/index.js";
4
- import * as File from "./File/index.js";
5
- import * as Formatter from "./Formatter/index.js";
6
- import * as Math from "./Math/index.js";
7
- import * as Misc from "./Misc/index.js";
8
- import * as Random from "./Random/index.js";
9
- import * as Time from "./Time/index.js";
10
1
  export * from "./Base/index.js";
11
2
  export * from "./Browser/index.js";
12
3
  export * from "./Data/index.js";
@@ -16,15 +7,4 @@ export * from "./Math/index.js";
16
7
  export * from "./Misc/index.js";
17
8
  export * from "./Random/index.js";
18
9
  export * from "./Time/index.js";
19
- export { Base, Browser, Data, File, Formatter, Math, Misc, Random, Time };
20
- export const LibJs = {
21
- Base,
22
- Browser,
23
- Data,
24
- File,
25
- Formatter,
26
- Math,
27
- Misc,
28
- Random,
29
- Time,
30
- };
10
+ export { Base, Browser, Data, File, Formatter, Math, Misc, Random, Time, LibJs, } from "./legacy.js";
package/legacy.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ import * as Base from "./Base/index.js";
2
+ import * as Browser from "./Browser/index.js";
3
+ import * as Data from "./Data/index.js";
4
+ import * as File from "./File/index.js";
5
+ import * as Formatter from "./Formatter/index.js";
6
+ import * as Math from "./Math/index.js";
7
+ import * as Misc from "./Misc/index.js";
8
+ import * as Random from "./Random/index.js";
9
+ import * as Time from "./Time/index.js";
10
+ export { Base, Browser, Data, File, Formatter, Math, Misc, Random, Time };
11
+ export declare const LibJs: {
12
+ Base: typeof Base;
13
+ Browser: typeof Browser;
14
+ Data: typeof Data;
15
+ File: typeof File;
16
+ Formatter: typeof Formatter;
17
+ Math: typeof Math;
18
+ Misc: typeof Misc;
19
+ Random: typeof Random;
20
+ Time: typeof Time;
21
+ };
package/legacy.js ADDED
@@ -0,0 +1,21 @@
1
+ import * as Base from "./Base/index.js";
2
+ import * as Browser from "./Browser/index.js";
3
+ import * as Data from "./Data/index.js";
4
+ import * as File from "./File/index.js";
5
+ import * as Formatter from "./Formatter/index.js";
6
+ import * as Math from "./Math/index.js";
7
+ import * as Misc from "./Misc/index.js";
8
+ import * as Random from "./Random/index.js";
9
+ import * as Time from "./Time/index.js";
10
+ export { Base, Browser, Data, File, Formatter, Math, Misc, Random, Time };
11
+ export const LibJs = {
12
+ Base,
13
+ Browser,
14
+ Data,
15
+ File,
16
+ Formatter,
17
+ Math,
18
+ Misc,
19
+ Random,
20
+ Time,
21
+ };
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "lyb-js",
3
- "version": "1.6.36",
3
+ "version": "1.6.38",
4
4
  "description": "JavaScript utility library",
5
5
  "license": "ISC",
6
6
  "type": "module",
7
+ "sideEffects": false,
7
8
  "types": "./index.d.ts",
8
9
  "main": "./index.js",
9
10
  "module": "./index.js",
@@ -23,6 +24,7 @@
23
24
  ],
24
25
  "exports": {
25
26
  ".": "./index.js",
27
+ "./legacy": "./legacy.js",
26
28
  "./Base": "./Base/index.js",
27
29
  "./Base/*": "./Base/*",
28
30
  "./Browser": "./Browser/index.js",