Skip to content

Commit

Permalink
思考计划: 删除所有lodash-es和es-toolkit中已经有的基础函数
Browse files Browse the repository at this point in the history
  • Loading branch information
chenbimo committed Sep 16, 2024
1 parent ab8c290 commit e74bf51
Show file tree
Hide file tree
Showing 139 changed files with 206 additions and 3,158 deletions.
26 changes: 19 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,28 @@ console.log(validNumber('1.2.')); // 1.20
12. 能用 `const` 定义的地方尽量用 `const`
13. 不能使用 `var` 定义变量。
14. `不要炫技`,用尽量简单易懂的方式,宁愿多写几行,也不要增加理解难度。
15. 尽量不要函数引入函数,每个函数尽量独立,不依赖其他函数。
16. 除导出函数外,其余函数不能使用多行注释,只能使用单行注释。
17. 一个工具函数的代码行数不超过500行(`特殊情况例外`)。
18. 代码风格以笔者规范为准(会进行沟通),不能擅自修改代码规范。
19. 笔者会对所有提交的代码进行审核,并根据情况增删代码。
20. 如若本项目产生收益,仓库所有者(陈随易)拥有对收益的完全支配权。
21. 如果提交代码,便视为同意以上守则,请查阅并确认后参与。
15. `es-toolkit``lodash` 已经存在的函数不要重复实现。
16. `只有几行代码` 的函数不要添加进来。
17. 尽量不要函数引入函数,每个函数尽量独立,不依赖其他函数。
18. 除导出函数外,其余函数不能使用多行注释,只能使用单行注释。
19. 一个工具函数的代码行数不超过500行(`特殊情况例外`)。
20. 代码风格以笔者规范为准(会进行沟通),不能擅自修改代码规范。
21. 笔者会对所有提交的代码进行审核,并根据情况增删代码。
22. 如若本项目产生收益,仓库所有者(陈随易)拥有对收益的完全支配权。
23. 如果提交代码,便视为同意以上守则,请查阅并确认后参与。

### **函数开发说明**

目前用到的依赖如下:

1. lodash-es
2. es-toolkit
3. date-fns

因为es-toolkit还在开发中,所以部分函数用lodash-es中的。

最终目标是所有基础函数都用es-toolkit中的。

`lib` 目录下,每一个目录是一个函数类型集合。

每个目录下,不能再创建目录,只能创建函数文件。
Expand Down
9 changes: 9 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"baseUrl": "./",
"paths": {}
},
"exclude": ["**/node_modules/*", "dist", "**/dist/*", "dist", "dist*", "node_modules", "release", "cache", ".git", ".cache", "logs"]
}
8 changes: 2 additions & 6 deletions lib/address/areaMatch.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
/**
* 省、市、区提取
* @author 陈随易 <https://chensuiyi.me>
* @category address
* @alias yd_address_areaMatch
* @category address
* @param {string} address 地址字符串
* @returns {Array} 省市区
* @author 陈随易 <https://chensuiyi.me>
* @example
* const address1 = "北京市朝阳区建国门外大街";
* const addressComponents1 = extractAddressComponents(address1);
* console.log(addressComponents1); // 输出: { province: '北京', city: '朝阳', region: '建国门外大街' }
*
* @example
* const address2 = "广东省深圳市南山区科技园";
* const addressComponents2 = extractAddressComponents(address2);
* console.log(addressComponents2); // 输出: { province: '广东', city: '深圳', region: '南山区科技园' }
*
* @example
* const address3 = "上海市浦东新区张江高科技园区";
* const addressComponents3 = extractAddressComponents(address3);
* console.log(addressComponents3); // 输出: { province: '上海', city: '浦东新区', region: '张江高科技园区' }
*
* @example
* const address4 = "黑龙江省哈尔滨市道里区";
* const addressComponents4 = extractAddressComponents(address4);
* console.log(addressComponents4); // 输出: { province: '黑龙江', city: '哈尔滨', region: '道里区' }
*
* @example
* const address5 = "错误地址";
* const addressComponents5 = extractAddressComponents(address5);
Expand Down
40 changes: 0 additions & 40 deletions lib/array/chunk.js

This file was deleted.

15 changes: 0 additions & 15 deletions lib/array/chunk.test.js

This file was deleted.

28 changes: 0 additions & 28 deletions lib/array/concat.js

This file was deleted.

16 changes: 0 additions & 16 deletions lib/array/filterBy.js

This file was deleted.

19 changes: 0 additions & 19 deletions lib/array/filterBy.test.js

This file was deleted.

24 changes: 0 additions & 24 deletions lib/array/findIndex.js

This file was deleted.

24 changes: 0 additions & 24 deletions lib/array/findObj.js

This file was deleted.

24 changes: 0 additions & 24 deletions lib/array/flatten.js

This file was deleted.

22 changes: 0 additions & 22 deletions lib/array/group.js

This file was deleted.

21 changes: 0 additions & 21 deletions lib/array/groupBy.js

This file was deleted.

21 changes: 0 additions & 21 deletions lib/array/intersection.js

This file was deleted.

38 changes: 0 additions & 38 deletions lib/array/intersection.test.js

This file was deleted.

16 changes: 0 additions & 16 deletions lib/array/keyBy.js

This file was deleted.

Loading

0 comments on commit e74bf51

Please sign in to comment.