Skip to content

Commit 519887e

Browse files
committed
♻️ Convert functions to arrow functions
1 parent 49f0423 commit 519887e

File tree

6 files changed

+22
-22
lines changed

6 files changed

+22
-22
lines changed

rest/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ declare global {
1212
*
1313
* @param sid connect.sidに入っている文字列
1414
*/
15-
export const cookie = (sid: string) => `connect.sid=${sid}`;
15+
export const cookie = (sid: string): string => `connect.sid=${sid}`;
1616

1717
/** CSRF tokenを取得する
1818
*

rest/page-data.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ import { BaseOptions, ExtendedOptions, Result, setDefaults } from "./util.ts";
1515
* @param project - インポート先のprojectの名前
1616
* @param data - インポートするページデータ
1717
*/
18-
export async function importPages(
18+
export const importPages = async (
1919
project: string,
2020
data: ImportedData<boolean>,
2121
init: ExtendedOptions,
2222
): Promise<
2323
Result<string, ErrorLike>
24-
> {
24+
> => {
2525
if (data.pages.length === 0) {
2626
return { ok: true, value: "No pages to import." };
2727
}
@@ -65,7 +65,7 @@ export async function importPages(
6565

6666
const { message } = (await res.json()) as { message: string };
6767
return { ok: true, value: message };
68-
}
68+
};
6969

7070
/** `exportPages`の認証情報 */
7171
export interface ExportInit<withMetadata extends true | false>
@@ -76,15 +76,15 @@ export interface ExportInit<withMetadata extends true | false>
7676
*
7777
* @param project exportしたいproject
7878
*/
79-
export async function exportPages<withMetadata extends true | false>(
79+
export const exportPages = async <withMetadata extends true | false>(
8080
project: string,
8181
init: ExportInit<withMetadata>,
8282
): Promise<
8383
Result<
8484
ExportedData<withMetadata>,
8585
NotFoundError | NotPrivilegeError | NotLoggedInError
8686
>
87-
> {
87+
> => {
8888
const { sid, hostName, fetch, metadata } = setDefaults(init ?? {});
8989
const path =
9090
`https://${hostName}/api/page-data/export/${project}.json?metadata=${metadata}`;
@@ -111,4 +111,4 @@ export async function exportPages<withMetadata extends true | false>(
111111

112112
const value = (await res.json()) as ExportedData<withMetadata>;
113113
return { ok: true, value };
114-
}
114+
};

rest/pages.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export interface GetPageOption extends BaseOptions {
2121
* @param title 取得したいページのtitle 大文字小文字は問わない
2222
* @param options オプション
2323
*/
24-
export async function getPage(
24+
export const getPage = async (
2525
project: string,
2626
title: string,
2727
options?: GetPageOption,
@@ -30,7 +30,7 @@ export async function getPage(
3030
Page,
3131
NotFoundError | NotLoggedInError | NotMemberError
3232
>
33-
> {
33+
> => {
3434
const { sid, hostName, fetch, followRename } = setDefaults(options ?? {});
3535
const path = `https://${hostName}/api/pages/${project}/${
3636
encodeTitleURI(title)
@@ -59,7 +59,7 @@ export async function getPage(
5959
}
6060
const value = (await res.json()) as Page;
6161
return { ok: true, value };
62-
}
62+
};
6363

6464
/** Options for `listPages()` */
6565
export interface ListPagesOption extends BaseOptions {
@@ -92,15 +92,15 @@ export interface ListPagesOption extends BaseOptions {
9292
* @param project 一覧したいproject
9393
* @param options オプション 取得範囲や並び順を決める
9494
*/
95-
export async function listPages(
95+
export const listPages = async (
9696
project: string,
9797
options?: ListPagesOption,
9898
): Promise<
9999
Result<
100100
PageList,
101101
NotFoundError | NotLoggedInError | NotMemberError
102102
>
103-
> {
103+
> => {
104104
const { sid, hostName, fetch, sort, limit, skip } = setDefaults(
105105
options ?? {},
106106
);
@@ -134,4 +134,4 @@ export async function listPages(
134134
}
135135
const value = (await res.json()) as PageList;
136136
return { ok: true, value };
137-
}
137+
};

rest/profile.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import { UnexpectedResponseError } from "./error.ts";
77
*
88
* @param init connect.sid etc.
99
*/
10-
export async function getProfile(
10+
export const getProfile = async (
1111
init?: BaseOptions,
12-
): Promise<MemberUser | GuestUser> {
12+
): Promise<MemberUser | GuestUser> => {
1313
const { sid, hostName, fetch } = setDefaults(init ?? {});
1414
const path = `https://${hostName}/api/users/me`;
1515
const res = await fetch(
@@ -24,4 +24,4 @@ export async function getProfile(
2424
});
2525
}
2626
return (await res.json()) as MemberUser | GuestUser;
27-
}
27+
};

rest/project.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ import { BaseOptions, Result, setDefaults } from "./util.ts";
1515
* @param project project name to get
1616
* @param init connect.sid etc.
1717
*/
18-
export async function getProject(
18+
export const getProject = async (
1919
project: string,
2020
init?: BaseOptions,
2121
): Promise<
2222
Result<
2323
MemberProject | NotMemberProject,
2424
NotFoundError | NotMemberError | NotLoggedInError
2525
>
26-
> {
26+
> => {
2727
const { sid, hostName, fetch } = setDefaults(init ?? {});
2828
const path = `https://${hostName}/api/projects/${project}`;
2929
const res = await fetch(
@@ -49,4 +49,4 @@ export async function getProject(
4949

5050
const value = (await res.json()) as MemberProject | NotMemberProject;
5151
return { ok: true, value };
52-
}
52+
};

rest/replaceLinks.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { ExtendedOptions, Result, setDefaults } from "./util.ts";
1919
* @param init connect.sidなど
2020
* @return 置換されたリンクがあったページの数
2121
*/
22-
export async function replaceLinks(
22+
export const replaceLinks = async (
2323
project: string,
2424
from: string,
2525
to: string,
@@ -29,7 +29,7 @@ export async function replaceLinks(
2929
number,
3030
NotFoundError | NotLoggedInError | NotMemberError
3131
>
32-
> {
32+
> => {
3333
const { sid, hostName, fetch, csrf } = setDefaults(init ?? {});
3434
const path = `https://${hostName}/api/pages/${project}/replace/links`;
3535

@@ -65,4 +65,4 @@ export async function replaceLinks(
6565
// messageには"2 pages have been successfully updated!"というような文字列が入っているはず
6666
const { message } = (await res.json()) as { message: string };
6767
return { ok: true, value: parseInt(message.match(/\d+/)?.[0] ?? "0") };
68-
}
68+
};

0 commit comments

Comments
 (0)