Skip to content

Commit 3dcd03e

Browse files
nyaa~
0 parents  commit 3dcd03e

File tree

6 files changed

+103
-0
lines changed

6 files changed

+103
-0
lines changed

license

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 SLIME
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

mod.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import {gimme_neko} from './src/neko.ts';
2+
import {neko_url} from './src/type.ts';
3+
4+
export {gimme_neko};
5+
export type {neko_url};

readme.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# gimme_neko
2+
3+
I just want a neko using **[nekos.best](https://nekos.best) api**~
4+
5+
![nekohug](https://user-images.githubusercontent.com/84064124/233825692-588a474f-3e96-47d0-b2fb-745c6cc180e3.png)![nekohug](https://user-images.githubusercontent.com/84064124/233825688-1293878c-090d-48b0-948b-3f904c355bd8.png)
6+
7+
## Import `deno 🦖`
8+
```ts
9+
import {gimme_neko} from 'https://deno.land/x/gimme_neko@v1.0.0/mod.ts';
10+
```
11+
12+
# function
13+
## `gimme_neko(): neko_url`
14+
**SLIME:** smth like-
15+
```ts
16+
import {gimme_neko, neko_url} from 'https://deno.land/x/gimme_neko@v1.0.0/mod.ts'; // import
17+
18+
const neko: neko_url = await gimme_neko(); // (await) cus returns a Promise<>
19+
console.log(neko); // log neko
20+
```
21+
## console
22+
```sh
23+
$ https://nekos.best/api/v2/neko/07996548-24a8-44b5-9200-2a0a74309eb3.png
24+
```
25+
(or)
26+
```sh
27+
$ undefined
28+
```
29+
**SLIME:** **`undefined`** cus error ;-;
30+
## error
31+
```sh
32+
$ SLIME: theres no neko here~
33+
```
34+
**SLIME:** never really happens but JIC (just-in-case)

src/neko.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {nyaa} from './nyaa.ts';
2+
import {neko_url} from './type.ts';
3+
4+
/**
5+
* @export
6+
* @function gimme_neko
7+
* @returns Promise<neko_url>
8+
* @since 1.0.0
9+
*/
10+
11+
export async function gimme_neko (): Promise<neko_url> {
12+
try {
13+
return await nyaa();
14+
}
15+
catch (error) {
16+
console.error(error);
17+
}
18+
}

src/nyaa.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import {neko_url} from './type.ts';
2+
3+
/**
4+
* @export
5+
* @function nyaa
6+
* @returns Promise<neko_url>
7+
* @since 1.0.0
8+
*/
9+
10+
export async function nyaa (): Promise<neko_url> { // undefined cus error ;-;
11+
const url = 'https://nekos.best/api/v2/neko'; // nekoUrl
12+
const {results} = await (await fetch(url)).json(); // results : Array
13+
if (!results) throw 'SLIME: theres no neko here~'; // throw smth (never really happens but JIC)
14+
15+
const data = await results.pop() // (pop) -> data : Object
16+
return data.url; // return nekos url >u<
17+
}

src/type.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @export
3+
* @type neko_url
4+
* @since 1.0.0
5+
*/
6+
7+
export
8+
type neko_url = `https://nekos.best/api/v2/neko/${any}.png` | undefined; // any : (0_9 a_z -) | undef : cus error

0 commit comments

Comments
 (0)