kythia-core 0.9.5-beta → 0.10.1-beta

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.
@@ -1,34 +1,34 @@
1
1
  const discordColors = {
2
- Default: 0x000000,
3
- White: 0xffffff,
4
- Aqua: 0x1abc9c,
5
- Green: 0x57f287,
6
- Blue: 0x3498db,
7
- Yellow: 0xfee75c,
8
- Purple: 0x9b59b6,
9
- LuminousVividPink: 0xe91e63,
10
- Fuchsia: 0xeb459e,
11
- Gold: 0xf1c40f,
12
- Orange: 0xe67e22,
13
- Red: 0xed4245,
14
- Grey: 0x95a5a6,
15
- Navy: 0x34495e,
16
- DarkAqua: 0x11806a,
17
- DarkGreen: 0x1f8b4c,
18
- DarkBlue: 0x206694,
19
- DarkPurple: 0x71368a,
20
- DarkVividPink: 0xad1457,
21
- DarkGold: 0xc27c0e,
22
- DarkOrange: 0xa84300,
23
- DarkRed: 0x992d22,
24
- DarkGrey: 0x979c9f,
25
- DarkerGrey: 0x7f8c8d,
26
- LightGrey: 0xbcc0c0,
27
- DarkNavy: 0x2c3e50,
28
- Blurple: 0x5865f2,
29
- Greyple: 0x99aab5,
30
- DarkButNotBlack: 0x2c2f33,
31
- NotQuiteBlack: 0x23272a,
2
+ Default: 0x000000,
3
+ White: 0xffffff,
4
+ Aqua: 0x1abc9c,
5
+ Green: 0x57f287,
6
+ Blue: 0x3498db,
7
+ Yellow: 0xfee75c,
8
+ Purple: 0x9b59b6,
9
+ LuminousVividPink: 0xe91e63,
10
+ Fuchsia: 0xeb459e,
11
+ Gold: 0xf1c40f,
12
+ Orange: 0xe67e22,
13
+ Red: 0xed4245,
14
+ Grey: 0x95a5a6,
15
+ Navy: 0x34495e,
16
+ DarkAqua: 0x11806a,
17
+ DarkGreen: 0x1f8b4c,
18
+ DarkBlue: 0x206694,
19
+ DarkPurple: 0x71368a,
20
+ DarkVividPink: 0xad1457,
21
+ DarkGold: 0xc27c0e,
22
+ DarkOrange: 0xa84300,
23
+ DarkRed: 0x992d22,
24
+ DarkGrey: 0x979c9f,
25
+ DarkerGrey: 0x7f8c8d,
26
+ LightGrey: 0xbcc0c0,
27
+ DarkNavy: 0x2c3e50,
28
+ Blurple: 0x5865f2,
29
+ Greyple: 0x99aab5,
30
+ DarkButNotBlack: 0x2c2f33,
31
+ NotQuiteBlack: 0x23272a,
32
32
  };
33
33
 
34
34
  /**
@@ -39,138 +39,142 @@ const discordColors = {
39
39
  * @returns {string|number|{r:number,g:number,b:number}} The converted color.
40
40
  */
