blob: d23bb93695ce36079ec18791fda6fe4dc79e2995 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
/**
* idとオブジェクトを分離する
* @param input idまたはオブジェクトの配列
* @returns idの配列とオブジェクトの配列
*/
export function splitIdAndObjects<T extends { id: string }>(input: (T | string)[]): { ids: string[]; objects: T[] } {
const ids: string[] = [];
const objects : T[] = [];
for (const item of input) {
if (typeof item === 'string') {
ids.push(item);
} else {
objects.push(item);
}
}
return {
ids,
objects,
};
}
|