Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit 0fe29cb

Browse files
committed
write docs + fix some jsdocs & dumb errors
1 parent 5a4e235 commit 0fe29cb

File tree

9 files changed

+450
-53
lines changed

9 files changed

+450
-53
lines changed

README.md

Lines changed: 356 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,359 @@
11
# pastebin.js
22
An OOP JavaScript wrapper for the Pastebin API
33

4-
docs coming soon :tm:
4+
# Docs
5+
The module exports 8 classes:
6+
```js
7+
const { PastebinClient, PastebinError, Paste, User, ClientUser, PasteStore, UserStore, userPasteStore } = require("pastebin.js")
8+
```
9+
10+
## PastebinClient
11+
The client used to interact with the Pastebin API.
12+
13+
### constructor()
14+
```js
15+
new PastebinClient(apiKey, username, password)
16+
```
17+
18+
#### Parameters
19+
| name | description | type | default |
20+
|----------|------------------------|--------|---------|
21+
| apiKey | Your Pastebin API key | string | `null` |
22+
| username | Your Pastebin username | string | `null` |
23+
| password | Your Pastebin password | string | `null` |
24+
25+
### credentials
26+
Your Pastebin credentials.
27+
**Type: [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)**
28+
29+
#### credentials.apiKey
30+
Your Pastebin API key.
31+
**Type: ?[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**
32+
33+
#### credentials.username
34+
Your Pastebin username.
35+
**Type: ?[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**
36+
37+
#### credentials.password
38+
Your Pastebin password.
39+
**Type: ?[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**
40+
41+
### user
42+
The user the client logged in with, if it has.
43+
**Type: ?[ClientUser](#ClientUser)**
44+
45+
### users
46+
All of the cached users.
47+
**Type: ?[UserStore](#UserStore)**
48+
49+
### pastes
50+
All of the cached pastes.
51+
**Type: ?[PasteStore](#PasteStore)**
52+
53+
### login()
54+
Login with the stored username and password and store the user key.
55+
56+
#### Returns
57+
**[PastebinClient](#PastebinClient)**
58+
59+
## PastebinError
60+
Thrown when there's an error related to the Pastebin API or pastebin.js.
61+
62+
### constructor()
63+
```js
64+
new PastebinError(message)
65+
```
66+
67+
#### Parameters
68+
| name | description | type | default |
69+
|----------|-------------------|--------|---------|
70+
| message | The error message | string | |
71+
72+
### message
73+
The error message.
74+
75+
## Paste
76+
A Pastebin paste.
77+
78+
### constructor()
79+
```js
80+
new Paste(client, data)
81+
```
82+
83+
#### Parameters
84+
| name | description | type | default |
85+
|-----------------|------------------------------------------|----------------|---------|
86+
| client | The client used to get this paste | PastebinClient | |
87+
| data | | Object | |
88+
| data.key | The key of the paste | string | |
89+
| data.title | The title of the paste | string | `null` |
90+
| data.author | The author of the paste | User | `null` |
91+
| data.content | The content of the paste | string | `null` |
92+
| data.size | The length of the content of the paste | number | `null` |
93+
| data.date | The date the paste was posted | Date | `null` |
94+
| data.format | The format of the paste | string | `null` |
95+
| data.privacy | The privacy setting of the paste | number | `null` |
96+
| data.expiry | The expiry time of the paste | string | `null` |
97+
| data.expiryDate | The expiry date of the paste | Date | `null` |
98+
| data.hits | The number of times anyone saw the paste | number | `null` |
99+
100+
### client
101+
The client used to get this paste.
102+
**Type: [PastebinClient](#PastebinClient)**
103+
104+
### key
105+
The key of this paste.
106+
**Type: [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**
107+
108+
### url
109+
The URL of this paste.
110+
**Type: [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**
111+
112+
### title
113+
The title of this paste.
114+
**Type: ?[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**
115+
116+
### author
117+
The author of this paste.
118+
**Type: ?[User](#User)**
119+
120+
### content
121+
The content of this paste.
122+
**Type: ?[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**
123+
124+
### size
125+
The length of the content of this paste.
126+
**Type: ?[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)**
127+
128+
### date
129+
The date this paste was posted.
130+
**Type: ?[Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)**
131+
132+
### format
133+
The format of this paste.
134+
**Type: ?[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**
135+
136+
### privacy
137+
The privacy setting of this paste.
138+
**Type: ?[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)**
139+
140+
### expiry
141+
The expiry time of this paste.
142+
**Type: ?[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**
143+
144+
### expiryDate
145+
The expiry date of this paste.
146+
**Type: ?[Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)**
147+
148+
### hits
149+
The number of times anyone saw this paste.
150+
**Type: ?[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)**
151+
152+
### fetch()
153+
Fetch the content of this paste, and store it in the cache.
154+
155+
#### Returns
156+
**[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Paste](#Paste)>**
157+
158+
### delete()
159+
Delete this paste.
160+
161+
#### Returns
162+
**[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Paste](#Paste)>**
163+
164+
## User
165+
A Pastebin user.
166+
167+
### constructor()
168+
```js
169+
new User(client, username)
170+
```
171+
172+
#### Parameters
173+
| name | description | type | default |
174+
|-----------------|------------------------------------------|----------------|---------|
175+
| client | The client used to get this paste | PastebinClient | |
176+
| username | The user's username | string | |
177+
178+
### client
179+
The client used to get this user.
180+
**Type: [PastebinClient](#PastebinClient)**
181+
182+
### username
183+
This user's username.
184+
**Type: [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**
185+
186+
### me
187+
Whether this user is the same as the client's user.
188+
**Type: [boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**
189+
190+
## ClientUser *extends User*
191+
The Pastebin user of the logged in client.
192+
193+
### constructor()
194+
```js
195+
new ClientUser(client, data)
196+
```
197+
198+
#### Parameters
199+
| name | description | type | default |
200+
|-----------------|------------------------------------------|----------------|---------|
201+
| client | The client used to get this paste | PastebinClient | |
202+
| data | | Object | |
203+
| data.username | The user's username | string | |
204+
| data.format | The user's format setting | string | `null` |
205+
| data.expiry | The user's expiry setting | string | `null` |
206+
| data.avatarURL | The user's avatar URL | string | `null` |
207+
| data.privacy | The user's privacy setting | number | `null` |
208+
| data.website | The user's website | string | `null` |
209+
| data.email | The user's e-mail | string | `null` |
210+
| data.location | The user's location | string | `null` |
211+
| data.pro | Whether the user is a PRO account | boolean | `null` |
212+
213+
### username
214+
This user's username.
215+
**Type: [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**
216+
217+
### format
218+
This user's format setting.
219+
**Type: ?[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**
220+
221+
### expiry
222+
This user's expiry setting.
223+
**Type: ?[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**
224+
225+
### avatarURL
226+
This user's avatar URL.
227+
**Type: ?[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**
228+
229+
### privacy
230+
This user's privacy setting.
231+
**Type: ?[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)**
232+
233+
### website
234+
This user's website.
235+
**Type: ?[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**
236+
237+
### email
238+
This user's e-mail.
239+
**Type: ?[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**
240+
241+
### location
242+
This user's location.
243+
**Type: ?[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**
244+
245+
### pro
246+
Whether this user is a PRO account.
247+
**Type: ?[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**
248+
249+
### pastes
250+
All of this user's cached pastes.
251+
**Type: ?[UserPasteStore](#UserPasteStore)**
252+
253+
## PasteStore *extends Map*
254+
A structure that holds all of the cached pastes.
255+
256+
### constructor()
257+
```js
258+
new PasteStore(client, entries)
259+
```
260+
261+
#### Parameters
262+
| name | description | type | default |
263+
|-----------------|---------------------------------|----------------------|---------|
264+
| client | The client the store belongs to | PastebinClient | |
265+
| entries | | Array<string, Paste> | `null` |
266+
267+
### client
268+
The client this store belongs to.
269+
**Type: [PastebinClient](#PastebinClient)**
270+
271+
### fetch()
272+
Fetch a paste by its key, and store it in the cache.
273+
274+
#### Parameters
275+
| name | description | type | default |
276+
|------|-----------------|--------|---------|
277+
| key | The paste's key | string | |
278+
279+
#### Returns
280+
**[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Paste](#Paste)>**
281+
282+
### create()
283+
Create a paste, and store it in the cache.
284+
285+
#### Parameters
286+
| name | description | type | default |
287+
|-----------------|-----------------------------|----------------------|---------|
288+
| content | The paste's content | any | |
289+
| options | | Array<string, Paste> | `null` |
290+
| options.title | The paste's title | string | `{}` |
291+
| options.format | The paste's format | string | `null` |
292+
| options.privacy | The paste's privacy setting | number | `null` |
293+
| options.expiry | The paste's expiry time | string | `null` |
294+
295+
#### Returns
296+
**[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Paste](#Paste)>**
297+
298+
## UserStore
299+
A structure that holds all of the cached users.
300+
301+
### constructor()
302+
```js
303+
new UserStore(client, entries)
304+
```
305+
306+
#### Paramaters
307+
| name | description | type | default |
308+
|---------|---------------------------------|----------------------|---------|
309+
| client | The client the store belongs to | PastebinClient | |
310+
| entries | | Array<string, Paste> | `null` |
311+
312+
### client
313+
The client this store belongs to.
314+
**Type: [PastebinClient](#PastebinClient)**
315+
316+
### fetch()
317+
Fetch a user by their username, and store them in the cache.
318+
319+
#### Parameters
320+
| name | description | type | default |
321+
|----------|---------------------|----------------|---------|
322+
| username | The user's username | PastebinClient | |
323+
324+
#### Returns
325+
**[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[User](#User)>**
326+
327+
## UserPasteStore
328+
A structure that holds all of a user's cached pastes.
329+
330+
### constructor()
331+
```js
332+
new UserPasteStore()
333+
```
334+
335+
#### Parameters
336+
| name | description | type | default |
337+
|---------|---------------------------------|----------------------|---------|
338+
| client | The client the store belongs to | PastebinClient | |
339+
| user | The user the store belongs to | User | |
340+
| entries | | Array<string, Paste> | `null` |
341+
342+
### client
343+
The client this store belongs to.
344+
**Type: [PastebinClient](#PastebinClient)**
345+
346+
### user
347+
The user this store belongs to.
348+
**Type: [User](#User)**
349+
350+
### fetch()
351+
Fetch this user's pastes, and store them in the cache.
352+
353+
#### Parameters
354+
| name | description | type | default |
355+
|------|---------------------------------------|--------|---------|
356+
| max | The maximum number of pastes to fetch | number | `50` |
357+
358+
#### Returns
359+
**[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[UserPasteStore](#UserPasteStore)>**

0 commit comments

Comments
 (0)