Skip to content

Commit 1d0f9ae

Browse files
authored
Merge pull request #54 from mmdapl/feat/dev
feat: 算法md文档更新,新增百度统计相关配置
2 parents 1ee2370 + 0724b3b commit 1d0f9ae

File tree

278 files changed

+296
-99
lines changed

Some content is hidden

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

278 files changed

+296
-99
lines changed

.dockerignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
node_modules
2-
manuscript
1+
node_modules

.eslintignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
node_modules
2-
manuscript
2+
docs/manuscripts
33
.github
44
.idea
55
.dockerignore

.github/workflows/CD.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ jobs:
129129
- name: Create Zip Package
130130
run: |
131131
zip -r JavaScriptCollection.zip . \
132-
-x "node_modules/*"
132+
-x "node_modules/*" \
133+
-x ".git/*" \
133134
134135
# 提取版本号
135136
- name: Get New Version Number

.gitignore

-15
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ pids
1616
*.seed
1717
*.pid.lock
1818

19-
# Directory for instrumented libs generated by jscoverage/JSCover
20-
lib-cov
21-
2219
# Coverage directory used by tools like istanbul
2320
coverage
2421
*.lcov
@@ -27,15 +24,6 @@ coverage
2724
.nyc_output
2825

2926

30-
# Bower dependency directory (https://bower.io/)
31-
bower_components
32-
33-
# node-waf configuration
34-
.lock-wscript
35-
36-
# Compiled binary addons (https://nodejs.org/api/addons.html)
37-
build/Release
38-
3927
# Dependency directories
4028
node_modules/
4129
jspm_packages/
@@ -58,12 +46,9 @@ typings/
5846
.rts2_cache_es/
5947
.rts2_cache_umd/
6048

61-
6249
# Output of 'npm pack'
6350
*.tgz
6451

65-
# Yarn Integrity file
66-
.yarn-integrity
6752

6853
# dotenv environment variables file
6954
.env

CHANGELOG.md

