deno.land / x / anilist_js@0.1.0 / src / media.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
import { media as media_query } from '../graphql/media.ts';import { MEDIA_TYPE } from './utils/constants.ts';import { req } from './utils/req.ts';
/** * Sub class for media related functions * @since 1.0.0 * @memberof Anilist */export class Media { /** * Fetch an anime based on a anime id * @since 1.0.0 * @param {number} id * @returns {Anime} Anime */ async anime(id: number) { if (!id || typeof id !== 'number') { throw new TypeError( 'Argument id is required and must be a number', ); }
return await req({ query: media_query, variables: { id: id, type: MEDIA_TYPE['ANIME'], }, }) .then((body) => body.Media); } /** * Fetch a manga based on a manga id * @since 1.0.0 * @param {number} id * @returns {Manga} Manga */ async manga(id: number) { if (!id || typeof id !== 'number') { throw new TypeError( 'Argument id is required and must be a number', ); }
return await req({ query: media_query, variables: { id: id, type: MEDIA_TYPE['MANGA'], }, }) .then((body) => body.Media); }}
anilist_js

Version Info

Tagged at
a year ago

External Dependencies

No external dependencies 🎉