@sefinek/random-emoji 1.0.1 โ 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -5
- package/README.md +87 -29
- package/api/endpoints.json +1 -0
- package/index.js +48 -3
- package/json/cats.json +1 -1
- package/json/circles.json +1 -0
- package/json/hearts.json +1 -0
- package/package.json +9 -4
- package/test.js +24 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
|
-
## ๐ฅใป
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
## ๐ฅใปv1.3.0 (13.05.2022)
|
|
2
|
+
1. Updated README.md file.
|
|
3
|
+
2. Added new function `new kaomojis()` with random kaomoji from my [API](https://api.skiffybot.pl). See examples: [[1](https://github.com/sefinek24/random-emoji/blob/main/test.js)] [[2](https://github.com/sefinek24/random-emoji#%EF%B8%8F--kaomojis)]
|
|
4
|
+
3. Other changes to [index.js](https://github.com/sefinek24/random-emoji/blob/main/index.js) file.
|
|
5
|
+
|
|
6
|
+
## ๐ฅใปv1.2.0 (12.05.2022)
|
|
7
|
+
1. Updated CHANGELOG.md, README.md and package.json.
|
|
8
|
+
2. Added new function `circles()` with random circles.
|
|
9
|
+
3. Removed `.slashes`.
|
|
10
|
+
|
|
11
|
+
## ๐ฅใปv1.1.1 (11.05.2022)
|
|
12
|
+
1. Added new function `hearts()` with random hearts.
|
|
13
|
+
|
|
14
|
+
## ๐ฅใปv1.0.1 (08.05.2022)
|
|
15
|
+
1. Added new function `cats()` with random cat emojis.
|
|
16
|
+
2. Added **CHANGELOG.md** file.
|
|
17
|
+
2. Changes:
|
|
5
18
|
```diff
|
|
6
19
|
- emoji()
|
|
7
20
|
+ emojis()
|
|
8
21
|
```
|
|
9
22
|
|
|
10
|
-
## ๐ฅใป
|
|
23
|
+
## ๐ฅใปv0.1.0 (07.05.2022)
|
|
11
24
|
First release.
|
package/README.md
CHANGED
|
@@ -1,47 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
<
|
|
3
|
-
<a
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>๐ฑ About this package ๐</h1>
|
|
3
|
+
<p>Returns a random emoticons (name, type) and kaomojis.</p>
|
|
4
|
+
<a href="https://www.npmjs.com/package/@sefinek/random-emoji" target="_blank" title="random-emoji - npm" style="text-decoration:none">
|
|
5
|
+
<img src="https://img.shields.io/npm/dt/@sefinek/random-emoji.svg?maxAge=3600" alt="The number of downloads">
|
|
6
|
+
<img src="https://img.shields.io/github/issues/sefinek24/random-emoji" alt="Issues">
|
|
7
|
+
<img src="https://img.shields.io/github/last-commit/sefinek24/random-emoji" alt="Last commit">
|
|
8
|
+
<img src="https://img.shields.io/github/commit-activity/w/sefinek24/random-emoji" alt="Commit activity">
|
|
9
|
+
<img src="https://img.shields.io/github/languages/code-size/sefinek24/random-emoji" alt="Code size">
|
|
10
|
+
<img src="https://img.shields.io/tokei/lines/github/sefinek24/random-emoji" alt="Total lines">
|
|
11
|
+
</a>
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
## ๐ฅ โข Installation
|
|
13
15
|
> **$** npm install @sefinek/random-emoji
|
|
14
16
|
|
|
15
17
|
## ๐ผ โข Examples
|
|
16
18
|
```js
|
|
17
19
|
const random = require('@sefinek/random-emoji');
|
|
18
20
|
|
|
19
|
-
// 1.
|
|
21
|
+
// 1. A single emote
|
|
22
|
+
console.log(unicode());
|
|
23
|
+
// > ๐ฅฐ
|
|
24
|
+
|
|
25
|
+
// 2. Random emoji with name and type
|
|
20
26
|
const emoji = random.emojis();
|
|
21
|
-
console.log(`Name: ${emoji.name};
|
|
22
|
-
//
|
|
27
|
+
console.log(`Name: ${emoji.name}; Emoji: ${emoji.content};`);
|
|
28
|
+
// > Name: Cat Face; Type: animal; Emoji: ๐ฑ;
|
|
23
29
|
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
// 3. Random cat
|
|
31
|
+
const cat = random.cats();
|
|
32
|
+
console.log(`Name: ${cat.name}; Emoji: ${cat.content};`);
|
|
33
|
+
// > Name: smiley_cat; Emoji: ๐บ;
|
|
34
|
+
|
|
35
|
+
// 4. Random heart
|
|
36
|
+
const heart = random.hearts();
|
|
37
|
+
console.log(`Name: ${heart.name}; Emoji: ${heart.content};`);
|
|
38
|
+
// > Name: blue_heart; Emoji: ๐;
|
|
27
39
|
|
|
28
|
-
//
|
|
29
|
-
const
|
|
30
|
-
console.log(`Name: ${
|
|
31
|
-
//
|
|
40
|
+
// 5. Random circle
|
|
41
|
+
const circle = random.circles();
|
|
42
|
+
console.log(`Name: ${heart.name}; Emoji: ${heart.content};`);
|
|
43
|
+
// > Name: blue_circle; Emoji: ๐ต;
|
|
32
44
|
```
|
|
33
45
|
|
|
34
|
-
## ๐ป โข
|
|
46
|
+
## ๐ป โข Usage
|
|
47
|
+
| Function | Description |
|
|
48
|
+
|-----------------------------------------------------------------------------------|--------------------------------------------------------------|
|
|
49
|
+
| [emojis](https://github.com/sefinek24/random-emoji#%EF%B8%8F--kaomojis) | Random emoji with name and type |
|
|
50
|
+
| [unicode](https://github.com/sefinek24/random-emoji#%EF%B8%8F--kaomojis) | A single emote |
|
|
51
|
+
| [cats](https://github.com/sefinek24/random-emoji#%EF%B8%8F--kaomojis) | Return random cat |
|
|
52
|
+
| [hearts](https://github.com/sefinek24/random-emoji#%EF%B8%8F--kaomojis) | Return random heart |
|
|
53
|
+
| [circles](https://github.com/sefinek24/random-emoji#%EF%B8%8F--kaomojis) | Return random circle |
|
|
54
|
+
| [**new** kaomojis](https://github.com/sefinek24/random-emoji#%EF%B8%8F--kaomojis) | Return random kaomojis from [API](https://api.skiffybot.xyz) |
|
|
55
|
+
|
|
56
|
+
## โฉ๏ธ โข Kaomojis
|
|
57
|
+
### ยป Async/await example
|
|
35
58
|
```js
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
59
|
+
const random = require('@sefinek/random-emoji');
|
|
60
|
+
const kaomoji = new random.kaomojis();
|
|
61
|
+
|
|
62
|
+
async function example() {
|
|
63
|
+
const uwu = await kaomoji.uwu();
|
|
64
|
+
console.log(uwu.message);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
example(); // Execute function
|
|
39
68
|
```
|
|
40
69
|
|
|
70
|
+
### ยป Promise example
|
|
71
|
+
```js
|
|
72
|
+
const random = require('@sefinek/random-emoji');
|
|
73
|
+
const kaomoji = new random.kaomojis();
|
|
74
|
+
|
|
75
|
+
kaomoji.love().then(data => console.log(data));
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### ยป The returned object from [API](https://api.skiffybot.xyz)
|
|
79
|
+
```json
|
|
80
|
+
{
|
|
81
|
+
"success": true,
|
|
82
|
+
"status": 200,
|
|
83
|
+
"category": "kaomoji",
|
|
84
|
+
"endpoint": "uwu",
|
|
85
|
+
"message": "๐
ค๐
ฆ๐
ค"
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### ยป Kaomoji endpoints
|
|
90
|
+
| Function | Example |
|
|
91
|
+
|-------------------------------------------------------|-----------|
|
|
92
|
+
| [cat](https://api.skiffybot.xyz/api/v1/kaomoji/cat) | (=^-ฯ-^=) |
|
|
93
|
+
| [dog](https://api.skiffybot.xyz/api/v1/kaomoji/dog) | เฌ(โชใป๏ปใปโช)เฌ |
|
|
94
|
+
| [owo](https://api.skiffybot.xyz/api/v1/kaomoji/owo) | ๐๐๐ |
|
|
95
|
+
| [uwu](https://api.skiffybot.xyz/api/v1/kaomoji/uwu) | ๐๐จ๐ |
|
|
96
|
+
| [love](https://api.skiffybot.xyz/api/v1/kaomoji/love) | ใฝ(โกโฟโก)ใ |
|
|
97
|
+
|
|
41
98
|
## ๐ โข Changelog
|
|
42
|
-
>
|
|
99
|
+
> https://github.com/sefinek24/random-emoji/blob/main/CHANGELOG.md
|
|
43
100
|
|
|
44
101
|
## ๐ค โข Help
|
|
45
|
-
Open new
|
|
102
|
+
Open new [Issue](https://github.com/sefinek24/random-emoji/issues/new/choose) on GitHub.
|
|
46
103
|
|
|
47
|
-
|
|
104
|
+
## โญ โข Thank you
|
|
105
|
+
Give a [star](https://github.com/sefinek24/random-emoji) if you can on GitHub page.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"cat":"kaomoji/cat","dog":"kaomoji/dog","owo":"kaomoji/owo","uwu":"kaomoji/uwu","love":"kaomoji/love"}
|
package/index.js
CHANGED
|
@@ -1,7 +1,52 @@
|
|
|
1
1
|
const emojis = require('./json/emojis.json');
|
|
2
2
|
const unicode = require('./json/unicode.json');
|
|
3
3
|
const cats = require('./json/cats.json');
|
|
4
|
+
const hearts = require('./json/hearts.json');
|
|
5
|
+
const circles = require('./json/circles.json');
|
|
6
|
+
const { get } = require('https');
|
|
7
|
+
const { URL, URLSearchParams } = require('url');
|
|
8
|
+
const endpoints = require('./api/endpoints.json');
|
|
4
9
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
10
|
+
function getContent(url) {
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
get(url, res => {
|
|
13
|
+
const { statusCode } = res;
|
|
14
|
+
if (statusCode !== 200) {
|
|
15
|
+
res.resume();
|
|
16
|
+
reject(`Request failed with status code ${statusCode}.`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
res.setEncoding('utf8');
|
|
20
|
+
let rawData = '';
|
|
21
|
+
res.on('data', chunk => {rawData += chunk;});
|
|
22
|
+
res.on('end', () => {
|
|
23
|
+
try {
|
|
24
|
+
resolve(JSON.parse(rawData));
|
|
25
|
+
} catch (err) {
|
|
26
|
+
reject(err.message);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}).on('error', err => reject(err.message));
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
class SkiffyBOT {
|
|
34
|
+
constructor() {
|
|
35
|
+
Object.keys(endpoints).forEach(endpoint => {
|
|
36
|
+
this[endpoint] = async function(queryParams = '') {
|
|
37
|
+
const url = new URL(`https://api.skiffybot.xyz/api/v1/${endpoints[endpoint]}`);
|
|
38
|
+
queryParams !== '' ? url.search = new URLSearchParams(queryParams) : '';
|
|
39
|
+
return await getContent(url.toString());
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
module.exports = {
|
|
46
|
+
emojis: () => emojis[Math.floor(Math.random() * emojis.length)],
|
|
47
|
+
unicode: () => unicode[Math.floor(Math.random() * unicode.length)],
|
|
48
|
+
cats: () => cats[Math.floor(Math.random() * cats.length)],
|
|
49
|
+
hearts: () => hearts[Math.floor(Math.random() * hearts.length)],
|
|
50
|
+
circles: () => circles[Math.floor(Math.random() * circles.length)],
|
|
51
|
+
kaomojis: SkiffyBOT,
|
|
52
|
+
};
|
package/json/cats.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"content":"๐บ","
|
|
1
|
+
[{"content":"๐บ","name":"smiley_cat"},{"content":"๐ธ","name":"smile_cat"},{"content":"๐น","name":"joy_cat"},{"content":"๐ป","name":"heart_eyes_cat"},{"content":"๐ผ","name":"smirk_cat"},{"content":"๐ฝ","name":"kissing_cat"},{"content":"๐","name":"scream_cat"},{"content":"๐ฟ","name":"crying_cat_face"},{"content":"๐พ","name":"pouting_cat"},{"content":"๐ฑ","name":"cat"},{"content":"๐","name":"cat2"},{"content":"๐โโฌ","name":"black_cat"}]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[{"content":"๐ด","name":"red_circle"},{"content":"๐ ","name":"orange_circle"},{"content":"๐ก","name":"yellow_circle"},{"content":"๐ข","name":"green_circle"},{"content":"๐ต","name":"blue_circle"},{"content":"๐ฃ","name":"purple_circle"},{"content":"๐ค","name":"brown_circle"},{"content":"โซ","name":"black_circle"},{"content":"โช","name":"white_circle"}]
|
package/json/hearts.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[{"content":"๐","name":"love_letter"},{"content":"๐","name":"gift_heart"},{"content":"โฃ๏ธ","name":"heart_exclamation"},{"content":"๐","name":"broken_heart"},{"content":"โค๏ธโ๐ฅ","name":"heart_on_fire"},{"content":"โค๏ธโ๐ฉน","name":"mending_heart"},{"content":"โค๏ธ","name":"heart"},{"content":"๐","name":"yellow_heart"},{"content":"๐","name":"green_heart"},{"content":"๐","name":"blue_heart"},{"content":"๐","name":"purple_heart"},{"content":"๐ค","name":"brown_heart"},{"content":"๐ค","name":"black_heart"},{"content":"๐ค","name":"white_heart"},{"content":"๐ซ","name":"anatomical_heart"},{"content":"๐","name":"wedding"},{"content":"๐","name":"cupid"},{"content":"๐","name":"heartpulse"}]
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sefinek/random-emoji",
|
|
3
|
-
"version": "1.0
|
|
4
|
-
"description": "Returns a random
|
|
3
|
+
"version": "1.3.0",
|
|
4
|
+
"description": "Returns a random emoticons (name, type) and kaomojis.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "node test.js"
|
|
@@ -13,14 +13,19 @@
|
|
|
13
13
|
"keywords": [
|
|
14
14
|
"random",
|
|
15
15
|
"emoji",
|
|
16
|
+
"emojis",
|
|
16
17
|
"emoticon",
|
|
17
18
|
"unicode",
|
|
18
|
-
"cats",
|
|
19
19
|
"cat",
|
|
20
|
+
"cats",
|
|
21
|
+
"heart",
|
|
22
|
+
"hearts",
|
|
23
|
+
"circle",
|
|
24
|
+
"circles",
|
|
20
25
|
"name",
|
|
21
26
|
"type"
|
|
22
27
|
],
|
|
23
|
-
"author": "Sefinek",
|
|
28
|
+
"author": "Sefinek (https://skiffybot.xyz)",
|
|
24
29
|
"license": "MIT",
|
|
25
30
|
"bugs": {
|
|
26
31
|
"url": "https://github.com/sefinek24/random-emoji/issues"
|
package/test.js
CHANGED
|
@@ -1,12 +1,30 @@
|
|
|
1
|
-
const {
|
|
2
|
-
|
|
3
|
-
// Random emoji with name and type
|
|
4
|
-
const emoji = emojis();
|
|
5
|
-
console.log(`Name: ${emoji.name}; Type: ${emoji.type}; Emoji: ${emoji.content};`);
|
|
1
|
+
const { unicode, emojis, cats, hearts, circles, kaomojis } = require('./index.js');
|
|
6
2
|
|
|
7
3
|
// A single emote
|
|
8
4
|
console.log(unicode());
|
|
9
5
|
|
|
6
|
+
// Random emoji with name and type
|
|
7
|
+
const emoji = emojis();
|
|
8
|
+
console.log(`Name: ${emoji.name}; Emoji: ${emoji.content};`);
|
|
9
|
+
|
|
10
10
|
// Random cats
|
|
11
11
|
const cat = cats();
|
|
12
|
-
console.log(`Name: ${cat.name};
|
|
12
|
+
console.log(`Name: ${cat.name}; Emoji: ${cat.content};`);
|
|
13
|
+
|
|
14
|
+
// Random hearts
|
|
15
|
+
const heart = hearts();
|
|
16
|
+
console.log(`Name: ${heart.name}; Emoji: ${heart.content};`);
|
|
17
|
+
|
|
18
|
+
// Random circles
|
|
19
|
+
const circle = circles();
|
|
20
|
+
console.log(`Name: ${circle.name}; Emoji: ${circle.content};`);
|
|
21
|
+
|
|
22
|
+
// Random kaomoji
|
|
23
|
+
(async () => {
|
|
24
|
+
const kaomoji = new kaomojis();
|
|
25
|
+
const kaoCat = await kaomoji.cat();
|
|
26
|
+
console.log(`Cat face: ${kaoCat.message}`);
|
|
27
|
+
|
|
28
|
+
const uwu = await kaomoji.uwu();
|
|
29
|
+
console.log(`Random UwU: ${uwu.message}`);
|
|
30
|
+
})();
|