-9
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ All notable changes to this project will be documented in this file. See [Conven
1414
* **algorithm:** 算法文档更新,侧边栏优化 ([80f08f6](https://github.com/mmdapl/JavaScriptCollection/commit/80f08f66dd98e3a511f6ac48f1f55bca8bbc6655))
1515
* build-proxy image ([e460747](https://github.com/mmdapl/JavaScriptCollection/commit/e460747d5719490c659a6b015418a4daa7179d89))
1616
* **ci:** add code-ci for eslint ([c8b91aa](https://github.com/mmdapl/JavaScriptCollection/commit/c8b91aa5fe3b50411f65d878c89193cb64f1a7bf))
17-
* **ci:** update code-ci rule ([7106c25](https://github.com/mmdapl/JavaScriptCollection/commit/7106c2535c71aa8a60076e5eda698b09bcdeff61))
18-
* **ci:** update run ([a9d6b0d](https://github.com/mmdapl/JavaScriptCollection/commit/a9d6b0d0740eda7d61fb2efe97f37131d54be7e5))
19-
* **ci:** update secrets ([6c5b40f](https://github.com/mmdapl/JavaScriptCollection/commit/6c5b40f821bf402199c0d4ce353047ee0ab0aa63))
2017
* ci回滚 ([7f9f9b4](https://github.com/mmdapl/JavaScriptCollection/commit/7f9f9b46bd0738bc2ecd2c676b6c073e2c1a9c3f))
2118
* **ci:** 支持master分之部署 ([b60319c](https://github.com/mmdapl/JavaScriptCollection/commit/b60319cba8049d0488d4e32a60f1e3c9af1d9a45))
2219
* ci流程优化,修复部分脚本异常 ([8e50abf](https://github.com/mmdapl/JavaScriptCollection/commit/8e50abfc505a36be3f31d5ac4e17dceb72a80981))
@@ -41,13 +38,7 @@ All notable changes to this project will be documented in this file. See [Conven
4138
* update ([871d031](https://github.com/mmdapl/JavaScriptCollection/commit/871d0311a78bcf3e24f9fbe436f88318ccc72f0c))
4239
* update /service_env/ ([0434970](https://github.com/mmdapl/JavaScriptCollection/commit/0434970eb89836cd3a0db685ff738a324f67326b))
4340
* update ci ([f01ca69](https://github.com/mmdapl/JavaScriptCollection/commit/f01ca6903e5bf992598f62a636269489b0bfee95))
44-
* update ci rule ([177c2f4](https://github.com/mmdapl/JavaScriptCollection/commit/177c2f4e8077debe50809e00c162a433b13a81ab))
4541
* update ci yaml ([e7e33f5](https://github.com/mmdapl/JavaScriptCollection/commit/e7e33f56ad20820ced703567690c84bc4a9070c6))
46-
* update config ([f7eaeac](https://github.com/mmdapl/JavaScriptCollection/commit/f7eaeac28bada71001dd884023e8a3dad7e0ff83))
47-
* update docs ([510f213](https://github.com/mmdapl/JavaScriptCollection/commit/510f21308a12c653706c2409f4f251bc7dff0bc1))
48-
* update job sort ([46ba934](https://github.com/mmdapl/JavaScriptCollection/commit/46ba934711958d8d300bd8c780fb68de22a09df5))
49-
* update logo ([435550c](https://github.com/mmdapl/JavaScriptCollection/commit/435550cd03ab34ac8da708d3fd5213573fa1006f))
50-
* update todo list ([c9b8b8e](https://github.com/mmdapl/JavaScriptCollection/commit/c9b8b8e341f3257e29c4b44239bd2b3a19960320))
5142
* update-desc ([185af9d](https://github.com/mmdapl/JavaScriptCollection/commit/185af9db8762d9cd394bad944a66e6a2d672afee))
5243
* **vercel:** vercel 统计相关配置 ([fe5f02e](https://github.com/mmdapl/JavaScriptCollection/commit/fe5f02ed5b921b26105233653ef66d9eef932430))
5344
* 优化js代码,新增链表相关刷题文档 ([d99044f](https://github.com/mmdapl/JavaScriptCollection/commit/d99044f1ffc643b14b8c41cc63f6e9bab105b71b))

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ RUN if [ "$CONTAINER_BUILD" = "true" ]; then \
2424
FROM registry.cn-hangzhou.aliyuncs.com/142vip/nginx:1.23.0-alpine
2525
ARG APP_VERSION
2626
LABEL version=$APP_VERSION description="JavaScriptCollection文档合集、博客"
27-
LABEL author="【Github&公众号】:Rong姐姐好可爱" email="[email protected]"
27+
LABEL author="【Github&公众号】:储凡" email="[email protected]"
2828
# 将dist文件中的内容复制到 /usr/share/nginx/html/ 这个目录下面 注意:--from参数
2929
COPY --from=build_base /apps/docs/.vuepress/dist/ /usr/share/nginx/html/
3030
COPY nginx.conf /etc/nginx/
File renamed without changes.

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

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* 计数
3+
* @param str
4+
*/
5+
function count(str:string) {
6+
// 转换为数组后去重
7+
const originArr = str.split('')
8+
const arr = Array.from(new Set<string>(originArr))
9+
const result = {}
10+
for (let index = 0; index < arr.length; index++) {
11+
const value = arr[index]
12+
let count = 0
13+
if (value !== ' ') {
14+
originArr.forEach(item => {
15+
if (item === value) {
16+
count++
17+
}
18+
})
19+
// 对象计数
20+
result[value] = count
21+
}
22+
}
23+
return result
24+
}
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* 找出数组 arr 中重复出现过的元素
3+
*/
4+
function duplicates(arr:number[]) {
5+
const sortArr = arr.sort()
6+
const result = []
7+
const len = sortArr.length
8+
for (let index = 0; index < len - 1; index++) {
9+
if (sortArr[index] === sortArr[index++]) {
10+
result.push(sortArr[index])
11+
}
12+
}
13+
// 去重
14+
return Array.from(new Set(result))
15+
}
16+
17+
console.log(duplicates([1, 2, 4, 4, 3, 3, 1, 5, 3]))

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

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* 检测是否为USD字符
3+
* @param str
4+
*/
5+
function isUSD(str:string) {
6+
if (!str.startsWith('$')) {
7+
return false
8+
}
9+
if (str.indexOf('.')) {
10+
// 小数
11+
const arr = str.split('.')
12+
if (arr[1].length !== 2) {
13+
return false
14+
}
15+
const strArr = arr[0].split(',')
16+
17+
for (let index = 0; index < strArr.length; index++) {
18+
if (strArr[index].length !== 3) {
19+
return false
20+
}
21+
}
22+
return true
23+
}
24+
25+
const strArr = str.split(',')
26+
27+
for (let index = 0; index < strArr.length; index++) {
28+
if (strArr[index].length !== 3) {
29+
return false
30+
}
31+
}
32+
33+
return true
34+
}
35+
36+
console.log(isUSD('$20,933,209.93'))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* 移除数组 arr 中的所有值与 item 相等的元素
3+
* - 直接在给定的 arr 数组上进行操作,并将结果返回
4+
*/
5+
function removeWithoutCopy(arr:number[], item:number) {
6+
// const result= arr.filter(value=>value!==item)
7+
// // 输出
8+
// return result;
9+
// 每次都和arr中的首个元素去比较
10+
const len = arr.length
11+
for (let index = 0; index < len; index++) {
12+
if (arr[0] !== item) {
13+
arr.push(arr[0])
14+
}
15+
16+
// 删除第一个
17+
arr.shift()
18+
}
19+
return arr
20+
}
21+
22+
const test = [1, 2, 2, 3, 4, 2, 2]
23+
console.log(removeWithoutCopy(test, 2))

code/algorithm/front-end/Readme.md

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
2+
## 前端算法刷题
3+
4+
> 相比后端涉及到的算法,前端的算法较为基础,常常是用来解决某个场景的问题
5+
6+
- 刷题平台: [牛客网](https://www.nowcoder.com/ta/front-end)
7+
- 语言版本:JavaScript
8+
9+
10+
11+
### 入门
12+
13+
14+
- dom 节点查找
15+
- 根据包名,在指定空间中创建对象
16+
- 斐波那契数列
17+
- 字符串字符统计
18+
- 数组求和
19+
- 删除数组最后一个元素
20+
- 添加元素
21+
- 删除数组第一个元素
22+
- 数组合并
23+
- 计数
24+
- 求二次方
25+
- 查找元素位置
26+
- 避免全局变量
27+
- 正确的使用
28+
- 完全等同
29+
- 函数传参
30+
- 函数的上下文
31+
- 二次封装函数
32+
- 使用 arguments
33+
- 柯里化
34+
- 或运算
35+
- 且运算
36+
- 二进制转换
37+
- 乘法
38+
- 改变上下文
39+
- 批量改变对象的属性
40+
- 判断是否包含数字
41+
- 判断是否以元音字母结尾
42+
43+
44+
### 简单
45+
46+
- 获取字符串的长度
47+
- 段落标识
48+
- 查找数组元素位置
49+
- 移除数组中的元素
50+
- 添加元素
51+
- 添加元素
52+
- 正确的函数定义
53+
- 返回函数
54+
- 使用 apply 调用函数
55+
- 二次封装函数
56+
- 二进制转换
57+
- 二进制转换
58+
- 属性遍历
59+
- 检查重复字符串
60+
- 获取指定字符串
61+
- 判断是否符合指定格式
62+
63+
64+
65+
### 中等
66+
67+
- 修改 this 指向
68+
- 时间格式化输出
69+
- 邮箱字符串判断
70+
- 颜色字符串转换
71+
- 将字符串转换为驼峰格式
72+
- 加粗文字
73+
- 移除数组中的元素
74+
- 查找重复元素
75+
- 计时器
76+
- 流程控制
77+
- 使用闭包
78+
- 判断是否符合 USD 格式
79+
80+
81+
### 较难
82+
83+
- 获取 url 参数
84+
- 数组去重
85+
- 设置文字颜色
86+
- 模块
87+
88+
89+
90+
### 困难
91+
92+
在牛客网题库——前端大挑战中暂时没有标记为`困难`的题目,个人觉得按照常用的场景,把前面的几个分类刷完就ok了,没事多刷刷呗
93+

code/algorithm/front-end/add.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* 累加
3+
*/
4+
function add() {
5+
const args = Array.prototype.slice.call(arguments)
6+
const _add = function() {
7+
console.log('add', arguments)
8+
args.push(...arguments)
9+
10+
// 返回函数
11+
return _add
12+
}
13+
// 对参数数组做求和处理
14+
_add.toString = function() {
15+
// 设置sum的起始值为0
16+
return args.reduce((sum, item) => {
17+
console.log(sum, item)
18+
return sum + item
19+
})
20+
}
21+
// 返回函数
22+
return _add
23+
}
24+
25+
const str = add(1, 6)(2)(3)
26+
console.log(str)
27+
// console.log(String(add(1,6)(2)(3)) )
28+
// console.log(add(1)(2)(3))
29+
// console.log(add(1)(2,3,4))
File renamed without changes.
File renamed without changes.
File renamed without changes.

docs/.vuepress/config.ts

+11
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@ export default defineUserConfig({
2121
// vercel统计 相关配置
2222
[
2323
'script', {type: 'text/javascript', src: '/_vercel/insights/script.js'}
24+
],
25+
// 百度统计
26+
[
27+
'script', {}, `
28+
var _hmt = _hmt || [];
29+
(function() {
30+
var hm = document.createElement("script");
31+
hm.src = "https://hm.baidu.com/hm.js?613c9d7af9e1c9a7f9eef6a55aa2399d";
32+
var s = document.getElementsByTagName("script")[0];
33+
s.parentNode.insertBefore(hm, s);
34+
})();`
2435
]
2536
],
2637
markdown: {

docs/.vuepress/config/navbar.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,36 @@ export default [
55
},
66
{
77
text: "SOLO算法",
8-
link: "/manuscript/solo-algorithm",
8+
link: "/manuscripts/solo-algorithm",
99
},
1010
{
1111
text: "前端",
12-
link: "/manuscript/front-end",
12+
link: "/manuscripts/front-end",
1313
},
1414
{
1515
text: "Node后端",
16-
link: "/manuscript/server-end",
16+
link: "/manuscripts/server-end",
1717
},
1818

1919
{
2020
text: '微服务',
21-
link: "/manuscript/microservice",
21+
link: "/manuscripts/microservice",
2222
},
2323
{
2424
text: "Battle面试官",
25-
link: "/manuscript/battle-interview",
25+
link: "/manuscripts/battle-interview",
2626
},
2727
{
2828
text: "开发技巧",
29-
link: "/manuscript/develop-skill",
29+
link: "/manuscripts/develop-skill",
3030
},
3131
{
3232
text: "读书整理",
33-
link: "/manuscript/read-books",
33+
link: "/manuscripts/read-books",
3434
},
3535

3636
{
3737
text: "其他",
38-
link: "/manuscript/other",
38+
link: "/manuscripts/other",
3939
},
4040
];

0 commit comments

Comments
 (0)