lyb-js 1.6.40 → 1.6.41

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.
Files changed (2) hide show
  1. package/README.md +4 -40
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -26,53 +26,17 @@ yarn add lyb-js
26
26
 
27
27
  ## 起步
28
28
 
29
- ### 1. 整库引入
29
+ ### 1. 直接导入
30
30
 
31
- 适合快速试用,或者你已经统一通过 `LibJs` 管理工具访问。
31
+ 当前默认已支持按需导入,不需要手动按分类路径引入或做聚合,直接从 `lyb-js` 引入即可。
32
32
 
33
33
  ```ts
34
- import { LibJs } from "lyb-js";
35
-
36
- const type = LibJs.Base.libJsGetDataType("Hello World");
37
- console.log(type); // "string"
38
- ```
39
-
40
- ### 2. 按需引入
41
-
42
- 更推荐。只引入当前用到的方法,路径按分类和文件名区分。
43
-
44
- ```ts
45
- import { libJsGetDataType } from "lyb-js/Base/LibJsGetDataType";
46
- import { libJsCalculateExpression } from "lyb-js/Math/LibJsCalculateExpression";
34
+ import { libJsGetDataType, libJsCalculateExpression } from "lyb-js";
47
35
 
48
36
  console.log(libJsGetDataType([1, 2, 3])); // "array"
49
37
  console.log(libJsCalculateExpression("(1+2)-(3*4)/5")); // 0.6
50
38
  ```
51
39
 
52
- ### 3. 项目内二次封装
53
-
54
- 如果同一批工具会在多个文件重复使用,建议在你自己的 `utils.ts` 中统一导出。
55
-
56
- ```ts
57
- // utils.ts
58
- export * from "lyb-js/Base/LibJsGetDataType";
59
- export * from "lyb-js/Math/LibJsCalculateExpression";
60
- export * from "lyb-js/Browser/LibJsGetRowValue";
61
- ```
62
-
63
- ```ts
64
- // page.ts
65
- import {
66
- libJsGetDataType,
67
- libJsCalculateExpression,
68
- libJsGetRowValue,
69
- } from "./utils";
70
-
71
- console.log(libJsGetDataType({ a: 1 })); // "object"
72
- console.log(libJsCalculateExpression("10/4", 2)); // 2.5
73
- console.log(libJsGetRowValue({ user: { name: "Tom" } }, "user.name")); // "Tom"
74
- ```
75
-
76
40
  ## 使用说明
77
41
 
78
42
  ### 环境说明
@@ -86,7 +50,7 @@ console.log(libJsGetRowValue({ user: { name: "Tom" } }, "user.name")); // "Tom"
86
50
  每个工具章节都遵循同一结构:
87
51
 
88
52
  1. 作用说明
89
- 2. 按需导入
53
+ 2. 导入方式
90
54
  3. 1 到 2 个最常见示例
91
55
 
92
56
  如果你只想找某个工具的导入方式,可以直接看每个章节的第一段代码。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lyb-js",
3
- "version": "1.6.40",
3
+ "version": "1.6.41",
4
4
  "description": "JavaScript utility library",
5
5
  "license": "ISC",
6
6
  "type": "module",