-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3dcd03e
Showing
6 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 SLIME | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import {gimme_neko} from './src/neko.ts'; | ||
import {neko_url} from './src/type.ts'; | ||
|
||
export {gimme_neko}; | ||
export type {neko_url}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# gimme_neko | ||
|
||
I just want a neko using **[nekos.best](https://nekos.best) api**~ | ||
|
||
![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) | ||
|
||
## Import `deno 🦖` | ||
```ts | ||
import {gimme_neko} from 'https://deno.land/x/gimme_neko@v1.0.0/mod.ts'; | ||
``` | ||
|
||
# function | ||
## `gimme_neko(): neko_url` | ||
**SLIME:** smth like- | ||
```ts | ||
import {gimme_neko, neko_url} from 'https://deno.land/x/gimme_neko@v1.0.0/mod.ts'; // import | ||
|
||
const neko: neko_url = await gimme_neko(); // (await) cus returns a Promise<> | ||
console.log(neko); // log neko | ||
``` | ||
## console | ||
```sh | ||
$ https://nekos.best/api/v2/neko/07996548-24a8-44b5-9200-2a0a74309eb3.png | ||
``` | ||
(or) | ||
```sh | ||
$ undefined | ||
``` | ||
**SLIME:** **`undefined`** cus error ;-; | ||
## error | ||
```sh | ||
$ SLIME: theres no neko here~ | ||
``` | ||
**SLIME:** never really happens but JIC (just-in-case) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import {nyaa} from './nyaa.ts'; | ||
import {neko_url} from './type.ts'; | ||
|
||
/** | ||
* @export | ||
* @function gimme_neko | ||
* @returns Promise<neko_url> | ||
* @since 1.0.0 | ||
*/ | ||
|
||
export async function gimme_neko (): Promise<neko_url> { | ||
try { | ||
return await nyaa(); | ||
} | ||
catch (error) { | ||
console.error(error); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import {neko_url} from './type.ts'; | ||
|
||
/** | ||
* @export | ||
* @function nyaa | ||
* @returns Promise<neko_url> | ||
* @since 1.0.0 | ||
*/ | ||
|
||
export async function nyaa (): Promise<neko_url> { // undefined cus error ;-; | ||
const url = 'https://nekos.best/api/v2/neko'; // nekoUrl | ||
const {results} = await (await fetch(url)).json(); // results : Array | ||
if (!results) throw 'SLIME: theres no neko here~'; // throw smth (never really happens but JIC) | ||
|
||
const data = await results.pop() // (pop) -> data : Object | ||
return data.url; // return nekos url >u< | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* @export | ||
* @type neko_url | ||
* @since 1.0.0 | ||
*/ | ||
|
||
export | ||
type neko_url = `https://nekos.best/api/v2/neko/${any}.png` | undefined; // any : (0_9 a_z -) | undef : cus error |