@sefinek/random-emoji 2.0.4 → 2.1.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 ADDED
@@ -0,0 +1,88 @@
1
+ ## 📥・v2.1.0 (20.12.2023)
2
+
3
+ ### 🎉 Added
4
+ 1. New function `<random>.squares` for retrieving random squares.
5
+ 2. Added a new example ([examples/table.js](examples/table.js)) demonstrating the use of module functions in a table format.
6
+
7
+ ### ✨ Changes
8
+ 1. General code quality improvements.
9
+ 2. Enhanced type definitions in [`index.d.ts`](index.d.ts) and expanded documentation.
10
+ 3. Improved the emoji randomization mechanism.
11
+ 4. Updated example files in the [`examples`](examples) directory.
12
+
13
+
14
+ ## 📥・v2.0.2/v2.0.3 (08.11.2023)
15
+
16
+ ### 🎉 Added
17
+ 1. `<random>.version`
18
+
19
+ ### ✨ Changes
20
+ 1. Removed `README_PL.md`.
21
+ 2. Updated add added new types to `index.d.ts` file.
22
+ 3. Now this module uses only native module (like `https`).
23
+ 4. Added new headers for better safety etc.
24
+
25
+ ### 🌠 Migration
26
+ 1. Changed `new random.kaomojis()` to `new random.Kaomojis()`.
27
+
28
+
29
+ ## 📥・v1.4.6 (11.03.2023)
30
+ 1. Updated to **v2** release of API.
31
+
32
+
33
+ ## 📥・v1.4.5 (09.10.2022)
34
+ 1. Fixed URLs.
35
+
36
+
37
+ ## 📥・v1.4.4 (02.10.2022)
38
+ 1. Fixed URLs.
39
+
40
+
41
+ ## 📥・v1.4.3 (19.09.2022)
42
+ 1. Small changes in `index.d.ts` etc.
43
+
44
+
45
+ ## 📥・v1.4.2 (05.06.2022)
46
+ 1. Added typings.
47
+ 2. Small fixes in `README.md` and `README_PL.md`.
48
+
49
+
50
+ ## 📥・v1.4.1 (02.06.2022)
51
+ 1. Small changes.
52
+
53
+
54
+ ## 📥・v1.4.0 (15.05.2022)
55
+ 1. Added new function `foods()` with random foods.
56
+ 2. Fixes in `new kaomojis()`.
57
+ 3. Small fixes in README.md.
58
+ 4. Added Poland version of README.md file.
59
+
60
+
61
+ ## 📥・v1.3.0 (13.05.2022)
62
+ 1. Updated README.md file.
63
+ 2. Added `new kaomojis()` with random kaomoji from my [API](https://api.sefinek.net). See examples: [[1](https://github.com/sefinek24/random-emoji/blob/main/test.js)] [[2](https://github.com/sefinek24/random-emoji#%EF%B8%8F--kaomojis)]
64
+ 3. Other changes to [index.js](https://github.com/sefinek24/random-emoji/blob/main/index.js) file.
65
+
66
+
67
+ ## 📥・v1.2.0 (12.05.2022)
68
+ 1. Updated CHANGELOG.md, README.md and package.json.
69
+ 2. Added new function `circles()` with random circles.
70
+ 3. Removed `.slashes`.
71
+
72
+
73
+ ## 📥・v1.1.1 (11.05.2022)
74
+ 1. Added new function `hearts()` with random hearts.
75
+
76
+
77
+ ## 📥・v1.0.1 (08.05.2022)
78
+ 1. Added new function `cats()` with random cat emojis.
79
+ 2. Added **CHANGELOG.md** file.
80
+ 3. Changes:
81
+ ```diff
82
+ - emoji()
83
+ + emojis()
84
+ ```
85
+
86
+
87
+ ## 📥・v0.1.0 (07.05.2022)
88
+ First release.
package/README.md CHANGED
@@ -17,15 +17,15 @@ npm install @sefinek/random-emoji
17
17
 
18
18
 
19
19
  ## 😻 • Usage
20
- | Function | Description |
21
- |----------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------|
22
- | [unicode](https://github.com/sefinek24/random-emoji/blob/f8e6a007717dc5e51adc31b4418bb954e2d364e5/example.js#L4) | A single emoji |
23
- | [emojis](https://github.com/sefinek24/random-emoji/blob/f8e6a007717dc5e51adc31b4418bb954e2d364e5/example.js#L7) | Random emoji with name and type |
24
- | [cats](https://github.com/sefinek24/random-emoji/blob/f8e6a007717dc5e51adc31b4418bb954e2d364e5/example.js#L11) | Return random cat |
25
- | [hearts](https://github.com/sefinek24/random-emoji/blob/f8e6a007717dc5e51adc31b4418bb954e2d364e5/example.js#L14) | Return random heart |
26
- | [foods](https://github.com/sefinek24/random-emoji/blob/f8e6a007717dc5e51adc31b4418bb954e2d364e5/example.js#L18) | Return random food |
27
- | [circles](https://github.com/sefinek24/random-emoji/blob/f8e6a007717dc5e51adc31b4418bb954e2d364e5/example.js#L22) | Return random circle |
28
- | [**new** Kaomojis](https://github.com/sefinek24/random-emoji/blob/f8e6a007717dc5e51adc31b4418bb954e2d364e5/example.js#L28) | Return random kaomojis from [API](https://api.sefinek.net) |
20
+ | Function | Description |
21
+ |-------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------|
22
+ | [unicode](https://github.com/sefinek24/random-emoji/blob/f8e6a007717dc5e51adc31b4418bb954e2d364e5/example.js#L4) | Get a single emoji |
23
+ | [emojis](https://github.com/sefinek24/random-emoji/blob/f8e6a007717dc5e51adc31b4418bb954e2d364e5/example.js#L7) | Get a random emoji with its name and type |
24
+ | [cats](https://github.com/sefinek24/random-emoji/blob/f8e6a007717dc5e51adc31b4418bb954e2d364e5/example.js#L11) | Get a random cat |
25
+ | [hearts](https://github.com/sefinek24/random-emoji/blob/f8e6a007717dc5e51adc31b4418bb954e2d364e5/example.js#L14) | Get a random heart |
26
+ | [foods](https://github.com/sefinek24/random-emoji/blob/f8e6a007717dc5e51adc31b4418bb954e2d364e5/example.js#L18) | Get a random food |
27
+ | [circles](https://github.com/sefinek24/random-emoji/blob/f8e6a007717dc5e51adc31b4418bb954e2d364e5/example.js#L22) | Get a random circle |
28
+ | [**new** Kaomojis](#kaomoji-endpoints) | Get random kaomojis from the [API](https://api.sefinek.net) |
29
29
 
30
30
 
31
31
  ## 😼 • Examples
@@ -33,18 +33,17 @@ npm install @sefinek/random-emoji
33
33
  const random = require('@sefinek/random-emoji');
34
34
 
35
35
  // 1. A single emoji
36
- console.log(random.unicode());
37
- // Output: 🥰
36
+ console.log(random.unicode()); // 🥰
38
37
 
39
- // 2. Random emoji with name and type
38
+ // 2. Random emoji along with its visual representation, name, and category
40
39
  const emoji = random.emojis();
41
- console.log(`Name: ${emoji.name}; Emoji: ${emoji.content};`);
42
- // Output: Name: jack-o-lantern; Emoji: 🎃;
40
+ console.log(`Emoji: ${emoji.content}; Name: ${emoji.name}; Type: ${emoji.type}`);
41
+ // Emoji: 🐶; Name: Dog Face; Type: animal
43
42
 
44
43
  // 3. Random cat
45
44
  const cat = random.cats();
46
- console.log(`Name: ${cat.name}; Emoji: ${cat.content};`);
47
- // Output: Name: smiley_cat; Emoji: 😺;
45
+ console.log(`Emoji: ${cat.content}; Name: ${cat.name}`);
46
+ // Emoji: 😺; Name: smiley_cat
48
47
  ```
49
48
 
50
49
 
@@ -57,7 +56,7 @@ const random = require('@sefinek/random-emoji');
57
56
  const kaomoji = new random.Kaomojis();
58
57
 
59
58
  const uwu = await kaomoji.uwu();
60
- console.log(`Random UwU: ${uwu.message}`);
59
+ console.log('Random UwU:', uwu.message);
61
60
  })();
62
61
  ```
63
62
 
@@ -66,9 +65,9 @@ const random = require('@sefinek/random-emoji');
66
65
  const random = require('@sefinek/random-emoji');
67
66
  const kaomoji = new random.Kaomojis();
68
67
 
69
- kaomoji.love().then(data => console.log(data));
68
+ kaomoji.uwu().then(data => console.log(data));
70
69
  // or shorter
71
- kaomoji.love().then(console.log);
70
+ kaomoji.uwu().then(console.log);
72
71
  ```
73
72
 
74
73
  ### » The returned object from [API](https://api.sefinek.net)
@@ -76,21 +75,23 @@ kaomoji.love().then(console.log);
76
75
  {
77
76
  "success": true,
78
77
  "status": 200,
79
- "category": "kaomoji",
80
- "endpoint": "uwu",
81
- "message": "🅤🅦🅤"
78
+ "info": {
79
+ "category": "kaomoji",
80
+ "endpoint": "uwu"
81
+ },
82
+ "message": "UwU"
82
83
  }
83
84
  ```
84
85
 
85
86
 
86
- ### » Kaomoji endpoints
87
- | Function | Example |
88
- |-----------------------------------------------------|-----------|
89
- | [cat](https://api.sefinek.net/api/v2/kaomoji/cat) | (=^-ω-^=) |
90
- | [dog](https://api.sefinek.net/api/v2/kaomoji/dog) | ଘ(∪・ﻌ・∪)ଓ |
91
- | [owo](https://api.sefinek.net/api/v2/kaomoji/owo) | 𝓞𝔀𝓞 |
92
- | [uwu](https://api.sefinek.net/api/v2/kaomoji/uwu) | 𝕌𝕨𝕌 |
93
- | [love](https://api.sefinek.net/api/v2/kaomoji/love) | ヽ(♡‿♡)ノ |
87
+ ### <div id="kaomoji-endpoints">» Kaomoji endpoints</div>
88
+ | Function | Link to the API | Version | Example |
89
+ |----------|:----------------------------------------------------------|:--------|-----------|
90
+ | `cat()` | [Click here](https://api.sefinek.net/api/v2/kaomoji/cat) | v2 | (=^-ω-^=) |
91
+ | `dog()` | [Click here](https://api.sefinek.net/api/v2/kaomoji/dog) | v2 | ଘ(∪・ﻌ・∪)ଓ |
92
+ | `owo()` | [Click here](https://api.sefinek.net/api/v2/kaomoji/owo) | v2 | 𝓞𝔀𝓞 |
93
+ | `uwu()` | [Click here](https://api.sefinek.net/api/v2/kaomoji/uwu) | v2 | 𝕌𝕨𝕌 |
94
+ | `love()` | [Click here](https://api.sefinek.net/api/v2/kaomoji/love) | v2 | ヽ(♡‿♡)ノ |
94
95
 
95
96
 
96
97
  ## 📝 • Changelog
@@ -0,0 +1 @@
1
+ [{"content":"🟥","name":"red_square"},{"content":"🟧","name":"orange_square"},{"content":"🟨","name":"yellow_square"},{"content":"🟩","name":"green_square"},{"content":"🟦","name":"blue_square"},{"content":"🟪","name":"purple_square"},{"content":"🟫","name":"brown_square"},{"content":"⬛","name":"black_large_square"},{"content":"⬜","name":"white_large_square"}]
@@ -0,0 +1,44 @@
1
+ const random = require('../index.js'); // Change to @sefinek/random-emoji
2
+
3
+ // Get a single random Unicode emoji.
4
+ console.log(`Single Emoji : ${random.unicode()}`);
5
+
6
+ // Retrieves a random emoji with its name, visual representation, and type
7
+ const emoji = random.emojis();
8
+ console.log(`Random Emoji : ${emoji.content}; ${emoji.name}; ${emoji.type}`);
9
+
10
+ // Get a random cat emoji
11
+ const cat = random.cats();
12
+ console.log(`Cat Emoji : ${cat.content}; ${cat.name}`);
13
+
14
+ // Get a random heart emoji
15
+ const heart = random.hearts();
16
+ console.log(`Heart Emoji : ${heart.content}; ${heart.name}`);
17
+
18
+ // Retrieves a random food emoji
19
+ const food = random.foods();
20
+ console.log(`Food Emoji : ${food.content}; ${food.name}`);
21
+
22
+ // Gets a random circle emoji
23
+ const circle = random.circles();
24
+ console.log(`Circle Emoji : ${circle.content}; ${circle.name}`);
25
+
26
+ // Gets a random squares emoji
27
+ const squares = random.squares();
28
+ console.log(`Square Emoji : ${squares.content}; ${squares.name}`);
29
+
30
+ // Fetches and displays random kaomojis using async/await syntax
31
+ (async () => {
32
+ const kaomojis = new random.Kaomojis();
33
+
34
+ // Retrieves and displays a cat face kaomoji
35
+ const kaoCat = await kaomojis.cat();
36
+ console.log(`Kaomoji Cat Face : ${kaoCat.message}`);
37
+
38
+ // Fetches and displays a random UwU kaomoji
39
+ const uwu = await kaomojis.uwu();
40
+ console.log(`Kaomoji UwU : ${uwu.message}`);
41
+ })();
42
+
43
+ // Displays the current version of the module
44
+ console.log(`Module version : v${random.version}`);
@@ -0,0 +1,53 @@
1
+ const random = require('../index.js'); // Change to @sefinek/random-emoji
2
+ const data = [];
3
+
4
+ async function displayEmojiData() {
5
+ // Get a single random Unicode emoji
6
+ data.push({ Function: 'unicode()', Emoji: random.unicode().trim() });
7
+
8
+ // Retrieves a random emoji, including its visual representation, name, and category
9
+ const emoji = random.emojis();
10
+ data.push({ Function: 'emojis()', Emoji: emoji.content.trim(), Name: emoji.name, Type: emoji.type });
11
+
12
+ // Get a random cat emoji
13
+ const cat = random.cats();
14
+ data.push({ Function: 'cats()', Emoji: cat.content.trim(), Name: cat.name });
15
+
16
+ // Get a random heart emoji
17
+ const heart = random.hearts();
18
+ data.push({ Function: 'hearts()', Emoji: heart.content.trim(), Name: heart.name });
19
+
20
+ // Retrieves a random food emoji
21
+ const food = random.foods();
22
+ data.push({ Function: 'foods()', Emoji: food.content.trim(), Name: food.name });
23
+
24
+ // Gets a random circle emoji
25
+ const circle = random.circles();
26
+ data.push({ Function: 'circles()', Emoji: circle.content.trim(), Name: circle.name });
27
+
28
+ // Gets a random squares emoji
29
+ const squares = random.squares();
30
+ data.push({ Function: 'squares()', Emoji: squares.content.trim(), Name: squares.name });
31
+
32
+
33
+ // Fetches random kaomojis
34
+ const kaomojis = new random.Kaomojis();
35
+ const kaoCat = await kaomojis.cat();
36
+ data.push({ Function: 'cat()', Emoji: kaoCat.message.trim(), Name: 'Cat face' });
37
+
38
+ const uwu = await kaomojis.uwu();
39
+ data.push({ Function: 'uwu()', Emoji: uwu.message.trim(), Name: 'UwU' });
40
+
41
+
42
+ // Displays the table
43
+ console.table(data);
44
+ }
45
+
46
+ try {
47
+ displayEmojiData().then(() => {
48
+ // Displays the current version of the module
49
+ console.log(`Module version: v${random.version}`);
50
+ });
51
+ } catch (err) {
52
+ throw new Error(err);
53
+ }
package/index.d.ts CHANGED
@@ -1,22 +1,71 @@
1
1
  declare module '@sefinek/random-emoji' {
2
- // Unicode
3
- export function unicode(): string;
4
-
5
-
6
- // Random emojis
7
- export interface Emoji {
2
+ /**
3
+ * Interface representing an emoji with a name, content, and type.
4
+ * Used in the emoji collection to provide more detailed information about each emoji.
5
+ */
6
+ export interface EmojisCollection {
8
7
  content: string;
9
8
  name: string;
10
9
  type: string;
11
10
  }
12
- export function emojis(): Emoji;
13
- export function cats(): Emoji;
14
- export function hearts(): Emoji;
15
- export function foods(): Emoji;
16
- export function circles(): Emoji;
17
11
 
12
+ /**
13
+ * Interface representing an emoji with a name and content.
14
+ * Used for simpler emoji categories like cats, hearts, etc.
15
+ */
16
+ export interface Emojis {
17
+ content: string;
18
+ name: string;
19
+ }
20
+
21
+ /**
22
+ * Returns a random emoji from a large collection.
23
+ * Each emoji includes its name and type.
24
+ * @returns {EmojisCollection} A random emoji from the collection.
25
+ */
26
+ export function emojis(): EmojisCollection;
27
+
28
+ /**
29
+ * Returns a random cat emoji.
30
+ * @returns {Emojis} A random cat emoji.
31
+ */
32
+ export function cats(): Emojis;
33
+
34
+ /**
35
+ * Returns a random circle emoji.
36
+ * @returns {Emojis} A random circle emoji.
37
+ */
38
+ export function circles(): Emojis;
18
39
 
19
- // Kaomojis
40
+ /**
41
+ * Returns a random food emoji.
42
+ * @returns {Emojis} A random food emoji.
43
+ */
44
+ export function foods(): Emojis;
45
+
46
+ /**
47
+ * Returns a random heart emoji.
48
+ * @returns {Emojis} A random heart emoji.
49
+ */
50
+ export function hearts(): Emojis;
51
+
52
+ /**
53
+ * Returns a random square emoji.
54
+ * @returns {Emojis} A random square emoji.
55
+ */
56
+ export function squares(): Emojis;
57
+
58
+
59
+ /**
60
+ * Returns a random Unicode emoji character.
61
+ * @returns {string} A random Unicode emoji character.
62
+ */
63
+ export function unicode(): string;
64
+
65
+ /**
66
+ * Interface representing the response from an API endpoint.
67
+ * Includes information about the success status, API category, and response message.
68
+ */
20
69
  export interface ApiResponse {
21
70
  success: boolean;
22
71
  status: number;
@@ -26,14 +75,24 @@ declare module '@sefinek/random-emoji' {
26
75
  };
27
76
  message: string;
28
77
  }
78
+
79
+ /**
80
+ * Kaomojis class for accessing various random content endpoints.
81
+ * Allows fetching of random kaomojis from specified endpoints.
82
+ */
29
83
  export class Kaomojis {
30
- cat(): Promise<ApiResponse>;
31
- owo(): Promise<ApiResponse>;
32
- uwu(): Promise<ApiResponse>;
33
- love(): Promise<ApiResponse>;
34
- }
84
+ constructor();
35
85
 
86
+ /**
87
+ * Dynamically generated methods for accessing random content endpoints.
88
+ * Each method returns a Promise that resolves to an ApiResponse.
89
+ * @returns {Promise<ApiResponse>} A promise resolving to the API response.
90
+ */
91
+ [endpoint: string]: () => Promise<ApiResponse>;
92
+ }
36
93
 
37
- // Other
94
+ /**
95
+ * The current version of the module.
96
+ */
38
97
  export const version: string;
39
- }
98
+ }
package/index.js CHANGED
@@ -1,26 +1,22 @@
1
1
  const { get } = require('https');
2
- const emojis = require('./data/emoji/random.json');
3
- const unicode = require('./data/emoji/unicode.json');
4
- const cats = require('./data/emoji/cat.json');
5
- const hearts = require('./data/emoji/heart.json');
6
- const foods = require('./data/emoji/food.json');
7
- const circles = require('./data/emoji/circle.json');
2
+ const emojis = {
3
+ emojis: require('./data/emoji/collection/big.json'),
4
+ cats: require('./data/emoji/cat.json'),
5
+ foods: require('./data/emoji/food.json'),
6
+ hearts: require('./data/emoji/heart.json'),
7
+ circles: require('./data/emoji/circle.json'),
8
+ squares: require('./data/emoji/square.json'),
9
+ unicode: require('./data/emoji/collection/single.json'),
10
+ };
8
11
  const endpoints = require('./data/endpoints.json');
9
12
  const { version } = require('./package.json');
10
13
 
11
- /**
12
- * Configuration options for HTTP requests.
13
- * @type {Object}
14
- */
15
- const options = {
14
+ const httpOptions = {
16
15
  method: 'GET',
17
- port: 443,
18
16
  headers: {
19
- 'User-Agent': `random-emoji/${version} (+https://github.com/sefinek24/random-emoji)`,
17
+ 'User-Agent': `Mozilla/5.0 (compatible; random-emoji/${version}; +https://github.com/sefinek24/random-emoji)`,
20
18
  'Accept': 'application/json',
21
19
  'Cache-Control': 'no-cache',
22
- 'CF-IPCountry': 'false',
23
- 'CF-Visitor': '{"scheme":"https"}',
24
20
  'Connection': 'keep-alive',
25
21
  'DNT': '1',
26
22
  'Pragma': 'no-cache',
@@ -31,105 +27,39 @@ const options = {
31
27
  },
32
28
  };
33
29
 
34
- /**
35
- * Fetch content from a given URL using HTTP GET.
36
- * @param {string} url - The URL to fetch content from.
37
- * @returns {Promise} - A Promise that resolves with the fetched JSON data or rejects with an error.
38
- */
39
- function getContent(url) {
40
- return new Promise((resolve, reject) => {
41
- const req = get(url, options, res => {
42
- if (res.statusCode !== 200) {
43
- reject(`Request failed with status code ${res.statusCode}.`);
44
- return;
45
- }
46
-
47
- res.setEncoding('utf8');
48
30
 
49
- let rawData = '';
50
- res.on('data', chunk => {
51
- rawData += chunk;
52
- });
31
+ async function getContent(url) {
32
+ const res = await new Promise((resolve, reject) => {
33
+ const req = get(url, httpOptions, resolve);
34
+ req.on('error', reject);
35
+ req.end();
36
+ });
53
37
 
54
- res.on('end', () => {
55
- try {
56
- resolve(JSON.parse(rawData));
57
- } catch (err) {
58
- reject(err.message);
59
- }
60
- });
61
- });
38
+ if (res.statusCode !== 200) {
39
+ throw new Error(`Request failed with status code ${res.statusCode}`);
40
+ }
62
41
 
63
- req.on('error', err => {
64
- reject(err);
65
- });
42
+ res.setEncoding('utf8');
43
+ let rawData = '';
44
+ for await (const chunk of res) {
45
+ rawData += chunk;
46
+ }
66
47
 
67
- req.end();
68
- });
48
+ return JSON.parse(rawData);
69
49
  }
70
50
 
71
- /**
72
- * SefinekAPI class for accessing various random content endpoints.
73
- * @class
74
- */
75
51
  class SefinekAPI {
76
52
  constructor() {
77
- Object.keys(endpoints).forEach(endpoint => {
78
- /**
79
- * Access a specific random content endpoint.
80
- * @method
81
- * @returns {Promise} - A Promise that resolves with the fetched content or rejects with an error.
82
- */
83
- this[endpoint] = () => getContent(`https://api.sefinek.net/api/v2/random/${endpoints[endpoint]}`);
53
+ Object.entries(endpoints).forEach(([key, endpoint]) => {
54
+ this[key] = () => getContent(`https://api.sefinek.net/api/v2/random/${endpoint}`);
84
55
  });
85
56
  }
86
57
  }
87
58
 
88
59
  module.exports = {
89
- /**
90
- * Get a random Unicode emoji.
91
- * @returns {string} - A random Unicode emoji.
92
- */
93
- unicode: () => unicode[Math.floor(Math.random() * unicode.length)],
94
-
95
- /**
96
- * Get a random emoji.
97
- * @returns {object} - A random emoji.
98
- */
99
- emojis: () => emojis[Math.floor(Math.random() * emojis.length)],
100
-
101
- /**
102
- * Get a random cat emoji.
103
- * @returns {object} - A random cat emoji.
104
- */
105
- cats: () => cats[Math.floor(Math.random() * cats.length)],
106
-
107
- /**
108
- * Get a random heart emoji.
109
- * @returns {object} - A random heart emoji.
110
- */
111
- hearts: () => hearts[Math.floor(Math.random() * hearts.length)],
112
-
113
- /**
114
- * Get a random food emoji.
115
- * @returns {object} - A random food emoji.
116
- */
117
- foods: () => foods[Math.floor(Math.random() * foods.length)],
118
-
119
- /**
120
- * Get a random circle emoji.
121
- * @returns {object} - A random circle emoji.
122
- */
123
- circles: () => circles[Math.floor(Math.random() * circles.length)],
124
-
125
- /**
126
- * Access various random content endpoints using the SefinekAPI class.
127
- */
60
+ ...Object.fromEntries(Object.entries(emojis).map(([key, value]) => [
61
+ key, () => value[Math.floor(Math.random() * value.length)],
62
+ ])),
128
63
  Kaomojis: SefinekAPI,
129
-
130
- /**
131
- * Get the module version.
132
- * @returns {string} - Returns the package version.
133
- */
134
64
  version,
135
65
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sefinek/random-emoji",
3
- "version": "2.0.4",
4
- "description": "A module providing various random emoticons along with their names and types. Additionally, it also includes random kaomoji.",
3
+ "version": "2.1.0",
4
+ "description": "A module offering a range of random emoticons, complete with their names and categories. Additionally, it also includes random kaomoji.",
5
5
  "keywords": [
6
6
  "random",
7
7
  "emoji",
@@ -30,19 +30,8 @@
30
30
  "license": "MIT",
31
31
  "author": "Sefinek <contact@sefinek.net> (https://sefinek.net)",
32
32
  "main": "index.js",
33
- "types": "./index.d.ts",
34
- "directories": {
35
- "data": "data"
36
- },
37
- "files": [
38
- "data/",
39
- "example.js",
40
- "index.d.ts",
41
- "index.js",
42
- "LICENSE",
43
- "README.md"
44
- ],
33
+ "typings": "./index.d.ts",
45
34
  "scripts": {
46
- "test": "node example.js"
35
+ "test": "node examples/main.js"
47
36
  }
48
37
  }
package/example.js DELETED
@@ -1,38 +0,0 @@
1
- const random = require('./index.js'); // Change to @sefinek/random-emoji
2
-
3
- // A single emoji
4
- console.log(random.unicode());
5
-
6
- // Random emoji with name and type
7
- const emoji = random.emojis();
8
- console.log(`Name: ${emoji.name}; Emoji: ${emoji.content};`);
9
-
10
- // Random cat
11
- const cat = random.cats();
12
- console.log(`Name: ${cat.name}; Emoji: ${cat.content};`);
13
-
14
- // Random heart
15
- const heart = random.hearts();
16
- console.log(`Name: ${heart.name}; Emoji: ${heart.content};`);
17
-
18
- // Random food
19
- const food = random.foods();
20
- console.log(`Name: ${food.name}; Emoji: ${food.content};`);
21
-
22
- // Random circle
23
- const circle = random.circles();
24
- console.log(`Name: ${circle.name}; Emoji: ${circle.content};`);
25
-
26
- // Random kaomoji
27
- (async () => {
28
- const kaomojis = new random.Kaomojis();
29
-
30
- const kaoCat = await kaomojis.cat();
31
- console.log(`Cat face: ${kaoCat.message}`);
32
-
33
- const uwu = await kaomojis.uwu();
34
- console.log(`Random UwU: ${uwu.message}`);
35
- })();
36
-
37
- // Version
38
- console.log(`Module version: ${random.version}`);
File without changes