Skip to content

Commit ca42333

Browse files
committed
Fix: functionをarrow functionにする(完結編)
1 parent ec79ffd commit ca42333

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

browser/websocket/_codeBlock.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ export interface CodeTitle {
1212
}
1313

1414
/** コミットを送信する一連の処理 */
15-
export async function applyCommit(
15+
export const applyCommit = async (
1616
commits: Change[],
1717
head: HeadData,
1818
projectName: string,
1919
pageTitle: string,
2020
socket: Socket,
2121
userId?: string,
22-
): ReturnType<typeof pushWithRetry> {
22+
): ReturnType<typeof pushWithRetry> => {
2323
const [projectId, userId_] = await Promise.all([
2424
getProjectId(projectName),
2525
userId ?? getUserId(),
@@ -34,14 +34,14 @@ export async function applyCommit(
3434
title: pageTitle,
3535
retry: 3,
3636
});
37-
}
37+
};
3838

3939
/** コードブロックのタイトル行から各種プロパティを抽出する
4040
*
4141
* @param lineText {string} 行テキスト
4242
* @return `lineText`がコードタイトル行であれば`CodeTitle`を、そうでなければ`null`を返す
4343
*/
44-
export function extractFromCodeTitle(lineText: string): CodeTitle | null {
44+
export const extractFromCodeTitle = (lineText: string): CodeTitle | null => {
4545
const matched = lineText.match(/^(\s*)code:(.+?)(\(.+\)){0,1}\s*$/);
4646
if (matched === null) return null;
4747
const filename = matched[2].trim();
@@ -66,7 +66,7 @@ export function extractFromCodeTitle(lineText: string): CodeTitle | null {
6666
lang: lang,
6767
indent: matched[1].length,
6868
};
69-
}
69+
};
7070

7171
/** コードブロック本文のインデント数を計算する */
7272
export function countBodyIndent(

browser/websocket/updateCodeBlock.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ export const updateCodeBlock = async (
8383
};
8484

8585
/** コード本文のテキストを取得する */
86-
function getCodeBody(code: string | string[] | SimpleCodeFile): string[] {
86+
const getCodeBody = (code: string | string[] | SimpleCodeFile): string[] => {
8787
const content = isSimpleCodeFile(code) ? code.content : code;
8888
if (Array.isArray(content)) return content;
8989
return content.split("\n");
90-
}
90+
};
9191

9292
/** insertコミットの行IDとtextのインデントを修正する */
9393
function* fixCommits(
@@ -133,10 +133,10 @@ function* fixCommits(
133133
}
134134

135135
/** コードタイトルが違う場合は書き換える */
136-
function makeTitleChangeCommit(
136+
const makeTitleChangeCommit = (
137137
code: SimpleCodeFile,
138138
target: Pick<TinyCodeBlock, "titleLine">,
139-
): UpdateCommit | null {
139+
): UpdateCommit | null => {
140140
const lineId = target.titleLine.id;
141141
const targetTitle = extractFromCodeTitle(target.titleLine.text);
142142
if (
@@ -158,4 +158,4 @@ function makeTitleChangeCommit(
158158
text: " ".repeat(countBodyIndent(target) - 1) + "code:" + title,
159159
},
160160
};
161-
}
161+
};

browser/websocket/updateCodeFile.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,14 @@ export const updateCodeFile = async (
107107
/** TinyCodeBlocksの配列からコード本文をフラットな配列に格納して返す \
108108
* その際、コードブロックの左側に存在していたインデントは削除する
109109
*/
110-
function flatCodeBodies(codeBlocks: readonly TinyCodeBlock[]): Line[] {
110+
const flatCodeBodies = (codeBlocks: readonly TinyCodeBlock[]): Line[] => {
111111
return codeBlocks.map((block) => {
112112
const indent = countBodyIndent(block);
113113
return block.bodyLines.map((body) => {
114114
return { ...body, text: body.text.slice(indent) };
115115
});
116116
}).flat();
117-
}
117+
};
118118

119119
/** コードブロックの差分からコミットデータを作成する */
120120
function* makeCommits(
@@ -233,7 +233,7 @@ function* makeCommits(
233233
}
234234
}
235235

236-
function makeCodeBlockTitle(code: SimpleCodeFile) {
236+
const makeCodeBlockTitle = (code: SimpleCodeFile) => {
237237
const codeName = code.filename + (code.lang ? `(${code.lang})` : "");
238238
return `code:${codeName}`;
239-
}
239+
};

0 commit comments

Comments
 (0)