Skip to content
This repository was archived by the owner on Feb 10, 2022. It is now read-only.

Commit d578cb3

Browse files
committed
💡 JSDoc
1 parent 215fd4f commit d578cb3

File tree

2 files changed

+52
-2
lines changed

2 files changed

+52
-2
lines changed

applyCommit.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,18 @@ import { getUnixTimeFromId } from "./id.ts";
55
export interface ApplyCommitProp {
66
/** changesの作成日時
77
*
8-
* UnixTimeか、UnixTimeを含んだidを渡す
8+
* UnixTimeか、UnixTimeを含んだidを渡す。
9+
* 何も指定されなかったら、実行時の時刻を用いる
910
*/
1011
updated?: number | string;
11-
userId: string;
12+
/** user id */ userId: string;
1213
}
14+
15+
/** メタデータを含んだ行にcommitsを適用する
16+
*
17+
* @param lines commitsを適用する行
18+
* @param changes 適用するcommits
19+
*/
1320
export function applyCommit(
1421
lines: readonly Line[],
1522
changes: CommitNotification["changes"],

mod.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,45 @@ export type {
2626
};
2727

2828
export interface JoinPageRoomResult {
29+
/** 特定の位置にテキストを挿入する
30+
*
31+
* @param text - 挿入したいテキスト (複数行も可)
32+
* @param beforeId - この行IDが指し示す行の上に挿入する。末尾に挿入する場合は`_end`を指定する
33+
*/
2934
insert: (text: string, beforeId: string) => Promise<void>;
35+
/** 特定の行を削除する
36+
*
37+
* @param lineId 削除したい行の行ID
38+
*/
3039
remove: (lineId: string) => Promise<void>;
40+
/** 特定の位置のテキストを書き換える
41+
*
42+
* @param text - 書き換え後のテキスト (改行は不可)
43+
* @param lineId - 書き換えたい行の行ID
44+
*/
3145
update: (text: string, lineId: string) => Promise<void>;
46+
47+
/** ページ全体を書き換える
48+
*
49+
* `update()`で現在の本文から書き換え後の本文を作ってもらう。
50+
* serverには書き換え前後の差分だけを送信する
51+
*
52+
* @param update 書き換え後の本文を作成する函数。引数には現在の本文が渡される
53+
*/
3254
patch: (update: (before: Line[]) => string[]) => Promise<void>;
55+
/** ページの更新情報を購読する */
3356
listenPageUpdate: () => AsyncGenerator<CommitNotification, void, unknown>;
57+
/** ページの操作を終了する。これを呼び出すと他のmethodsは使えなくなる
58+
*
59+
* 内部的にはwebsocketを切断している
60+
*/
3461
cleanup: () => void;
3562
}
63+
/** 指定したページを操作する
64+
*
65+
* @param project 操作したいページのproject
66+
* @param title 操作したいページのタイトル
67+
*/
3668
export async function joinPageRoom(
3769
project: string,
3870
title: string,
@@ -122,6 +154,12 @@ export async function joinPageRoom(
122154
},
123155
};
124156
}
157+
158+
/** 指定したページを削除する
159+
*
160+
* @param project 削除したいページのproject
161+
* @param title 削除したいページのタイトル
162+
*/
125163
export async function deletePage(
126164
project: string,
127165
title: string,
@@ -153,6 +191,11 @@ export async function deletePage(
153191
}
154192
}
155193

194+
/** Streamを購読する
195+
*
196+
* @param project 購読したいproject
197+
* @param events 購読したいeventの種類。複数種類を指定できる
198+
*/
156199
export async function* listenStream<EventName extends keyof ListenEventMap>(
157200
project: string,
158201
...events: EventName[]

0 commit comments

Comments
 (0)