deno.land / x / anilist_js@0.1.0 / src / lists.ts

نووسراو ببینە
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { req } from './utils/req.ts';import { MEDIA_TYPE } from './utils/constants.ts';import { media_list } from '../graphql/media_list.ts';
/** * Sub class for list related functions * @since 1.0.0 * @memberof Anilist */export class Lists { /** * Fetch Anime lists of a user * @since 1.0.0 * @param {(string | number)} user Can be a username or userid * @returns {MediaListCollection} MediaListCollection */ async anime(user: string | number) { if ( typeof user !== 'string' && typeof user !== 'number' ) { throw new Error( 'Invalid argument. User is required. Must be a string (username) or number (user id)', ); } const vars = typeof user === 'string' ? { username: user } : { userId: user };
return await req({ query: media_list, variables: { ...vars, type: MEDIA_TYPE['ANIME'], }, }) .then((body) => body.MediaListCollection.lists); } /** * Fetch Manga lists of a user * @since 1.0.0 * @param {(string | number)} user Can be a username or userid * @returns {MediaListCollection} MediaListCollection */ async manga(user: string | number) { if ( !user || typeof user !== 'string' || typeof user !== 'number' ) { throw new Error( 'Invalid argument. User is required. Must be a string (username) or number (user id)', ); } const vars = typeof user === 'string' ? { username: user } : { userId: user }; return await req({ query: media_list, variables: { ...vars, type: MEDIA_TYPE['MANGA'], }, }) .then((body) => body.MediaListCollection); }}
anilist_js

Version Info

Tagged at
a year ago

External Dependencies

No external dependencies 🎉