@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 CHANGED
@@ -1,11 +1,24 @@
1
- ## ๐Ÿ“ฅใƒปVersion v1.0.1 (STABLE)
2
- **1.** Added new function `cats()` with random cat emojis.
3
- **2.** Added **CHANGELOG.md** file.
4
- **2.** Changes:
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
- ## ๐Ÿ“ฅใƒปVersion v0.1.0
23
+ ## ๐Ÿ“ฅใƒปv0.1.0 (07.05.2022)
11
24
  First release.
package/README.md CHANGED
@@ -1,47 +1,105 @@
1
- ## โญ โ€ข Information
2
- <p>Returns a random emoticon and its name and type. ๐Ÿˆ ๐Ÿฑ ๐Ÿ™€</p>
3
- <a href="https://www.npmjs.com/package/@sefinek/random-emoji" target="_blank" title="random-emoji - npm" style="text-decoration:none">
4
- <img src="https://img.shields.io/npm/dt/@sefinek/random-emoji.svg?maxAge=3600" alt="npm downloads">
5
- <img src="https://img.shields.io/github/issues/sefinek24/random-emoji" alt="Issues">
6
- <img src="https://img.shields.io/github/last-commit/sefinek24/random-emoji" alt="Last commit">
7
- <img src="https://img.shields.io/github/commit-activity/w/sefinek24/random-emoji" alt="Commit activity">
8
- <img src="https://img.shields.io/github/languages/code-size/sefinek24/random-emoji" alt="Code size">
9
- <img src="https://img.shields.io/tokei/lines/github/sefinek24/random-emoji" alt="Total lines">
10
- </a>
11
-
12
- ## ๐Ÿ“ฅ โ€ข How to install?
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. Random emoji with name and type
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}; Type: ${emoji.type}; Emoji: ${emoji.content};`);
22
- // Output ยป Name: Cat Face; Type: animal; Emoji: ๐Ÿฑ;
27
+ console.log(`Name: ${emoji.name}; Emoji: ${emoji.content};`);
28
+ // > Name: Cat Face; Type: animal; Emoji: ๐Ÿฑ;
23
29
 
24
- // 2. A single emote
25
- console.log(unicode());
26
- // Output ยป ๐Ÿฅฐ
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
- // 3. Random cats
29
- const cat = cats();
30
- console.log(`Name: ${cat.name}; Slashes: ${cat.slashes}; Emoji: ${cat.content};`);
31
- // Output ยป Name: smiley_cat; Slashes: \\๐Ÿ˜บ; Emoji: ๐Ÿ˜บ;
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
- ## ๐Ÿ˜ป โ€ข Functions list
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
- emojis() // Random emoji with name and type
37
- unicode() // A single emote
38
- cats() // Return random cats
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
- > <a href="https://github.com/sefinek24/random-emoji/blob/main/CHANGELOG.md" target="_blank">https://github.com/sefinek24/random-emoji/blob/main/CHANGELOG.md</a>
99
+ > https://github.com/sefinek24/random-emoji/blob/main/CHANGELOG.md
43
100
 
44
101
  ## ๐Ÿค โ€ข Help
45
- Open new <a href="https://github.com/sefinek24/random-emoji/issues/new/choose" target="_blank">Issue</a> on Github.
102
+ Open new [Issue](https://github.com/sefinek24/random-emoji/issues/new/choose) on GitHub.
46
103
 
47
- ### Thank you โค๏ธ
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
- exports.emojis = () => emojis[Math.floor(Math.random() * emojis.length)];
6
- exports.unicode = () => unicode[Math.floor(Math.random() * unicode.length)];
7
- exports.cats = () => cats[Math.floor(Math.random() * cats.length)];
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":"๐Ÿ˜บ","slashes":"\\๐Ÿ˜บ","name":"smiley_cat"},{"content":"๐Ÿ˜ธ","slashes":"\\๐Ÿ˜ธ","name":"smile_cat"},{"content":"๐Ÿ˜น","slashes":"\\๐Ÿ˜น","name":"joy_cat"},{"content":"๐Ÿ˜ป","slashes":"\\๐Ÿ˜ป","name":"heart_eyes_cat"},{"content":"๐Ÿ˜ผ","slashes":"\\๐Ÿ˜ผ","name":"smirk_cat"},{"content":"๐Ÿ˜ฝ","slashes":"\\๐Ÿ˜ฝ","name":"kissing_cat"},{"content":"๐Ÿ™€","slashes":"\\๐Ÿ™€","name":"scream_cat"},{"content":"๐Ÿ˜ฟ","slashes":"\\๐Ÿ˜ฟ","name":"crying_cat_face"},{"content":"๐Ÿ˜พ","slashes":"\\๐Ÿ˜พ","name":"pouting_cat"},{"content":"๐Ÿฑ","slashes":"\\๐Ÿฑ","name":"cat"},{"content":"๐Ÿˆ","slashes":"\\๐Ÿˆ","name":"cat2"},{"content":"๐Ÿˆโ€โฌ›","slashes":"\\๐Ÿˆโ€โฌ›","name":"black_cat"}]
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"}]
@@ -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.1",
4
- "description": "Returns a random emoticon and its name and type.",
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 { emojis, unicode, cats } = require('./index.js');
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}; Slashes: ${cat.slashes}; Emoji: ${cat.content};`);
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
+ })();