Skip to content
This repository has been archived by the owner on Jul 14, 2020. It is now read-only.

Commit

Permalink
#23 先添加一个 js 和 2 个 py 片段, 看看效果
Browse files Browse the repository at this point in the history
  • Loading branch information
testacount1 committed Jul 12, 2020
1 parent 27959f8 commit 2e3cb75
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,17 @@
"enumDescriptions": []
}
}
}
},
"snippets": [
{
"language": "javascript",
"path": "./片段/javascript.json"
},
{
"language": "python",
"path": "./片段/python.json"
}
]
},
"scripts": {
"test": "node ./test/runTest.js"
Expand Down
14 changes: 14 additions & 0 deletions 片段/javascript.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"出现次数": {
"prefix": [
"array",
"ChuXianCiShu",
"出现次数"
],
"body": [
"const 统计出现次数 = (数组, 值) => 数组.reduce((次数, 项) => (项 === 值 ? 次数 + 1 : 次数), 0);",
"统计出现次数(${1:数组}, ${2:值});"
],
"description": "统计数组中某个值出现的次数"
}
}
29 changes: 29 additions & 0 deletions 片段/python.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"读文件": {
"prefix": [
"file",
"WenJian",
"读文件"
],
"body": [
"with open(${1:文件全路径}) as 文件:",
"\t内容 = 文件.read()"
],
"description": "读取某文件"
},
"读所有文件": {
"prefix": [
"file",
"WenJian",
"读所有文件"
],
"body": [
"import os",
"路径 = '.'",
"for 文件名 in os.listdir(路径):",
"\twith open(os.path.join(路径, 文件名)) as 文件:",
"\t\t内容 = 文件.read()"
],
"description": "读取某目录下所有文件"
}
}

0 comments on commit 2e3cb75

Please sign in to comment.