Skip to content

Commit ccf4c9e

Browse files
authored
style: 修复Eslint校验报错异常,修改部分代码和文档格式 (#184)
* chore: update * chore(deps): update `@142vip/vuepress` * chore: update * chore: update
1 parent c9ea4b0 commit ccf4c9e

File tree

146 files changed

+724
-1724
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+724
-1724
lines changed

code/algorithm/debounce.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/**
22
* 防抖
3-
* @param func
4-
* @param time
53
*/
64
function debounce(func, time) {
75
let timeout

code/algorithm/deepClone.js

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
1+
/**
2+
* 判断数据类型
3+
*/
4+
function checkType(target) {
5+
// typeof -instanceof -toString.call() -Array.isArray()
6+
return Object.prototype.toString.call(target).slice(8, -1)
7+
}
18
/**
29
* 基于Json序列化的深拷贝【不能处理函数】
3-
* @param target
410
*/
5-
function DeepCloneByJSON(target) {
11+
export function DeepCloneByJSON(target) {
612
return JSON.parse(JSON.stringify(target))
713
}
814

915
/**
1016
* 基于递归思想的深拷贝
1117
*/
12-
function DeepClone(target) {
18+
export function DeepClone(target) {
1319
let result
1420
const targetType = checkType(target)
1521
if (targetType === 'object') {
@@ -29,16 +35,3 @@ function DeepClone(target) {
2935
}
3036
return result
3137
}
32-
33-
/**
34-
* 判断数据类型
35-
* @param target
36-
*/
37-
function checkType(target) {
38-
// typeof -instanceof -toString.call() -Array.isArray()
39-
return Object.prototype.toString.call(target).slice(8, -1)
40-
}
41-
42-
// 深拷贝
43-
console.log(DeepCloneByJSON)
44-
console.log(DeepClone)

code/algorithm/front-end-ts/add.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

code/algorithm/front-end-ts/count.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/**
22
* 计数
3-
* @param str
43
*/
54
function count(str: string) {
65
// 转换为数组后去重
@@ -22,3 +21,5 @@ function count(str: string) {
2221
}
2322
return result
2423
}
24+
25+
count('12321')

code/algorithm/front-end-ts/duplicates.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* 找出数组 arr 中重复出现过的元素
33
*/
44
function duplicates(arr: number[]) {
5-
const sortArr = arr.sort()
6-
const result = []
5+
const sortArr: number[] = arr.sort()
6+
const result: number[] = []
77
const len = sortArr.length
88
for (let index = 0; index < len - 1; index++) {
99
if (sortArr[index] === sortArr[index++]) {

code/algorithm/front-end-ts/isUSD.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/**
22
* 检测是否为USD字符
3-
* @param str
43
*/
54
function isUSD(str: string) {
65
if (!str.startsWith('$')) {
@@ -33,4 +32,4 @@ function isUSD(str: string) {
3332
return true
3433
}
3534

36-
console.log(isUSD('$20,933,209.93'))
35+
isUSD('$20,933,209.93')

code/algorithm/front-end-ts/removeWithoutCopy.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
* - 直接在给定的 arr 数组上进行操作,并将结果返回
44
*/
55
function removeWithoutCopy(arr: number[], item: number) {
6+
// 第一种方法: filter过滤
67
// const result= arr.filter(value=>value!==item)
7-
// // 输出
8+
// 输出
89
// return result;
9-
// 每次都和arr中的首个元素去比较
10+
11+
// 第二种方法:循环遍历,每次都和arr中的首个元素去比较
1012
const len = arr.length
1113
for (let index = 0; index < len; index++) {
1214
if (arr[0] !== item) {
@@ -19,5 +21,4 @@ function removeWithoutCopy(arr: number[], item: number) {
1921
return arr
2022
}
2123

22-
const test = [1, 2, 2, 3, 4, 2, 2]
23-
console.log(removeWithoutCopy(test, 2))
24+
removeWithoutCopy([1, 2, 2, 3, 4, 2, 2], 2)

code/algorithm/front-end/add.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ function add(...inputs) {
2121
return _add
2222
}
2323

24-
const str = add(1, 6)(2)(3)
25-
console.log(str)
26-
console.log(add(1)(2)(3))
27-
console.log(add(1)(2, 3, 4))
24+
add(1, 6)(2)(3)
25+
add(1)(2)(3)
26+
add(1)(2, 3, 4)

code/algorithm/front-end/count.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/**
22
* 计数
3-
* @param str
43
*/
54
function count(str) {
65
// 转换为数组后去重
@@ -24,5 +23,4 @@ function count(str) {
2423
}
2524

2625
// 调用
27-
const result = count('abTT')
28-
console.log(result)
26+
count('abTT')

code/algorithm/front-end/duplicates.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ function duplicates(arr) {
1414
return [...new Set(result)]
1515
}
1616

17-
console.log(duplicates([1, 2, 4, 4, 3, 3, 1, 5, 3]))
17+
duplicates([1, 2, 4, 4, 3, 3, 1, 5, 3])

0 commit comments

Comments
 (0)