rich-helper 1.0.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/.gitignore +10 -0
- package/LICENSE +7 -0
- package/README.md +28 -0
- package/for_esm.mjs +3 -0
- package/help.html +393 -0
- package/index.js +68 -0
- package/modules/70 1337 (453.js +31 -0
- package/modules/ascii_percentage.js +8 -0
- package/modules/custom_error.js +9 -0
- package/modules/delete_all_nonalphanumeric.js +6 -0
- package/modules/delete_all_vowels.js +8 -0
- package/modules/delete_duplicates.js +11 -0
- package/modules/factorial.js +11 -0
- package/modules/font_converter.js +18 -0
- package/modules/from_capital_letter.js +6 -0
- package/modules/from_capital_letter_ew.js +10 -0
- package/modules/in_range.js +5 -0
- package/modules/is_ascii.js +5 -0
- package/modules/markdown_to_html.js +37 -0
- package/modules/object_stats.js +20 -0
- package/modules/pallindrome.js +10 -0
- package/modules/random.js +9 -0
- package/modules/random_int.js +7 -0
- package/modules/random_string.js +18 -0
- package/modules/recurse_reverse.js +7 -0
- package/modules/reverse_string.js +5 -0
- package/modules/sleep.js +5 -0
- package/modules/stringcut.js +6 -0
- package/modules/styled_console.js +63 -0
- package/modules/throw_error_only.js +6 -0
- package/modules/to_ascii.js +12 -0
- package/modules/to_camel_case.js +7 -0
- package/modules/to_kebab_case.js +11 -0
- package/modules/to_percentage.js +5 -0
- package/modules/to_snake_case.js +11 -0
- package/modules/trim.js +10 -0
- package/modules/typed_functions.js +43 -0
- package/modules/url_safe.js +5 -0
- package/package.json +36 -0
- package/rich-helper v1.0.0 +0 -0
package/.gitignore
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
MIT License 🎈
|
|
2
|
+
|
|
3
|
+
Copyright © 2026 NPMUCK You. All rights reversed. 😘
|
|
4
|
+
|
|
5
|
+
You can use rich-helper for any purpose, excluding illegal. You may copy, modify, share or do any other actions with rich-helper. Note that you must keep the original license when you copy, modify or share. ⚠️
|
|
6
|
+
|
|
7
|
+
rich-helper WORKS AS IS. NO WARRANTIES, GUARANTIES OR ANY OTHER LEGAL SHIT. WE RECOMMEND INSTEAD OF READING THIS FUCK GOTO help.html. 🙂
|
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# rich-helper
|
|
2
|
+
**rich-helper is a rich utility with many features.**
|
|
3
|
+
|
|
4
|
+
***
|
|
5
|
+
|
|
6
|
+
* Custom errors
|
|
7
|
+
* String manipulations
|
|
8
|
+
* ASCII manipulations
|
|
9
|
+
* Styled console
|
|
10
|
+
* And bulk more!
|
|
11
|
+
|
|
12
|
+
***
|
|
13
|
+
|
|
14
|
+
```Js
|
|
15
|
+
const rh = require("rich-helper")
|
|
16
|
+
const string = "Hello! 🙂"
|
|
17
|
+
const reversed = rh.reverseString(string)
|
|
18
|
+
rh.styledConsole.info(reversed) // 🙂 !olleH
|
|
19
|
+
|
|
20
|
+
if (!rh.ascii(string)) {
|
|
21
|
+
throw new rh.CustomError("NonAscii", string + " is not ascii!") // Will throw NonAscii: Hello! 🙂 is not ascii!
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
***
|
|
26
|
+
|
|
27
|
+
Uses the MIT license, more info in [LICENSE](LICENSE) or [help.html](help.html).
|
|
28
|
+
For how-to-use, examples, and other data visit [help.html](help.html).
|
package/for_esm.mjs
ADDED
package/help.html
ADDED
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html id="EichTea">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<style>
|
|
6
|
+
|
|
7
|
+
* {
|
|
8
|
+
font-family: Arial, sans-serif, serif;
|
|
9
|
+
overflow-wrap: break-word;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
*::selection {
|
|
13
|
+
background-color: #ff00ff;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
body {
|
|
17
|
+
position: relative;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
details {
|
|
21
|
+
background: #B8C5FF;
|
|
22
|
+
border-radius: 8px;
|
|
23
|
+
width: 90vw;
|
|
24
|
+
margin: 10px;
|
|
25
|
+
transition: background 0.1s ease;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
summary {
|
|
29
|
+
list-style: none;
|
|
30
|
+
position: relative;
|
|
31
|
+
line-height: 40px;
|
|
32
|
+
padding-left: 10px;
|
|
33
|
+
font-weight: 900;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
summary::after {
|
|
37
|
+
content: '▼';
|
|
38
|
+
position: absolute;
|
|
39
|
+
right: 10px;
|
|
40
|
+
font-size: 30px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
body > details[open] > summary::after {
|
|
44
|
+
content: '▲';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
details:hover {
|
|
48
|
+
background: #A4C5FF;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
b {
|
|
52
|
+
font-weight: 900;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
img {
|
|
56
|
+
position: absolute;
|
|
57
|
+
width: 100px;
|
|
58
|
+
height: 80px;
|
|
59
|
+
top: 1%;
|
|
60
|
+
right: 4%;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
ol {
|
|
64
|
+
margin: 0px;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
li {
|
|
68
|
+
margin: 15px;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
pre {
|
|
72
|
+
white-space: pre-wrap;
|
|
73
|
+
margin: 4px;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
#beautifulTransformer {
|
|
77
|
+
width: 150px;
|
|
78
|
+
height: 150px;
|
|
79
|
+
background: red;
|
|
80
|
+
transition: background 5s ease;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.oooops {
|
|
84
|
+
margin-left: 28px;
|
|
85
|
+
font-weight: 700;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.oooooooops {
|
|
89
|
+
margin-left: 26px;
|
|
90
|
+
font-weight: 500;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
details .under {
|
|
94
|
+
width: 70vw;
|
|
95
|
+
background-color: #885388;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.under > summary::after {
|
|
99
|
+
content: "▼";
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.under[open] > summary::after {
|
|
103
|
+
content: '▲'
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.chapterName {
|
|
107
|
+
text-decoration: underline;
|
|
108
|
+
color: blue;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
input[type="number"] {
|
|
112
|
+
width: 45px;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
</style>
|
|
116
|
+
</head>
|
|
117
|
+
<body>
|
|
118
|
+
<h1>rich-helper 1.0.0</h1>
|
|
119
|
+
<img src="https://i.imgur.com/OIoUZjX.jpg" alt="NPMUCK You logo" onclick="window.location.href = 'https://discord.gg/BhMJRxK7sy'" />
|
|
120
|
+
<b>rich-helper</b> is a rich utility with many features.<br />
|
|
121
|
+
<br /> <hr /> <br />
|
|
122
|
+
<details>
|
|
123
|
+
<summary>General Info</summary>
|
|
124
|
+
<div class="oooops">
|
|
125
|
+
<b>rich-helper</b> is ideal select for people who wanna less problemz. <br />
|
|
126
|
+
Head up on <span class="chapterName" onclick="let gib = document.getElementById('methodsList'); gib.open = true; gib.style.border = '2px solid blue'; setTimeout((() => { gib.style.border = 'none' }), 300)">Methods</span> to see list of methods.<br />
|
|
127
|
+
It's compatible with both import and require.<br />
|
|
128
|
+
We have 32 methods.<br />
|
|
129
|
+
We also have CLI commands, use <input readonly value="npm run commands rich-helper"> for help.
|
|
130
|
+
<br /><br />
|
|
131
|
+
Did you know that <b>rich-helper</b> is our first library?
|
|
132
|
+
<br /><br />
|
|
133
|
+
<a href="https://discord.gg/BhMJRxK7sy">Join our Discord server</a>
|
|
134
|
+
</div>
|
|
135
|
+
</details>
|
|
136
|
+
|
|
137
|
+
<details id="methodsList">
|
|
138
|
+
<summary>Methods</summary>
|
|
139
|
+
<div class="oooops">
|
|
140
|
+
|
|
141
|
+
<details class="under">
|
|
142
|
+
<summary>All</summary>
|
|
143
|
+
<div class="oooops">
|
|
144
|
+
<ol>
|
|
145
|
+
<li>new rh.CustomError(err, msg) - gives a custom error.</li>
|
|
146
|
+
<li>rh.reverseString(string) - reverses string.</li>
|
|
147
|
+
<li>rh.recverse(array) - recursiveley reverses array and all enclosed in it arrays. (Copy, not mutes original)</li>
|
|
148
|
+
<li>rh.ascii(string) - is the provided string fully wroten in ASCII?</li>
|
|
149
|
+
<li>rh.toPercentage(is, of) - turns it to percentage, for example rh.toPercentage(20, 50) -> 40.</li>
|
|
150
|
+
<li>rh.asciiPercentage(text) - how many percent of ur string is ASCII?</li>
|
|
151
|
+
<li>rh.toASCII(text) - turns your text to ASCII.</li>
|
|
152
|
+
<li>rh.styledConsole["log" | "info" | "error" | "warn"](text, background) - displays the stylized messgae in console. <span class="chapterName" onclick="alert('Colors: ~red, ~blue, ~yellow, ~green, ~cyan, ~magenta, for bright colors use ~brightred, ~brightblue etc.\nEffects: ~bold, ~undercode, ~cursive, ~negation\nEmojis: ~smile, ~sad, ~angry, ~like, ~dislike, ~click, ~congr, ~download, ~upload, ~lock, ~unlock, ~yes, ~no, ~warn, ~nsfw, ~lookfinger, ~lookarrow\nReset all styles: ~reset')">Learn the syntax</span></li>
|
|
153
|
+
<li>rh.toCamelCase(text) - turns your text to camelCase, for example "my-very_awesome text" - "myVeryAwesomeText".</li>
|
|
154
|
+
<li>rh.toKebabCase(text) - turns your text to kebab-case, for example "myVery_awesome text" - "my-very-awesome-text".</li>
|
|
155
|
+
<li>rh.toSnakeCase(text) - turns your text to snake_case, for example "myVery-awesome text" - "my_very_awesome_text".</li>
|
|
156
|
+
<li>rh.trim(text, whatToTrim) - deletes 1+-in-row, in-begin and in-end inputs of whatToTrim. For example: rh.trim("my very awesomme textm", "m") - "y very awesome text".</li>
|
|
157
|
+
<li>rh.randomString({ minlength = 8, maxlength = 20, allowedsymbs = /*alphanumeric*/}) - gives u a random string.</li>
|
|
158
|
+
<li>rh.fromCapitalLetter(text) - makes the <span style="color:green">1st</span> letter of ur text uppercase.</li>
|
|
159
|
+
<li>rh.deleteAllVowels(text) - dlts ll vwls frm yr txt</li>
|
|
160
|
+
<li>rh.random(array or iterable) - gives you a random variant from your array.</li>
|
|
161
|
+
<li>rh.inRange(number, min, max) - is your number (or strin'g) in range? (including min/max)</li>
|
|
162
|
+
<li>rh.randomInt(min = 1, max = 1000) - gives u a random integer (whole number) from the range u asked.</li>
|
|
163
|
+
<li>rh.factorial(number) - gives factorial (!) of ur number, for example rh.factorial(5)'ll return 120.</li>
|
|
164
|
+
<li>await rh.sleep(ms) - stops ur async fn until the timer'll end.</li>
|
|
165
|
+
<li>rh.urlSafe(text, allowEmpty = false) - is ur text url safe?</li>
|
|
166
|
+
<li>rh.objectStats(object) - gives you a object stats object: { object:object, type:string, allProps:number, methods:number, enclosedObjects:number, numbers:number, ints:number, truthys:number }</li>
|
|
167
|
+
<li>rh.fontConverter(text, sourceFont, convertTo) - converts Unicode fonts. Supports plain, bold, bolditalic, exboldtalic, monospace, fractur, twoline, minicap, wierd.</li>
|
|
168
|
+
<li>rh.throwErrorOnly(object, customCallbackForNonErrors = ()=>{}) - throws object only if it-s error.</li>
|
|
169
|
+
<li>rh.fromCapitalLetterEw(text) - makes each word of ur text from capital letter.</li>
|
|
170
|
+
<li>rh.stringcut(text, length) - cuts ur strjng and adds ...</li>
|
|
171
|
+
<li>rh.deleteAllNonalphanumeric(text, allowBasicPunctation = false) - deletes all nonalphanumeric symbols from ur strin'g.</li>
|
|
172
|
+
<li>rh.deleteDuplicates(array) - deletes all duplicates from ur array.</li>
|
|
173
|
+
<li>rh.createTypedFunction(function, types, onbreak, async=false) - makes a typed function. <span class="chapterName" onclick="alert('Typed Functions - help\nrh.createTypedFunction(function, types, onbreak, async=false)\n• function: the function to wrap.\n• types: areay with types. Can only include correct JS types (like \'number\', \'string\', etc) or \'any\'.\• onbreak - what will be when provided incorrect type. May be \'return false\', \'return 0\' or custom function that acceptd 2 args: (providedArgument, mustBe). (Defaultly throws an error)\n• async - is ur function async?')">Learn more</span></li>
|
|
174
|
+
<li>rh.markdownToHTML(markdownCode, allowHTMLinMDcode) - turns your markdown code to <u>HTML</u>. <span class="chapterName" onclick="alert('Markdown to HTML\n\n• Headers (# ... ######)\n• Bold (**), italic (* or _), sd (~~)\n• Quotes (>)\n• Copyable texts (`)\n• Links ([text](url))\n• Unimportant texts (-#)\n• Horizontal lines (***)')">See the supported MD list</span></li>
|
|
175
|
+
<li>rh.to1337case(text) - turns your text to leet text. (7|_||◇|\|5 `/0|_||◇ 73><7 70 |_337 73><7)</li>
|
|
176
|
+
<li>rh.pallindrome(text) - is ur text's backward reads same as it? (case insensetive, only counts letters and numbers)</li>
|
|
177
|
+
</ol>
|
|
178
|
+
</div>
|
|
179
|
+
</details>
|
|
180
|
+
|
|
181
|
+
<details class="under">
|
|
182
|
+
<summary>Strings</summary>
|
|
183
|
+
<div class="oooooooops">
|
|
184
|
+
<ol>
|
|
185
|
+
<li>rh.reverseString(string) - reverses string.</li>
|
|
186
|
+
<li>rh.ascii(string) - is the provided string fully wroten in ASCII?</li>
|
|
187
|
+
<li>rh.asciiPercentage(text) - how many percent of ur string is ASCII?</li>
|
|
188
|
+
<li>rh.toCamelCase(text) - turns your text to camelCase, for example "my-very_awesome text" - "myVeryAwesomeText".</li>
|
|
189
|
+
<li>rh.toKebabCase(text) - turns your text to kebab-case, for example "myVery_awesome text" - "my-very-awesome-text".</li>
|
|
190
|
+
<li>rh.toSnakeCase(text) - turns your text to snake_case, for example "myVery-awesome text" - "my_very_awesome_text".</li>
|
|
191
|
+
<li>rh.trim(text, whatToTrim) - deletes 1+-in-row, in-begin and in-end inputs of whatToTrim. For example: rh.trim("my very awesomme textm", "m") - "y very awesome text".</li>
|
|
192
|
+
<li>rh.randomString({ minlength = 8, maxlength = 20, allowedsymbs = /*alphanumeric*/}) - gives u a random string.</li>
|
|
193
|
+
<li>rh.fromCapitalLetter(text) - makes the <span style="color:green">1st</span> letter of ur text uppercase.</li>
|
|
194
|
+
<li>rh.deleteAllVowels(text) - dlts ll vwls frm yr txt</li>
|
|
195
|
+
<li>rh.urlSafe(text, allowEmpty = false) - is ur text url safe?</li>
|
|
196
|
+
<li>rh.inRange(number, min, max) - is your number (or strin'g) in range? (including min/max)</li>
|
|
197
|
+
<li>rh.fontConverter(text, sourceFont, convertTo) - converts Unicode fonts. Supports plain, bold, bolditalic, exboldtalic, monospace, fractur, twoline, minicap, wierd.</li>
|
|
198
|
+
<li>rh.fromCapitalLetterEw(text) - makes each word of ur text from capital letter.</li>
|
|
199
|
+
<li>rh.stringcut(text, length) - cuts ur strjng and adds ...</li>
|
|
200
|
+
<li>rh.deleteAllNonalphanumeric(text, allowBasicPunctation = false) - deletes all nonalphanumeric symbols from ur strin'g.</li>
|
|
201
|
+
<li>rh.markdownToHTML(markdownCode, allowHTMLinMDcode) - turns your markdown code to <u>HTML</u>. <span class="chapterName" onclick="alert('Markdown to HTML\n\n• Headers (# ... ######)\n• Bold (**), italic (* or _), sd (~~)\n• Quotes (>)\n• Copyable texts (`)\n• Links ([text](url))\n• Unimportant texts (-#)\n• Horizontal lines (***)')">See the supported MD list</span></li>
|
|
202
|
+
<li>rh.to1337case(text) - turns your text to leet text. (7|_||◇|\|5 `/0|_||◇ 73><7 70 |_337 73><7)</li>
|
|
203
|
+
<li>rh.pallindrome(text) - is ur text's backward reads same as it? (case insensetive, only counts letters and numbers)</li>
|
|
204
|
+
</ol>
|
|
205
|
+
</div>
|
|
206
|
+
</details>
|
|
207
|
+
|
|
208
|
+
<details class="under">
|
|
209
|
+
<summary>Arrays</summary>
|
|
210
|
+
<div class="oooooooops">
|
|
211
|
+
<ol>
|
|
212
|
+
<li>rh.recverse(array) - recursiveley reverses array and all enclosed in it arrays. (Copy, not mutes original)</li>
|
|
213
|
+
<li>rh.random(array or iterable) - gives you a random variant from your array.</li>
|
|
214
|
+
<li>rh.deleteDuplicates(array) - deletes all duplicates from ur array.</li>
|
|
215
|
+
</ol>
|
|
216
|
+
</div>
|
|
217
|
+
</details>
|
|
218
|
+
|
|
219
|
+
<details class="under">
|
|
220
|
+
<summary>Numbers / Math</summary>
|
|
221
|
+
<div class="oooooooops">
|
|
222
|
+
<ol>
|
|
223
|
+
<li>rh.inRange(number, min, max) - is your number (or strin'g) in range? (including min/max)</li>
|
|
224
|
+
<li>rh.randomInt(min = 1, max = 1000) - gives u a random integer (whole number) from the range u asked.</li>
|
|
225
|
+
<li>rh.toPercentage(is, of) - turns it to percentage, for example rh.toPercentage(20, 50) -> 40.</li>
|
|
226
|
+
<li>rh.factorial(number) - gives factorial (!) of ur number, for example rh.factorial(5)'ll return 120.</li>
|
|
227
|
+
</ol>
|
|
228
|
+
</div>
|
|
229
|
+
</details>
|
|
230
|
+
|
|
231
|
+
<details class="under">
|
|
232
|
+
<summary>Other</summary>
|
|
233
|
+
<div class="oooooooops">
|
|
234
|
+
<ol>
|
|
235
|
+
<li>new rh.CustomError(err, msg) - gives a custom error.</li>
|
|
236
|
+
<li>rh.styledConsole["log" | "info" | "error" | "warn"](text, background) - displays the stylized messgae in console. <span class="chapterName" onclick="alert('Colors: ~red, ~blue, ~yellow, ~green, ~cyan, ~magenta, for bright colors use ~brightred, ~brightblue etc.\nEffects: ~bold, ~undercode, ~cursive, ~negation\nEmojis: ~smile, ~sad, ~angry, ~like, ~dislike, ~click, ~congr, ~download, ~upload, ~lock, ~unlock, ~yes, ~no, ~warn, ~nsfw, ~lookfinger, ~lookarrow\nReset all styles: ~reset')">Learn the syntax</span></li>
|
|
237
|
+
<li>rh.objectStats(object) - gives you a object stats object: { object:object, type:string, allProps:number, methods:number, enclosedObjects:number, numbers:number, ints:number, truthys:number }</li>
|
|
238
|
+
<li>await rh.sleep(ms) - stops ur async fn until the timer'll end.</li>
|
|
239
|
+
<li>rh.throwErrorOnly(object, customCallbackForNonErrors = ()=>{}) - throws object only if it-s error.</li>
|
|
240
|
+
<li>rh.createTypedFunction(function, types, onbreak, async=false) - makes a typed function. <span class="chapterName" onclick="alert('Typed Functions - help\nrh.createTypedFunction(function, types, onbreak, async=false)\n• function: the function to wrap.\n• types: areay with types. Can only include correct JS types (like \'number\', \'string\', etc) or \'any\'.\• onbreak - what will be when provided incorrect type. May be \'return false\', \'return 0\' or custom function that acceptd 2 args: (providedArgument, mustBe). (Defaultly throws an error)\n• async - is ur function async?')">Learn more</span></li>
|
|
241
|
+
</ol>
|
|
242
|
+
</div>
|
|
243
|
+
</details>
|
|
244
|
+
|
|
245
|
+
<br /><br />
|
|
246
|
+
</div>
|
|
247
|
+
</details>
|
|
248
|
+
|
|
249
|
+
<details>
|
|
250
|
+
<summary>Usage examples</summary>
|
|
251
|
+
<div class="oooops">
|
|
252
|
+
Fuck detector machine:
|
|
253
|
+
<pre>
|
|
254
|
+
const rh = require("rich-helper")
|
|
255
|
+
function testFuckness(str) {
|
|
256
|
+
if (str === "fuck" || rh.reverseString(str) === "fuck") {
|
|
257
|
+
throw new rh.CustomError("DeniedFuck", "Fucking is denied!")
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
</pre>
|
|
261
|
+
<br /><br />
|
|
262
|
+
|
|
263
|
+
ASCII requiror:
|
|
264
|
+
<pre>
|
|
265
|
+
const rh = require("rich-helper")
|
|
266
|
+
function requireAscii(text) {
|
|
267
|
+
if (!rh.ascii(text)) {
|
|
268
|
+
throw new CustomError("NotAscii", `${text} isn't ASCII. Try "${rh.toASCII(text)}" instead.`)
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
</pre>
|
|
272
|
+
<br /><br />
|
|
273
|
+
|
|
274
|
+
Vowelless challenge generator:
|
|
275
|
+
<pre>
|
|
276
|
+
const rh = require("rich-helper")
|
|
277
|
+
function generateChallenge(text) {
|
|
278
|
+
return rh.change(function(answer) {
|
|
279
|
+
if (answer === text) rh.styledConsole.log("~bold Congrats! ~congrats You have ~green solved ~reset ~bold successfully! ~congrats", "green")
|
|
280
|
+
else rh.styledConsole.error("~bold ~no ~cyan Incorrect!", "red")
|
|
281
|
+
}, "puzzle", rh.deleteAllVowels(text))
|
|
282
|
+
}
|
|
283
|
+
</pre>
|
|
284
|
+
</div>
|
|
285
|
+
</details>
|
|
286
|
+
|
|
287
|
+
<details>
|
|
288
|
+
<summary>Demo</summary>
|
|
289
|
+
<div class="oooops">
|
|
290
|
+
Interactive demo <br /><br />
|
|
291
|
+
<pre>
|
|
292
|
+
const rh = require("rich-helper")
|
|
293
|
+
rh.reverseString("<input id="demos_str_t">") // <button onclick="document.getElementById('demos_str_r').innerHTML = Array.from(document.getElementById('demos_str_t').value).reverse().join('')">Execute</button> "<span id="demos_str_r"></span>"
|
|
294
|
+
rh.toPercentage(<input id="demos_prc_is" type="number">, <input id="demos_prc_of" type="number">) // <button onclick="document.getElementById('demos_prc_re').innerText = toPercentage(document.getElementById('demos_prc_is').value, document.getElementById('demos_prc_of').value)">Execute</button> <span id="demos_prc_re"></span>
|
|
295
|
+
rh.ascii("<input id="demos_asc_i">") // <button onclick="document.getElementById('demos_asc_r').innerText = /^[\u0000-\u007f]+$/.test(document.getElementById('demos_asc_i').value)">Execute</button> <span id="demos_asc_r"></span>
|
|
296
|
+
rh.toCamelCase("<input id="demos_cam_i">") // <button onclick="document.getElementById('demos_cam_r').innerText = toCamelCase(document.getElementById('demos_cam_i').value)">Execute</button> "<span id="demos_cam_r"></span>"
|
|
297
|
+
rh.deleteAllVowels("<input id="demos_vow_i">") // <button onclick="document.getElementById('demos_vow_r').innerText = deleteAllVowels(document.getElementById('demos_vow_i').value)">Execute</button> "<span id="demos_vow_r"></span>"
|
|
298
|
+
</pre>
|
|
299
|
+
</div>
|
|
300
|
+
</details>
|
|
301
|
+
|
|
302
|
+
<details>
|
|
303
|
+
<summary>Buy me a coffee</summary>
|
|
304
|
+
<div class="oooops">
|
|
305
|
+
<span style="color:orange">BTC</span>: bc1qmjl4wuv83e72rt6ezf7e8u0a3x4wj4t94p42pt <br />
|
|
306
|
+
<span style="color:blue">XNO</span>: nano_1se14mmobaw9tiodtnm9i9hma8m3tw55aafm56r89dg9cgw7syk9eu9hygxt <br />
|
|
307
|
+
<span style="color:purple">POL</span>: 0x152Dd1ff6254259D1478015f7E74F86753CC4a5e <br />
|
|
308
|
+
<span style="color:red">TRX</span>: TKmCQHDeUpbeZzb7VyEWPjP7fW9dfs8ojL <br />
|
|
309
|
+
</div>
|
|
310
|
+
</details>
|
|
311
|
+
|
|
312
|
+
<details onclick="window.open('https://www.npmjs.com/bundle/depended/rich-helper'); this.open = false">
|
|
313
|
+
<summary>Who depend on us</summary>
|
|
314
|
+
</details>
|
|
315
|
+
|
|
316
|
+
<details>
|
|
317
|
+
<summary>MIT License</summary>
|
|
318
|
+
<div class="oooops">
|
|
319
|
+
MIT License 🎈<br /><br />
|
|
320
|
+
Copyright © 2026 NPMUCK You. All rights reversed. 😘<br /><br />
|
|
321
|
+
|
|
322
|
+
You can use rich-helper for any purpose, excluding illegal. You may copy, modify, share or do any other actions with rich-helper. Note that you must keep the original license when you copy, modify or share. ⚠️<br /><br />
|
|
323
|
+
|
|
324
|
+
rich-helper WORKS AS IS. NO WARRANTIES, GUARANTIES OR ANY OTHER LEGAL SHIT. WE RECOMMEND INSTEAD OF READING THIS FUCK OPEN General Info, Methods, OR ANY OTHER FRIENDLY BLOCK. 🙂<br /><br />
|
|
325
|
+
</div>
|
|
326
|
+
</details>
|
|
327
|
+
|
|
328
|
+
<details>
|
|
329
|
+
<summary>Changelog</summary>
|
|
330
|
+
<div class="oooops">
|
|
331
|
+
v1.0.0 (Current) - basic work.
|
|
332
|
+
</div>
|
|
333
|
+
</details>
|
|
334
|
+
|
|
335
|
+
<details>
|
|
336
|
+
<summary>Contributing</summary>
|
|
337
|
+
<div class="oooops">
|
|
338
|
+
How to help us:
|
|
339
|
+
<ul>
|
|
340
|
+
<li>Find bugs and reveal them on <a href="https://discord.gg/BhMJRxK7sy">our Discord</a></li>
|
|
341
|
+
<li>Give us ideas on <a href="https://discord.gg/BhMJRxK7sy">our Discord</a></li>
|
|
342
|
+
<li>Join our devlopers team on <a href="https://discord.gg/BhMJRxK7sy">our Discord</a></li>
|
|
343
|
+
</ul>
|
|
344
|
+
</div>
|
|
345
|
+
</details>
|
|
346
|
+
|
|
347
|
+
<details>
|
|
348
|
+
<summary>Contacts</summary>
|
|
349
|
+
<div class="oooops">
|
|
350
|
+
Email: <a href="mailto:igfjncthv@outlook.com">igfjncthv@outlook.com</a><br />
|
|
351
|
+
Discord: <a href="https://discord.gg/BhMJRxK7sy">gg/BhMJRxK7sy</a><br />
|
|
352
|
+
</div>
|
|
353
|
+
</details>
|
|
354
|
+
|
|
355
|
+
<div id="mydiv">
|
|
356
|
+
<br /><hr /><br />
|
|
357
|
+
|
|
358
|
+
Also, enjoy our <span id="iD">beautiful transormer</span>: <br /> <br />
|
|
359
|
+
<div id="beautifulTransformer"></div>
|
|
360
|
+
</div>
|
|
361
|
+
|
|
362
|
+
<script>
|
|
363
|
+
function deleteAllVowels(string) {
|
|
364
|
+
return String(string)
|
|
365
|
+
.replace(/[EUIOA]/gi, "")
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
function toPercentage(Is, Of) {
|
|
369
|
+
return Is * (100 / Of)
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
function toCamelCase(text) {
|
|
373
|
+
return String(text)
|
|
374
|
+
.replace(/[А-ЯA-Z]/, txt => { return /^[А-ЯA-Z]/.test(text) ? txt.toLowerCase() : txt })
|
|
375
|
+
.replace(/[-_ ][A-Za-zА-Яа-я]/g, text => text[1].toUpperCase())
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
const u = document.getElementById("beautifulTransformer")
|
|
379
|
+
const d = document.getElementById("mydiv")
|
|
380
|
+
const i = document.getElementById("iD")
|
|
381
|
+
const t = 30000;
|
|
382
|
+
|
|
383
|
+
u.style.transition = `background ${t / 1000}s ease`
|
|
384
|
+
setTimeout(() => {u.style.backgroundColor = 'green'; }, 150)
|
|
385
|
+
setTimeout(() => { u.style.backgroundColor = 'purple'}, t)
|
|
386
|
+
setTimeout(() => { u.style.backgroundColor = 'blue'}, t * 2)
|
|
387
|
+
setTimeout(() => { u.style.backgroundColor = 'orange'}, t * 3)
|
|
388
|
+
setTimeout(() => { u.style.backgroundColor = 'black'}, t * 4)
|
|
389
|
+
setTimeout(() => { i.innerText = 'black hole' }, t * 5)
|
|
390
|
+
setTimeout(d.remove.bind(d), t * 5 + 6000)
|
|
391
|
+
</script>
|
|
392
|
+
</body>
|
|
393
|
+
</html>
|
package/index.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const CustomError = require("./modules/custom_error.js")
|
|
2
|
+
if (process.versions.node.split(".")[0] < 15) throw new CustomError("VersionError", `Your version ${process.versions.node} is too old, upgrade to 15.0.0 or higher.`)
|
|
3
|
+
const reverseString = require("./modules/reverse_string.js")
|
|
4
|
+
const recverse = require("./modules/recurse_reverse.js")
|
|
5
|
+
const ascii = require("./modules/is_ascii.js")
|
|
6
|
+
const toPercentage = require("./modules/to_percentage.js")
|
|
7
|
+
const asciiPercentage = require("./modules/ascii_percentage.js")
|
|
8
|
+
const toASCII = require("./modules/to_ascii.js")
|
|
9
|
+
const styledConsole = require("./modules/styled_console.js")
|
|
10
|
+
const toCamelCase = require("./modules/to_camel_case.js")
|
|
11
|
+
const toKebabCase = require("./modules/to_kebab_case.js")
|
|
12
|
+
const toSnakeCase = require("./modules/to_snake_case.js")
|
|
13
|
+
const trim = require("./modules/trim.js")
|
|
14
|
+
const sleep = require("./modules/sleep.js")
|
|
15
|
+
const factorial = require("./modules/factorial.js")
|
|
16
|
+
const randomInt = require("./modules/random_int.js")
|
|
17
|
+
const inRange = require("./modules/in_range.js")
|
|
18
|
+
const random = require("./modules/random.js")
|
|
19
|
+
const deleteAllVowels = require("./modules/delete_all_vowels.js") // cnst dltllVwls = rqr("./mdls/dlt_ll_vwls.js")
|
|
20
|
+
const fromCapitalLetter = require("./modules/from_capital_letter.js")
|
|
21
|
+
const randomString = require("./modules/random_string.js")
|
|
22
|
+
const urlSafe = require("./modules/url_safe.js")
|
|
23
|
+
const objectStats = require("./modules/object_stats.js")
|
|
24
|
+
const fontConverter = require("./modules/font_converter.js")
|
|
25
|
+
const throwErrorOnly = require("./modules/throw_error_only.js")
|
|
26
|
+
const fromCapitalLetterEw = require("./modules/from_capital_letter_ew.js")
|
|
27
|
+
const stringcut = require("./modules/stringcut.js")
|
|
28
|
+
const deleteAllNonalphanumeric = require("./modules/delete_all_nonalphanumeric.js")
|
|
29
|
+
const deleteDuplicates = require("./modules/delete_duplicates.js")
|
|
30
|
+
const createTypedFunction = require("./modules/typed_functions.js")
|
|
31
|
+
const markdownToHTML = require("./modules/markdown_to_html.js")
|
|
32
|
+
const to1337case = require("./modules/70 1337 (453.js")
|
|
33
|
+
const pallindrome = require("./modules/pallindrome.js")
|
|
34
|
+
|
|
35
|
+
module.exports = {
|
|
36
|
+
CustomError,
|
|
37
|
+
reverseString,
|
|
38
|
+
recverse,
|
|
39
|
+
ascii,
|
|
40
|
+
toPercentage,
|
|
41
|
+
asciiPercentage,
|
|
42
|
+
toASCII,
|
|
43
|
+
styledConsole,
|
|
44
|
+
toCamelCase,
|
|
45
|
+
toKebabCase,
|
|
46
|
+
toSnakeCase,
|
|
47
|
+
trim,
|
|
48
|
+
sleep,
|
|
49
|
+
factorial,
|
|
50
|
+
randomInt,
|
|
51
|
+
inRange,
|
|
52
|
+
random,
|
|
53
|
+
deleteAllVowels,
|
|
54
|
+
fromCapitalLetter,
|
|
55
|
+
randomString,
|
|
56
|
+
urlSafe,
|
|
57
|
+
objectStats,
|
|
58
|
+
fontConverter,
|
|
59
|
+
throwErrorOnly,
|
|
60
|
+
fromCapitalLetterEw,
|
|
61
|
+
stringcut,
|
|
62
|
+
deleteAllNonalphanumeric,
|
|
63
|
+
deleteDuplicates,
|
|
64
|
+
createTypedFunction,
|
|
65
|
+
markdownToHTML,
|
|
66
|
+
to1337case,
|
|
67
|
+
pallindrome
|
|
68
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
function to1337case(text) {
|
|
2
|
+
return String(text).toUpperCase()
|
|
3
|
+
.replaceAll("A", "4")
|
|
4
|
+
.replaceAll("B", "8")
|
|
5
|
+
.replaceAll("C", "(")
|
|
6
|
+
.replaceAll("D", "|)")
|
|
7
|
+
.replaceAll("E", "3")
|
|
8
|
+
.replaceAll("F", "|=")
|
|
9
|
+
.replaceAll("G", "6")
|
|
10
|
+
.replaceAll("H", "|-|")
|
|
11
|
+
.replaceAll("I", "1")
|
|
12
|
+
.replaceAll("J", ".|")
|
|
13
|
+
.replaceAll("K", "1<")
|
|
14
|
+
.replaceAll("L", "|_")
|
|
15
|
+
.replaceAll("M", "|\\|/|")
|
|
16
|
+
.replaceAll("N", "|\\|")
|
|
17
|
+
.replaceAll("O", "0")
|
|
18
|
+
.replaceAll("P", "|°")
|
|
19
|
+
.replaceAll("Q", "0.")
|
|
20
|
+
.replaceAll("R", "|◇")
|
|
21
|
+
.replaceAll("S", "5")
|
|
22
|
+
.replaceAll("T", "7")
|
|
23
|
+
.replaceAll("U", "|_|")
|
|
24
|
+
.replaceAll("V", "\\/")
|
|
25
|
+
.replaceAll("W", "\\/\\/")
|
|
26
|
+
.replaceAll("X", "><")
|
|
27
|
+
.replaceAll("Y", "`/")
|
|
28
|
+
.replaceAll("Z", "2")
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = to1337case
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const lysts = {
|
|
2
|
+
plain: ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","0","1","2","3","4","5","6","7","8","9"],
|
|
3
|
+
bold: ["𝗮","𝗯","𝗰","𝗱","𝗲","𝗳","𝗴","𝗵","𝗶","𝗷","𝗸","𝗹","𝗺","𝗻","𝗼","𝗽","𝗾","𝗿","𝘀","𝘁","𝘂","𝘃","𝘄","𝘅","𝘆","𝘇","𝗔","𝗕","𝗖","𝗗","𝗘","𝗙","𝗚","𝗛","𝗜","𝗝","𝗞","𝗟","𝗠","𝗡","𝗢","𝗣","𝗤","𝗥","𝗦","𝗧","𝗨","𝗩","𝗪","𝗫","𝗬","𝗭","𝟬","𝟭","𝟮","𝟯","𝟰","𝟱","𝟲","𝟳","𝟴","𝟵"],
|
|
4
|
+
bolditalic: ["𝙖","𝙗","𝙘","𝙙","𝙚","𝙛","𝙜","𝙝","𝙞","𝙟","𝙠","𝙡","𝙢","𝙣","𝙤","𝙥","𝙦","𝙧","𝙨","𝙩","𝙪","𝙫","𝙬","𝙭","𝙮","𝙯","𝘼","𝘽","𝘾","𝘿","𝙀","𝙁","𝙂","𝙃","𝙄","𝙅","𝙆","𝙇","𝙈","𝙉","𝙊","𝙋","𝙌","𝙍","𝙎","𝙏","𝙐","𝙑","𝙒","𝙓","𝙔","𝙕","0","1","2","3","4","5","6","7","8","9"],
|
|
5
|
+
exboldtalic: ["𝙖","𝙗","𝙘","𝙙","𝙚","𝙛","𝙜","𝙝","𝙞","𝙟","𝙠","𝙡","𝙢","𝙣","𝙤","𝙥","𝙦","𝙧","𝙨","𝙩","𝙪","𝙫","𝙬","𝙭","𝙮","𝙯","𝘼","𝘽","𝘾","𝘿","𝙀","𝙁","𝙂","𝙃","𝙄","𝙅","𝙆","𝙇","𝙈","𝙉","𝙊","𝙋","𝙌","𝙍","𝙎","𝙏","𝙐","𝙑","𝙒","𝙓","𝙔","𝙕","𝟬","𝟭","𝟮","𝟯","𝟰","𝟱","𝟲","𝟳","𝟴","𝟵"],
|
|
6
|
+
monospace: ["𝚊","𝚋","𝚌","𝚍","𝚎","𝚏","𝚐","𝚑","𝚒","𝚓","𝚔","𝚕","𝚖","𝚗","𝚘","𝚙","𝚚","𝚛","𝚜","𝚝","𝚞","𝚟","𝚠","𝚡","𝚢","𝚣","𝙰","𝙱","𝙲","𝙳","𝙴","𝙵","𝙶","𝙷","𝙸","𝙹","𝙺","𝙻","𝙼","𝙽","𝙾","𝙿","𝚀","𝚁","𝚂","𝚃","𝚄","𝚅","𝚆","𝚇","𝚈","𝚉","𝟶","𝟷","𝟸","𝟹","𝟺","𝟻","𝟼","𝟽","𝟾","𝟿"],
|
|
7
|
+
fractur: ["𝖆","𝖇","𝖈","𝖉","𝖊","𝖋","𝖌","𝖍","𝖎","𝖏","𝖐","𝖑","𝖒","𝖓","𝖔","𝖕","𝖖","𝖗","𝖘","𝖙","𝖚","𝖛","𝖜","𝖝","𝖞","𝖟","𝕬","𝕭","𝕮","𝕯","𝕰","𝕱","𝕲","𝕳","𝕴","𝕵","𝕶","𝕷","𝕸","𝕹","𝕺","𝕻","𝕼","𝕽","𝕾","𝕿","𝖀","𝖁","𝖂","𝖃","𝖄","𝖅","𝟬","𝟭","𝟮","𝟯","𝟰","𝟱","𝟲","𝟳","𝟴","𝟵"],
|
|
8
|
+
twoline: ["𝕒","𝕓","𝕔","𝕕","𝕖","𝕗","𝕘","𝕙","𝕚","𝕛","𝕜","𝕝","𝕞","𝕟","𝕠","𝕡","𝕢","𝕣","𝕤","𝕥","𝕦","𝕧","𝕨","𝕩","𝕪","𝕫","𝔸","𝔹","ℂ","𝔻","𝔼","𝔽","𝔾","ℍ","𝕀","𝕁","𝕂","𝕃","𝕄","ℕ","𝕆","ℙ","ℚ","ℝ","𝕊","𝕋","𝕌","𝕍","𝕎","𝕏","𝕐","ℤ","𝟘","𝟙","𝟚","𝟛","𝟜","𝟝","𝟞","𝟟","𝟠","𝟡"],
|
|
9
|
+
minicap: ["ᴀ","ʙ","ᴄ","ᴅ","ᴇ","ꜰ","ɢ","ʜ","ɪ","ᴊ","ᴋ","ʟ","ᴍ","ɴ","ᴏ","ᴘ","ǫ","ʀ","s","ᴛ","ᴜ","ᴠ","ᴡ","x","ʏ","ᴢ","ᴀ","ʙ","ᴄ","ᴅ","ᴇ","ꜰ","ɢ","ʜ","ɪ","ᴊ","ᴋ","ʟ","ᴍ","ɴ","ᴏ","ᴘ","ǫ","ʀ","s","ᴛ","ᴜ","ᴠ","ᴡ","x","ʏ","ᴢ","𝟬","𝟭","𝟮","𝟯","𝟰","𝟱","𝟲","𝟳","𝟴","𝟵"],
|
|
10
|
+
wierd: ["a", "ь", "ć", "d", "ε", "ғ", "9", "n", "1", "j", "к", "l", "м", "п", "о", "ρ", "q", "r", "s", "τ", "υ", "ν", "ω", "χ", "γ", "ζ", "А", "В", "С", "D", "E", "F", "G", "Ή", "1", "J", "Κ", "Ι_", "Μ", "И", "O", "P", "Ò", "R", "S", "T", "Υ", "V", "VV", "X", "Y", "2", "O", 1, 2, 3, 4, 5, 6, 7, 8, "g"]
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
function fontConverter(text, srcfont, resfont) {
|
|
14
|
+
return String(text)
|
|
15
|
+
.replace(/./gu, text => lysts[resfont][lysts[srcfont].indexOf(text)])
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
module.exports = fontConverter
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
function markdownToHTML(md, allowHTML = false) {
|
|
2
|
+
let result = String(md);
|
|
3
|
+
|
|
4
|
+
if (!allowHTML) result = result.replaceAll("&", "&")
|
|
5
|
+
.replaceAll("<", "<")
|
|
6
|
+
.replaceAll(">", ">")
|
|
7
|
+
.replaceAll('"', """)
|
|
8
|
+
.replaceAll("'", "'")
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
result = result.replace(/^ *\*\*\* *$/gm, "<hr />")
|
|
12
|
+
result = result.replace(/~~(.+?)~~/g, "<s>$1</s>")
|
|
13
|
+
|
|
14
|
+
result = result.replace(/^# .+$/gm, text => `<h1>${text.slice(2)}</h1>`)
|
|
15
|
+
result = result.replace(/^## .+$/gm, text => `<h2>${text.slice(3)}</h2>`)
|
|
16
|
+
result = result.replace(/^### .+$/gm, text => `<h3>${text.slice(4)}</h3>`)
|
|
17
|
+
result = result.replace(/^#### .+$/gm, text => `<h4>${text.slice(5)}</h4>`)
|
|
18
|
+
result = result.replace(/^##### .+$/gm, text => `<h5>${text.slice(6)}</h5>`)
|
|
19
|
+
result = result.replace(/^###### .+$/gm, text => `<h6>${text.slice(7)}</h6>`)
|
|
20
|
+
|
|
21
|
+
result = result.replace(/^-# .+$/gm, text => `<small style="color:gray;">${text.slice(3)}</small>`)
|
|
22
|
+
result = result.replace(/^> .+$/gm, text => `<blockquote style="border-left: 5px solid lightgray; padding: 15px; border-radius: 6px;">${text.slice(2)}</blockquote>`)
|
|
23
|
+
|
|
24
|
+
result = result.replace(/\*\*(.+?)\*\*/g, "<b>$1</b>")
|
|
25
|
+
result = result.replace(/_(.+?)_/g, "<i>$1</i>")
|
|
26
|
+
result = result.replace(/\*(.+?)\*/g, "<i>$1</i>")
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
result = result.replace(/\[([^\]]+)\]\(([^\)]+)\)/g, `<a href="$2">$1</a>`)
|
|
30
|
+
|
|
31
|
+
result = result.replace(/`(.+?)`/g, (_, code) => `<span style="background-color:lightgray; font-family: monospace, Arial, serif;" onclick="const textarea = document.createElement('textarea'); document.body.appendChild(textarea); textarea.value = ${JSON.stringify(code)}; textarea.select(); document.execCommand('copy'); textarea.remove()">${code}</span>`)
|
|
32
|
+
result = result.replaceAll(" \n", "<br />")
|
|
33
|
+
|
|
34
|
+
return result
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = markdownToHTML
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
function objectStats(object) {
|
|
2
|
+
if ((typeof object !== "object" && typeof object !== "function") || !object) throw new TypeError("Is not object.")
|
|
3
|
+
const keylist = Object.values(object)
|
|
4
|
+
let type = "other"
|
|
5
|
+
if (object instanceof Array) type = "array"
|
|
6
|
+
else if (object instanceof Function) type = "function"
|
|
7
|
+
else if (object instanceof Error) type = "error"
|
|
8
|
+
return {
|
|
9
|
+
object,
|
|
10
|
+
type,
|
|
11
|
+
allProps: keylist.length,
|
|
12
|
+
methods: keylist.filter(x => typeof x === 'function').length,
|
|
13
|
+
enclosedObjects: keylist.filter(x => (typeof x === 'object' || typeof x === 'function') && x).length,
|
|
14
|
+
numbers: keylist.filter(x => typeof x === 'number').length,
|
|
15
|
+
ints: keylist.filter(Number.isInteger).length,
|
|
16
|
+
truthys: keylist.filter(Boolean).length
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
module.exports = objectStats
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
function random(array) {
|
|
2
|
+
if (!Array.isArray(array)) {
|
|
3
|
+
try { array = Array.from(array) } catch { throw new TypeError("rh.random() accepts array or iterable as argument, not " + typeof array + "!") }
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
return array[Math.floor(Math.random() * array.length)]
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
module.exports = random
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
function getRandomString(data_ = {}) {
|
|
2
|
+
let data = /*data_.*/structuredClone(data_);
|
|
3
|
+
if (typeof data_ !== "object") data = {};
|
|
4
|
+
data.minlength ||= 8
|
|
5
|
+
data.maxlength ||= 20
|
|
6
|
+
data.allowedsymbs ||= Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._")
|
|
7
|
+
if (!Array.isArray(data.allowedsymbs)) data.allowedsymbs = typeof data.allowedsymbs === "string" ? Array.from(data.allowedsymbs) : Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._")
|
|
8
|
+
if (data.minlength > data.maxlength) throw new TypeError(`You provided ${data.minlength} as minlength and ${data.maxlength} as maxlength, but minlength can't be bigger then maxlength.`)
|
|
9
|
+
const length = Math.floor(Math.floor(Math.random() * (Number(data.maxlength) - Number(data.minlength))) + Number(data.minlength))
|
|
10
|
+
//console.log("length:", length);
|
|
11
|
+
let resultat = "";
|
|
12
|
+
for (let a = length; a > 0; a--) resultat += data.allowedsymbs[Math.floor(Math.random() * data.allowedsymbs.length)]
|
|
13
|
+
|
|
14
|
+
//console.log("result length:", resultat.length);
|
|
15
|
+
return resultat//.
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
module.exports = getRandomString
|
package/modules/sleep.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
function _a(text, background) {
|
|
2
|
+
const _b = {
|
|
3
|
+
none: "",
|
|
4
|
+
red: "\x1b[41m",
|
|
5
|
+
green: "\x1b[42m",
|
|
6
|
+
yellow: "\x1b[43m",
|
|
7
|
+
blue: "\x1b[44m",
|
|
8
|
+
magenta: "\x1b[45m",
|
|
9
|
+
cyan: "\x1b[46m"
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return (_b[String(background)] || "") + (String(text)
|
|
13
|
+
.replaceAll("~red", "\x1b[31m")
|
|
14
|
+
.replaceAll("~green", "\x1b[32m")
|
|
15
|
+
.replaceAll("~blue", "\x1b[34m")
|
|
16
|
+
.replaceAll("~yellow", "\x1b[33m")
|
|
17
|
+
.replaceAll("~magenta", "\x1b[35m")
|
|
18
|
+
.replaceAll("~cyan", "\x1b[36m")
|
|
19
|
+
|
|
20
|
+
.replaceAll("~brightred", "\x1b[91m")
|
|
21
|
+
.replaceAll("~brightgreen", "\x1b[92m")
|
|
22
|
+
.replaceAll("~brightblue", "\x1b[94m")
|
|
23
|
+
.replaceAll("~brightyellow", "\x1b[93m")
|
|
24
|
+
.replaceAll("~brightmagenta", "\x1b[95m")
|
|
25
|
+
.replaceAll("~brightcyan", "\x1b[96m")
|
|
26
|
+
|
|
27
|
+
.replaceAll("~bold", "\x1b[1m")
|
|
28
|
+
.replaceAll("~undercode", "\x1b[4m")
|
|
29
|
+
.replaceAll("~cursive", "\x1b[3m")
|
|
30
|
+
.replaceAll("~negation", "\x1b[9m")
|
|
31
|
+
.replaceAll("~reset", "\x1b[0m")
|
|
32
|
+
|
|
33
|
+
.replaceAll("~smile", "😀")
|
|
34
|
+
.replaceAll("~sad", "😪")
|
|
35
|
+
.replaceAll("~angry", "😡")
|
|
36
|
+
.replaceAll("~like", "👍")
|
|
37
|
+
.replaceAll("~dislike", "👎")
|
|
38
|
+
.replaceAll("~click", "👆")
|
|
39
|
+
.replaceAll("~lock", "🔒")
|
|
40
|
+
.replaceAll("~unlock", "🔓")
|
|
41
|
+
.replaceAll("~diamond", "💎")
|
|
42
|
+
.replaceAll("~download", "📥")
|
|
43
|
+
.replaceAll("~upload", "📤")
|
|
44
|
+
.replaceAll("~warn", "⚠️")
|
|
45
|
+
.replaceAll("~yes", "✅️")
|
|
46
|
+
.replaceAll("~no", "🚫")
|
|
47
|
+
.replaceAll("~nsfw", "🔞")
|
|
48
|
+
.replaceAll("~lookfinger", "👉")
|
|
49
|
+
.replaceAll("~lookarrow", "↪️")
|
|
50
|
+
.replaceAll("~congr", "🎉")) + "\x1b[0m"
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const log = (text, bg) => console.log(_a(text, bg))
|
|
54
|
+
const info = (text, bg) => console.log(_a(text, bg))
|
|
55
|
+
const error = (text, bg = "red") => console.log(_a(text, bg))
|
|
56
|
+
const warn = (text, bg = "yellow") => console.log(_a(text, bg))
|
|
57
|
+
|
|
58
|
+
module.exports = {
|
|
59
|
+
log,
|
|
60
|
+
info,
|
|
61
|
+
error,
|
|
62
|
+
warn
|
|
63
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const ascii = require("./is_ascii.js")
|
|
2
|
+
|
|
3
|
+
function toASCII(text) {
|
|
4
|
+
if (ascii(text)) return text;
|
|
5
|
+
|
|
6
|
+
return text.replace("×", "*")
|
|
7
|
+
.replace("÷", "/")
|
|
8
|
+
.replace(/[А-Яа-яёЁ]/, symbol => symbol.toLowerCase() === "а" ? "a" : "e")
|
|
9
|
+
.replace(/./, symbol => ascii(symbol) ? symbol: "?")
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
module.exports = toASCII
|
package/modules/trim.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
function trim(string, whatToTrim) {
|
|
2
|
+
let result = String(string);
|
|
3
|
+
while (result.startsWith(String(whatToTrim))) result = result.replace(String(whatToTrim), "");
|
|
4
|
+
while (result.includes(String(whatToTrim).repeat(2))) result = result.replace(String(whatToTrim).repeat(2), String(whatToTrim))
|
|
5
|
+
while (result.endsWith(String(whatToTrim))) result = result.slice(0, result.length - 1)
|
|
6
|
+
|
|
7
|
+
return result
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = trim
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
function createTypedFunction(functn, types, onbreak, aSync = false) {
|
|
2
|
+
if (typeof functn !== "function") throw new TypeError("1st arg must be function!")
|
|
3
|
+
if (!Array.isArray(types)) throw new TypeError("2nd arg must be array!")
|
|
4
|
+
if (!types.every(it => ["number", "string", "boolean", "bigint", "object", "function", "undefined", "symbol", "any"].includes(it))) throw new TypeError("Every pallot of 2nd argument must be correct JS type or 'any'!")
|
|
5
|
+
|
|
6
|
+
let whenBreaked;
|
|
7
|
+
if (typeof onbreak === "function") whenBreaked = onbreak;
|
|
8
|
+
else if (onbreak === "return false") whenBreaked = () => false;
|
|
9
|
+
else if (onbreak === "return 0") whenBreaked = () => 0;
|
|
10
|
+
else whenBreaked = (argument, mustbe) => { throw new TypeError(`Provided ${argument} instead of ${mustbe}.`) }
|
|
11
|
+
|
|
12
|
+
if (!aSync) {
|
|
13
|
+
return function(...argz) {
|
|
14
|
+
let goback = [false];
|
|
15
|
+
argz.every((it,index) => {
|
|
16
|
+
if (types[index] === "any") return true;
|
|
17
|
+
else if (types[index] !== typeof it) {
|
|
18
|
+
goback = [true, whenBreaked(it, types[index])]
|
|
19
|
+
return false
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
if (goback[0]) return goback[1]
|
|
23
|
+
|
|
24
|
+
return functn(...argz)
|
|
25
|
+
}
|
|
26
|
+
} else {
|
|
27
|
+
return async function(...argz) {
|
|
28
|
+
let goback = [false];
|
|
29
|
+
argz.every((it,index) => {
|
|
30
|
+
if (types[index] === "any") return true;
|
|
31
|
+
else if (types[index] !== typeof it) {
|
|
32
|
+
goback = [true, whenBreaked(it, types[index])]
|
|
33
|
+
return false
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
if (goback[0]) return goback[1]
|
|
37
|
+
|
|
38
|
+
return await functn(...argz)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
module.exports = createTypedFunction
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rich-helper",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "rich-helper is a rich utility with many features.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"rich",
|
|
7
|
+
"util",
|
|
8
|
+
"utility",
|
|
9
|
+
"utils"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"type": "commonjs",
|
|
13
|
+
"main": "index.js",
|
|
14
|
+
"module": "for_esm.mjs",
|
|
15
|
+
"exports": {
|
|
16
|
+
"require": "./index.js",
|
|
17
|
+
"import": "./for_esm.mjs"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"info": "echo -e '\\e[35mrich-helper is a rich utility with many features.\\e[0m'; echo 'Version: 1.0.0'; echo 'Open help.html in it for more info.'; echo -e 'Use \\e[36mnpm run commands rich-helper\\e[0m for commands list.'",
|
|
21
|
+
"commands": "echo -e '\\e[35mrich-helper CLI - commands'; echo -e '\\e[36minfo\\e[0m - displays info.'; echo -e '\\e[36mcommands\\e[0m - displays commands list'; echo -e '\\e[36mlicense\\e[0m - gives u license info'; echo -e '\\e[36mcompatibility\\e[0m - is rich-helper compatible for require, import or both?'",
|
|
22
|
+
"license": "echo -e 'rich-helper uses MIT. Visit help.html or LICENSE for \\e[9mless\\e[0mmore info.'",
|
|
23
|
+
"compatibility": "echo -e 'Both import and require.'"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"rich-helper v1.0.0",
|
|
27
|
+
"package.json",
|
|
28
|
+
"index.js",
|
|
29
|
+
"for_esm.mjs",
|
|
30
|
+
"modules/",
|
|
31
|
+
"help.html",
|
|
32
|
+
"README.md",
|
|
33
|
+
"LICENSE",
|
|
34
|
+
".gitignore"
|
|
35
|
+
]
|
|
36
|
+
}
|
|
File without changes
|