41
41
  function convertColor(input, { from, to }) {
42
- function hexToRgb(hex) {
43
- let h = hex.replace(/^#/, '');
44
- if (h.length === 3) {
45
- h = h
46
- .split('')
47
- .map((x) => x + x)
48
- .join('');
49
- }
50
- if (!/^[0-9a-fA-F]{6}$/.test(h)) throw new Error('Invalid hex color');
51
- return {
52
- r: parseInt(h.slice(0, 2), 16),
53
- g: parseInt(h.slice(2, 4), 16),
54
- b: parseInt(h.slice(4, 6), 16),
55
- };
56
- }
42
+ function hexToRgb(hex) {
43
+ let h = hex.replace(/^#/, '');
44
+ if (h.length === 3) {
45
+ h = h
46
+ .split('')
47
+ .map((x) => x + x)
48
+ .join('');
49
+ }
50
+ if (!/^[0-9a-fA-F]{6}$/.test(h)) throw new Error('Invalid hex color');
51
+ return {
52
+ r: parseInt(h.slice(0, 2), 16),
53
+ g: parseInt(h.slice(2, 4), 16),
54
+ b: parseInt(h.slice(4, 6), 16),
55
+ };
56
+ }
57
57
 
58
- function rgbToHex({ r, g, b }) {
59
- if (
60
- typeof r !== 'number' ||
61
- typeof g !== 'number' ||
62
- typeof b !== 'number' ||
63
- r < 0 ||
64
- r > 255 ||
65
- g < 0 ||
66
- g > 255 ||
67
- b < 0 ||
68
- b > 255
69
- )
70
- throw new Error('Invalid RGB color');
71
- return (
72
- '#' +
73
- [r, g, b]
74
- .map((x) => {
75
- const hex = x.toString(16);
76
- return hex.length === 1 ? '0' + hex : hex;
77
- })
78
- .join('')
79
- .toUpperCase()
80
- );
81
- }
58
+ function rgbToHex({ r, g, b }) {
59
+ if (
60
+ typeof r !== 'number' ||
61
+ typeof g !== 'number' ||
62
+ typeof b !== 'number' ||
63
+ r < 0 ||
64
+ r > 255 ||
65
+ g < 0 ||
66
+ g > 255 ||
67
+ b < 0 ||
68
+ b > 255
69
+ )
70
+ throw new Error('Invalid RGB color');
71
+ return (
72
+ '#' +
73
+ [r, g, b]
74
+ .map((x) => {
75
+ const hex = x.toString(16);
76
+ return hex.length === 1 ? `0${hex}` : hex;
77
+ })
78
+ .join('')
79
+ .toUpperCase()
80
+ );
81
+ }
82
82
 
83
- function hexToDecimal(hex) {
84
- let h = hex.replace(/^#/, '');
85
- if (h.length === 3) {
86
- h = h
87
- .split('')
88
- .map((x) => x + x)
89
- .join('');
90
- }
91
- if (!/^[0-9a-fA-F]{6}$/.test(h)) throw new Error('Invalid hex color');
92
- return Number('0x' + h.toUpperCase());
93
- }
83
+ function hexToDecimal(hex) {
84
+ let h = hex.replace(/^#/, '');
85
+ if (h.length === 3) {
86
+ h = h
87
+ .split('')
88
+ .map((x) => x + x)
89
+ .join('');
90
+ }
91
+ if (!/^[0-9a-fA-F]{6}$/.test(h)) throw new Error('Invalid hex color');
92
+ return Number(`0x${h.toUpperCase()}`);
93
+ }
94
94
 
95
- function decimalToHex(decimal) {
96
- if (typeof decimal !== 'number' || decimal < 0 || decimal > 0xffffff) throw new Error('Invalid decimal color');
97
- let hex = decimal.toString(16).toUpperCase();
98
- while (hex.length < 6) hex = '0' + hex;
99
- return '#' + hex;
100
- }
95
+ function decimalToHex(decimal) {
96
+ if (typeof decimal !== 'number' || decimal < 0 || decimal > 0xffffff)
97
+ throw new Error('Invalid decimal color');
98
+ let hex = decimal.toString(16).toUpperCase();
99
+ while (hex.length < 6) hex = `0${hex}`;
100
+ return `#${hex}`;
101
+ }
101
102
 
102
- function rgbToDecimal({ r, g, b }) {
103
- if (
104
- typeof r !== 'number' ||
105
- typeof g !== 'number' ||
106
- typeof b !== 'number' ||
107
- r < 0 ||
108
- r > 255 ||
109
- g < 0 ||
110
- g > 255 ||
111
- b < 0 ||
112
- b > 255
113
- )
114
- throw new Error('Invalid RGB color');
115
- return (r << 16) + (g << 8) + b;
116
- }
103
+ function rgbToDecimal({ r, g, b }) {
104
+ if (
105
+ typeof r !== 'number' ||
106
+ typeof g !== 'number' ||
107
+ typeof b !== 'number' ||
108
+ r < 0 ||
109
+ r > 255 ||
110
+ g < 0 ||
111
+ g > 255 ||
112
+ b < 0 ||
113
+ b > 255
114
+ )
115
+ throw new Error('Invalid RGB color');
116
+ return (r << 16) + (g << 8) + b;
117
+ }
117
118
 
118
- function decimalToRgb(decimal) {
119
- if (typeof decimal !== 'number' || decimal < 0 || decimal > 0xffffff) throw new Error('Invalid decimal color');
120
- return {
121
- r: (decimal >> 16) & 0xff,
122
- g: (decimal >> 8) & 0xff,
123
- b: decimal & 0xff,
124
- };
125
- }
119
+ function decimalToRgb(decimal) {
120
+ if (typeof decimal !== 'number' || decimal < 0 || decimal > 0xffffff)
121
+ throw new Error('Invalid decimal color');
122
+ return {
123
+ r: (decimal >> 16) & 0xff,
124
+ g: (decimal >> 8) & 0xff,
125
+ b: decimal & 0xff,
126
+ };
127
+ }
126
128
 
127
- if (from === to) return input;
129
+ if (from === to) return input;
128
130
 
129
- let rgb, hex, decimal;
131
+ let rgb, hex, decimal;
130
132
 
131
- switch (from) {
132
- case 'hex':
133
- hex = input;
134
- rgb = hexToRgb(hex);
135
- decimal = hexToDecimal(hex);
136
- break;
137
- case 'rgb':
138
- rgb = input;
139
- hex = rgbToHex(rgb);
140
- decimal = rgbToDecimal(rgb);
141
- break;
142
- case 'decimal':
143
- decimal = input;
144
- hex = decimalToHex(decimal);
145
- rgb = decimalToRgb(decimal);
146
- break;
147
- case 'discord':
148
- if (typeof input === 'string') {
149
- const key = Object.keys(discordColors).find((k) => k.toLowerCase() === input.toLowerCase());
150
- if (!key) throw new Error(`Invalid Discord color name: ${input}`);
151
- decimal = discordColors[key];
152
- } else if (typeof input === 'number') {
153
- decimal = input;
154
- } else {
155
- throw new Error('Invalid input type for Discord color');
156
- }
157
- hex = decimalToHex(decimal);
158
- rgb = decimalToRgb(decimal);
159
- break;
160
- default:
161
- throw new Error(`Invalid "from" color type: ${from}`);
162
- }
133
+ switch (from) {
134
+ case 'hex':
135
+ hex = input;
136
+ rgb = hexToRgb(hex);
137
+ decimal = hexToDecimal(hex);
138
+ break;
139
+ case 'rgb':
140
+ rgb = input;
141
+ hex = rgbToHex(rgb);
142
+ decimal = rgbToDecimal(rgb);
143
+ break;
144
+ case 'decimal':
145
+ decimal = input;
146
+ hex = decimalToHex(decimal);
147
+ rgb = decimalToRgb(decimal);
148
+ break;
149
+ case 'discord':
150
+ if (typeof input === 'string') {
151
+ const key = Object.keys(discordColors).find(
152
+ (k) => k.toLowerCase() === input.toLowerCase(),
153
+ );
154
+ if (!key) throw new Error(`Invalid Discord color name: ${input}`);
155
+ decimal = discordColors[key];
156
+ } else if (typeof input === 'number') {
157
+ decimal = input;
158
+ } else {
159
+ throw new Error('Invalid input type for Discord color');
160
+ }
161
+ hex = decimalToHex(decimal);
162
+ rgb = decimalToRgb(decimal);
163
+ break;
164
+ default:
165
+ throw new Error(`Invalid "from" color type: ${from}`);
166
+ }
163
167
 
164
- switch (to) {
165
- case 'hex':
166
- return hex;
167
- case 'rgb':
168
- return rgb;
169
- case 'decimal':
170
- return decimal;
171
- default:
172
- throw new Error(`Invalid "to" color type: ${to}`);
173
- }
168
+ switch (to) {
169
+ case 'hex':
170
+ return hex;
171
+ case 'rgb':
172
+ return rgb;
173
+ case 'decimal':
174
+ return decimal;
175
+ default:
176
+ throw new Error(`Invalid "to" color type: ${to}`);
177
+ }
174
178
  }
175
179
 
176
180
  module.exports = convertColor;
@@ -4,47 +4,47 @@
4
4
  * @returns {string} Converted text using tiny letters.
5
5
  */
6
6
  function toTinyText(text) {
7
- const normal = 'abcdefghijklmnopqrstuvwxyz';
8
- const tiny = [
9
- 'ᴀ',
10
- 'ʙ',
11
- 'ᴄ',
12
- 'ᴅ',
13
- 'ᴇ',
14
- 'ғ',
15
- 'ɢ',
16
- 'ʜ',
17
- 'ɪ',
18
- 'ᴊ',
19
- 'ᴋ',
20
- 'ʟ',
21
- 'ᴍ',
22
- 'ɴ',
23
- 'ᴏ',
24
- 'ᴘ',
25
- 'ǫ',
26
- 'ʀ',
27
- 's',
28
- 'ᴛ',
29
- 'ᴜ',
30
- 'ᴠ',
31
- 'ᴡ',
32
- 'x',
33
- 'ʏ',
34
- 'ᴢ',
35
- ];
7
+ const normal = 'abcdefghijklmnopqrstuvwxyz';
8
+ const tiny = [
9
+ 'ᴀ',
10
+ 'ʙ',
11
+ 'ᴄ',
12
+ 'ᴅ',
13
+ 'ᴇ',
14
+ 'ғ',
15
+ 'ɢ',
16
+ 'ʜ',
17
+ 'ɪ',
18
+ 'ᴊ',
19
+ 'ᴋ',
20
+ 'ʟ',
21
+ 'ᴍ',
22
+ 'ɴ',
23
+ 'ᴏ',
24
+ 'ᴘ',
25
+ 'ǫ',
26
+ 'ʀ',
27
+ 's',
28
+ 'ᴛ',
29
+ 'ᴜ',
30
+ 'ᴠ',
31
+ 'ᴡ',
32
+ 'x',
33
+ 'ʏ',
34
+ 'ᴢ',
35
+ ];
36
36
 
37
- return text
38
- .split('')
39
- .map((char) => {
40
- const lowerChar = char.toLowerCase();
41
- const index = normal.indexOf(lowerChar);
42
- if (index !== -1) {
43
- return tiny[index];
44
- }
45
- return char;
46
- })
47
- .join('');
37
+ return text
38
+ .split('')
39
+ .map((char) => {
40
+ const lowerChar = char.toLowerCase();
41
+ const index = normal.indexOf(lowerChar);
42
+ if (index !== -1) {
43
+ return tiny[index];
44
+ }
45
+ return char;
46
+ })
47
+ .join('');
48
48
  }
49
49
 
50
50
  /**
@@ -53,47 +53,47 @@ function toTinyText(text) {
53
53
  * @returns {string} Converted text using bold tiny letters.
54
54
  */
55
55
  function toTinyBoldText(text) {
56
- const normal = 'abcdefghijklmnopqrstuvwxyz';
57
- const tinyBold = [
58
- '𝗮',
59
- '𝗯',
60
- '𝗰',
61
- '𝗱',
62
- '𝗲',
63
- '𝗳',
64
- '𝗴',
65
- '𝗵',
66
- '𝗶',
67
- '𝗷',
68
- '𝗸',
69
- '𝗹',
70
- '𝗺',
71
- '𝗻',
72
- '𝗼',
73
- '𝗽',
74
- '𝗾',
75
- '𝗿',
76
- '𝘀',
77
- '𝘁',
78
- '𝘂',
79
- '𝘃',
80
- '𝘄',
81
- '𝘅',
82
- '𝘆',
83
- '𝘇',
84
- ];
56
+ const normal = 'abcdefghijklmnopqrstuvwxyz';
57
+ const tinyBold = [
58
+ '𝗮',
59
+ '𝗯',
60
+ '𝗰',
61
+ '𝗱',
62
+ '𝗲',
63
+ '𝗳',
64
+ '𝗴',
65
+ '𝗵',
66
+ '𝗶',
67
+ '𝗷',
68
+ '𝗸',
69
+ '𝗹',
70
+ '𝗺',
71
+ '𝗻',
72
+ '𝗼',
73
+ '𝗽',
74
+ '𝗾',
75
+ '𝗿',
76
+ '𝘀',
77
+ '𝘁',
78
+ '𝘂',
79
+ '𝘃',
80
+ '𝘄',
81
+ '𝘅',
82
+ '𝘆',
83
+ '𝘇',
84
+ ];
85
85
 
86
- return text
87
- .split('')
88
- .map((char) => {
89
- const lowerChar = char.toLowerCase();
90
- const index = normal.indexOf(lowerChar);
91
- if (index !== -1) {
92
- return tinyBold[index];
93
- }
94
- return char;
95
- })
96
- .join('');
86
+ return text
87
+ .split('')
88
+ .map((char) => {
89
+ const lowerChar = char.toLowerCase();
90
+ const index = normal.indexOf(lowerChar);
91
+ if (index !== -1) {
92
+ return tinyBold[index];
93
+ }
94
+ return char;
95
+ })
96
+ .join('');
97
97
  }
98
98
 
99
- module.export = { toTinyText, toTinyBoldText };
99
+ module.export = { toTinyText, toTinyBoldText };
@@ -1,4 +1,4 @@
1
1
  module.exports = {
2
- color: require('./color.js'),
3
- formatter: require('./formatter.js'),
2
+ color: require('./color.js'),
3
+ formatter: require('./formatter.js'),
4
4
  };