UNPKG
assistan-ts
Version:
latest (0.0.15)
0.0.15
0.0.11
0.0.10
0.0.9
0.0.6
0.0.5
0.0.4
0.0.2
0.0.1
A typesafe and code-first library to define and run OpenAI assistants
assistan-ts
/
src
/
lib
/
utils.ts
12 lines
(11 loc)
•
269 B
text/typescript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
export
const
groupBy = <T, K
extends
keyof T>(
arr
: T[],
keySelector
:
(
it
: T
) =>
string
):
Record
<
string
, T> => {
const
res
:
Record
<
string
, T> = {}; arr.
forEach
(
(
it
) =>
{
const
key =
keySelector
(it);
if
(!res[key]) res[key] = it; });
return
res; };