@vexify-org/yaggs 6.16.0 → 6.18.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/index.js +40 -0
- package/lib/parser.js +47 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -193,6 +193,46 @@ class Yaggs {
|
|
|
193
193
|
return this.parser.formatDate(date, format);
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
+
random(min = 0, max = 100) {
|
|
197
|
+
return this.parser.random(min, max);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
randomFloat(min = 0, max = 1) {
|
|
201
|
+
return this.parser.randomFloat(min, max);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
uuid() {
|
|
205
|
+
return this.parser.uuid();
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
slugify(str) {
|
|
209
|
+
return this.parser.slugify(str);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
capitalize(str) {
|
|
213
|
+
return this.parser.capitalize(str);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
truncate(str, maxLength = 100, suffix = '...') {
|
|
217
|
+
return this.parser.truncate(str, maxLength, suffix);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
hash(str, algorithm = 'sha256') {
|
|
221
|
+
return this.parser.hash(str, algorithm);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
md5(str) {
|
|
225
|
+
return this.parser.md5(str);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
sha256(str) {
|
|
229
|
+
return this.parser.sha256(str);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
sha512(str) {
|
|
233
|
+
return this.parser.sha512(str);
|
|
234
|
+
}
|
|
235
|
+
|
|
196
236
|
check(fn) {
|
|
197
237
|
this.middleware(fn);
|
|
198
238
|
return this;
|
package/lib/parser.js
CHANGED
|
@@ -1172,6 +1172,53 @@ complete -c ${this.scriptName} `;
|
|
|
1172
1172
|
});
|
|
1173
1173
|
}
|
|
1174
1174
|
|
|
1175
|
+
random(min = 0, max = 100) {
|
|
1176
|
+
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
randomFloat(min = 0, max = 1) {
|
|
1180
|
+
return Math.random() * (max - min) + min;
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
uuid() {
|
|
1184
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
1185
|
+
const r = Math.random() * 16 | 0;
|
|
1186
|
+
const v = c === 'x' ? r : (r & 0x3 | 0x8);
|
|
1187
|
+
return v.toString(16);
|
|
1188
|
+
});
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
slugify(str) {
|
|
1192
|
+
return str.toLowerCase()
|
|
1193
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
1194
|
+
.replace(/^-|-$/g, '');
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
capitalize(str) {
|
|
1198
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
truncate(str, maxLength = 100, suffix = '...') {
|
|
1202
|
+
return str.length > maxLength ? str.slice(0, maxLength) + suffix : str;
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
hash(str, algorithm = 'sha256') {
|
|
1206
|
+
const crypto = require('crypto');
|
|
1207
|
+
return crypto.createHash(algorithm).update(str).digest('hex');
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
md5(str) {
|
|
1211
|
+
return this.hash(str, 'md5');
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
sha256(str) {
|
|
1215
|
+
return this.hash(str, 'sha256');
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
sha512(str) {
|
|
1219
|
+
return this.hash(str, 'sha512');
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1175
1222
|
getHelp() {
|
|
1176
1223
|
let help = `\u001b[36m${this.scriptName}\u001b[0m`;
|
|
1177
1224
|
|