randex 0.21.0 → 0.23.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/README.md +93 -93
- package/lib/custom/email.d.ts +0 -3
- package/lib/custom/email.js +0 -41
- package/lib/custom/filename.d.ts +0 -4
- package/lib/custom/filename.js +0 -41
- package/lib/custom/fullname.d.ts +0 -5
- package/lib/custom/fullname.js +0 -33
- package/lib/custom/index.d.ts +41 -5
- package/lib/custom/index.js +309 -5
- package/lib/custom/number.d.ts +0 -3
- package/lib/custom/number.js +0 -37
- package/lib/custom/random.d.ts +5 -0
- package/lib/custom/random.js +2 -0
- package/lib/custom/singleName.d.ts +5 -0
- package/lib/custom/singleName.js +2 -0
- package/lib/custom/username.d.ts +0 -1
- package/lib/custom/username.js +0 -10
- package/lib/index.d.ts +3 -1
- package/lib/index.js +4 -1
- package/lib/test/array-item.test.js +2 -2
- package/lib/test/array.test.js +2 -2
- package/lib/test/email.test.js +8 -8
- package/lib/test/filename.test.js +10 -10
- package/lib/test/fullname.test.js +1 -1
- package/lib/test/markdown.test.js +34 -35
- package/lib/test/name.test.js +10 -10
- package/lib/test/number-array.test.js +5 -5
- package/lib/test/number.test.js +6 -6
- package/lib/test/params.test.js +15 -15
- package/lib/test/random.test.js +11 -11
- package/lib/test/username.test.js +8 -8
- package/package.json +1 -1
- package/lib/basic/index.d.ts +0 -2
- package/lib/basic/index.js +0 -83
- package/lib/custom/array-item.d.ts +0 -2
- package/lib/custom/array-item.js +0 -18
- package/lib/custom/array.d.ts +0 -1
- package/lib/custom/array.js +0 -21
- package/lib/custom/bool.d.ts +0 -1
- package/lib/custom/bool.js +0 -7
- package/lib/custom/name.d.ts +0 -9
- package/lib/custom/name.js +0 -30
- package/lib/custom/number-array.d.ts +0 -2
- package/lib/custom/number-array.js +0 -30
package/README.md
CHANGED
|
@@ -17,18 +17,18 @@ npm i randex
|
|
|
17
17
|
Strings:
|
|
18
18
|
|
|
19
19
|
- [random](#random)
|
|
20
|
-
- [
|
|
21
|
-
- [
|
|
22
|
-
- [
|
|
23
|
-
- [
|
|
24
|
-
- [
|
|
20
|
+
- [fileName](#filename)
|
|
21
|
+
- [username](#username)
|
|
22
|
+
- [email](#email)
|
|
23
|
+
- [singleName](#singlename)
|
|
24
|
+
- [fullName](#fullname)
|
|
25
25
|
|
|
26
26
|
Numbers:
|
|
27
|
-
- [
|
|
28
|
-
- [
|
|
27
|
+
- [number](#number)
|
|
28
|
+
- [numberArray](#numberarray)
|
|
29
29
|
|
|
30
30
|
Generic Type:
|
|
31
|
-
- [
|
|
31
|
+
- [array](#array)
|
|
32
32
|
|
|
33
33
|
Deeps:
|
|
34
34
|
|
|
@@ -40,62 +40,62 @@ Deeps:
|
|
|
40
40
|
Basic function to construct random things.
|
|
41
41
|
|
|
42
42
|
```ts
|
|
43
|
-
import
|
|
43
|
+
import Randex from "randex";
|
|
44
44
|
|
|
45
45
|
// 3 english chars
|
|
46
|
-
random({
|
|
46
|
+
Randex.random({
|
|
47
47
|
set: "english",
|
|
48
48
|
length: 3,
|
|
49
49
|
});
|
|
50
50
|
// or short:
|
|
51
|
-
random(["english", 3]);
|
|
51
|
+
Randex.random(["english", 3]);
|
|
52
52
|
// EFd
|
|
53
53
|
|
|
54
54
|
// 3 lower english chars
|
|
55
|
-
random({
|
|
55
|
+
Randex.random({
|
|
56
56
|
set: ["english", "lower"],
|
|
57
57
|
length: 3,
|
|
58
58
|
});
|
|
59
59
|
// or short:
|
|
60
|
-
random([["english", "lower"], 3]);
|
|
60
|
+
Randex.random([["english", "lower"], 3]);
|
|
61
61
|
// yhl
|
|
62
62
|
|
|
63
63
|
// min 1 and max 3 english chars
|
|
64
|
-
random({
|
|
64
|
+
Randex.random({
|
|
65
65
|
set: "english",
|
|
66
66
|
length: [1, 3],
|
|
67
67
|
});
|
|
68
68
|
// or short:
|
|
69
|
-
random(["english", [1, 3]]);
|
|
69
|
+
Randex.random(["english", [1, 3]]);
|
|
70
70
|
// eR
|
|
71
71
|
|
|
72
72
|
// 3 number chars
|
|
73
|
-
random({
|
|
73
|
+
Randex.random({
|
|
74
74
|
set: "number",
|
|
75
75
|
length: 3,
|
|
76
76
|
});
|
|
77
77
|
// or short:
|
|
78
|
-
random(["number", 3]);
|
|
78
|
+
Randex.random(["number", 3]);
|
|
79
79
|
// 643
|
|
80
80
|
|
|
81
81
|
// 3 chars from custom range
|
|
82
|
-
random({
|
|
82
|
+
Randex.random({
|
|
83
83
|
range: "abc123",
|
|
84
84
|
length: 3,
|
|
85
85
|
});
|
|
86
86
|
// a21
|
|
87
87
|
|
|
88
88
|
// 3 english or number chars
|
|
89
|
-
random({
|
|
89
|
+
Randex.random({
|
|
90
90
|
set: ["english", "number"],
|
|
91
91
|
length: 3,
|
|
92
92
|
});
|
|
93
93
|
// or short:
|
|
94
|
-
random([["english", "number"], 3]);
|
|
94
|
+
Randex.random([["english", "number"], 3]);
|
|
95
95
|
// x4d
|
|
96
96
|
|
|
97
97
|
// 4 chars: 2 english and 2 english or number
|
|
98
|
-
random(
|
|
98
|
+
Randex.random(
|
|
99
99
|
{
|
|
100
100
|
set: "english",
|
|
101
101
|
length: 2,
|
|
@@ -106,7 +106,7 @@ random(
|
|
|
106
106
|
}
|
|
107
107
|
);
|
|
108
108
|
// or short:
|
|
109
|
-
random(["english", 2], [["english", "number"], 2]);
|
|
109
|
+
Randex.random(["english", 2], [["english", "number"], 2]);
|
|
110
110
|
// Kb3b
|
|
111
111
|
```
|
|
112
112
|
|
|
@@ -117,43 +117,43 @@ Options:
|
|
|
117
117
|
|range|`string`| Range or custom chars |
|
|
118
118
|
|length|[RandexLength](#randexlength) | Length of chars |
|
|
119
119
|
|
|
120
|
-
##
|
|
120
|
+
## fileName
|
|
121
121
|
|
|
122
122
|
Randoms file name.
|
|
123
123
|
|
|
124
124
|
```ts
|
|
125
|
-
import
|
|
125
|
+
import Randex from "randex";
|
|
126
126
|
|
|
127
127
|
// default
|
|
128
|
-
|
|
128
|
+
Randex.fileName({
|
|
129
129
|
extension: "txt",
|
|
130
130
|
});
|
|
131
131
|
// td1TX31eOB.txt
|
|
132
132
|
|
|
133
133
|
// defined extension
|
|
134
|
-
|
|
134
|
+
Randex.fileName({
|
|
135
135
|
extension: "txt",
|
|
136
136
|
});
|
|
137
137
|
// or short:
|
|
138
|
-
|
|
138
|
+
Randex.fileName("txt");
|
|
139
139
|
// HkmOjqHC6.txt
|
|
140
140
|
|
|
141
141
|
// defined file name length and extension length
|
|
142
|
-
|
|
142
|
+
Randex.fileName({
|
|
143
143
|
fileNameLength: [7, 10],
|
|
144
144
|
extensionLength: 5,
|
|
145
145
|
});
|
|
146
146
|
// or short:
|
|
147
|
-
|
|
147
|
+
Randex.fileName([7, 10], 5);
|
|
148
148
|
// 1SJVkHSBjq.tejuw
|
|
149
149
|
|
|
150
150
|
// defined file name length and extension
|
|
151
|
-
|
|
151
|
+
Randex.fileName({
|
|
152
152
|
fileNameLength: 8,
|
|
153
153
|
extension: "xml",
|
|
154
154
|
});
|
|
155
155
|
// or short:
|
|
156
|
-
|
|
156
|
+
Randex.fileName(8, "xml");
|
|
157
157
|
// JyCsuN5kD.xml
|
|
158
158
|
```
|
|
159
159
|
|
|
@@ -164,27 +164,27 @@ Options:
|
|
|
164
164
|
|extensionLength|[RandexLength](#randexlength) | Length of extension (not including file name) chars. Default: [2,5] |
|
|
165
165
|
|extension| `string`| File extension. |
|
|
166
166
|
|
|
167
|
-
##
|
|
167
|
+
## username
|
|
168
168
|
|
|
169
169
|
Randoms username.
|
|
170
170
|
|
|
171
171
|
```ts
|
|
172
|
-
import
|
|
172
|
+
import Randex from "randex";
|
|
173
173
|
|
|
174
174
|
// default
|
|
175
|
-
|
|
175
|
+
Randex.username();
|
|
176
176
|
// icvv81d1j
|
|
177
177
|
|
|
178
178
|
// with length 5 chars
|
|
179
|
-
|
|
179
|
+
Randex.username({ length: 5 });
|
|
180
180
|
// or short:
|
|
181
|
-
|
|
181
|
+
Randex.username(5);
|
|
182
182
|
// okmle
|
|
183
183
|
|
|
184
184
|
// with 2 min and 5 max chars
|
|
185
|
-
|
|
185
|
+
Randex.singleName({ length: [2, 5] });
|
|
186
186
|
// or short:
|
|
187
|
-
|
|
187
|
+
Randex.username([2, 5]);
|
|
188
188
|
// lkhs
|
|
189
189
|
```
|
|
190
190
|
|
|
@@ -239,39 +239,39 @@ Options:
|
|
|
239
239
|
|lowDomainLength|[RandexLength](#randexlength) | Length of low domain part (example: <b>test</b>.com). Default: [4,2] |
|
|
240
240
|
|domain| `string`| Defined domain. |
|
|
241
241
|
|
|
242
|
-
##
|
|
242
|
+
## singleName
|
|
243
243
|
|
|
244
244
|
Randoms a name of the person, city, place, restaurant, ect.
|
|
245
245
|
|
|
246
246
|
```ts
|
|
247
|
-
import
|
|
247
|
+
import Randex from "randex";
|
|
248
248
|
|
|
249
249
|
// default
|
|
250
|
-
|
|
250
|
+
Randex.singleName();
|
|
251
251
|
// Ijb
|
|
252
252
|
|
|
253
253
|
// with length 5 chars
|
|
254
|
-
|
|
254
|
+
Randex.singleName({ length: 5 });
|
|
255
255
|
// or short:
|
|
256
|
-
|
|
256
|
+
Randex.singleName(5);
|
|
257
257
|
// Okmpj
|
|
258
258
|
|
|
259
259
|
// with 2 min and 5 max chars
|
|
260
|
-
|
|
260
|
+
Randex.singleName({ length: [2, 5] });
|
|
261
261
|
// or short:
|
|
262
|
-
|
|
262
|
+
Randex.singleName([2, 5]);
|
|
263
263
|
// Wslg
|
|
264
264
|
|
|
265
265
|
// name from french alphabet
|
|
266
|
-
|
|
266
|
+
Randex.singleName({ alphabet: "french" });
|
|
267
267
|
// or short:
|
|
268
|
-
|
|
268
|
+
Randex.singleName("french");
|
|
269
269
|
// Dbïœ
|
|
270
270
|
|
|
271
271
|
// name from french alphabet with length
|
|
272
|
-
|
|
272
|
+
Randex.singleName({ alphabet: "french", length: 10 });
|
|
273
273
|
// or short:
|
|
274
|
-
|
|
274
|
+
Randex.singleName("french", 10);
|
|
275
275
|
// Rsîrjhjôôw
|
|
276
276
|
```
|
|
277
277
|
|
|
@@ -286,10 +286,10 @@ Options:
|
|
|
286
286
|
Randoms a full name of the person.
|
|
287
287
|
|
|
288
288
|
```ts
|
|
289
|
-
import
|
|
289
|
+
import Randex from "randex";
|
|
290
290
|
|
|
291
291
|
// default
|
|
292
|
-
|
|
292
|
+
Randex.fullName();
|
|
293
293
|
// Eqaa Bfmotnq
|
|
294
294
|
```
|
|
295
295
|
|
|
@@ -301,18 +301,18 @@ Options:
|
|
|
301
301
|
|alphabet|[RandexAlphabet](#randexalphabet) | Defined alphabet. Default: `english` |
|
|
302
302
|
|
|
303
303
|
|
|
304
|
-
##
|
|
304
|
+
## number
|
|
305
305
|
|
|
306
306
|
Generates random number from a range of numbers.
|
|
307
307
|
|
|
308
308
|
```ts
|
|
309
|
-
import
|
|
309
|
+
import Randex from "randex";
|
|
310
310
|
|
|
311
311
|
// Generates a number from a range: [0, 3] (includes 0 and 3).
|
|
312
|
-
|
|
312
|
+
Randex.number(3);
|
|
313
313
|
|
|
314
314
|
// Generates a number from a specified range: [3, 7].
|
|
315
|
-
|
|
315
|
+
Randex.number([3, 7]);
|
|
316
316
|
```
|
|
317
317
|
|
|
318
318
|
Options:
|
|
@@ -320,31 +320,31 @@ Options:
|
|
|
320
320
|
| ------------------------ | ---- |------------ |
|
|
321
321
|
|decimals| `number` | Number of decimal digits |
|
|
322
322
|
|
|
323
|
-
##
|
|
323
|
+
## numberArray
|
|
324
324
|
|
|
325
325
|
Generates random array with values from a range.
|
|
326
326
|
|
|
327
327
|
```ts
|
|
328
|
-
import
|
|
328
|
+
import Randex from "randex";
|
|
329
329
|
|
|
330
330
|
// Generates an array (with length equals 2) with unique numbers from a range: [0, 3].
|
|
331
|
-
|
|
331
|
+
Randex.numberArray(3, 2);
|
|
332
332
|
|
|
333
333
|
// Generates an array (with length equals 3) with unique numbers from a range: [3, 7].
|
|
334
|
-
|
|
334
|
+
Randex.numberArray([3, 7], 3);
|
|
335
335
|
```
|
|
336
336
|
|
|
337
|
-
##
|
|
337
|
+
## array
|
|
338
338
|
|
|
339
339
|
Generates random array with values from defined array.
|
|
340
340
|
|
|
341
341
|
```ts
|
|
342
|
-
import
|
|
342
|
+
import Randex from "randex";
|
|
343
343
|
|
|
344
344
|
// Generates an array (with length equals 2) with values picked from defined array as the first parameter.
|
|
345
|
-
|
|
345
|
+
Randex.array([1, 2, 3, 4], 2);
|
|
346
346
|
// [2, 4]
|
|
347
|
-
|
|
347
|
+
Randex.array(["1", "2", "3", "4"], 2);
|
|
348
348
|
// ["1", "3"]
|
|
349
349
|
```
|
|
350
350
|
|
|
@@ -355,24 +355,24 @@ randomArray(["1", "2", "3", "4"], 2);
|
|
|
355
355
|
|
|
356
356
|
There are examples how to create custom function for most common cases:
|
|
357
357
|
|
|
358
|
-
<b>
|
|
358
|
+
<b>Randex.fileName</b>
|
|
359
359
|
|
|
360
360
|
```ts
|
|
361
|
-
random([
|
|
361
|
+
Randex.random([
|
|
362
362
|
["english", "number"],
|
|
363
363
|
[3, 10],
|
|
364
364
|
]) +
|
|
365
365
|
"." +
|
|
366
|
-
random([
|
|
366
|
+
Randex.random([
|
|
367
367
|
["english", "l"],
|
|
368
368
|
[2, 5],
|
|
369
369
|
]);
|
|
370
370
|
```
|
|
371
371
|
|
|
372
|
-
<b>
|
|
372
|
+
<b>Randex.username</b>
|
|
373
373
|
|
|
374
374
|
```ts
|
|
375
|
-
random(
|
|
375
|
+
Randex.random(
|
|
376
376
|
["english", "l"],
|
|
377
377
|
[
|
|
378
378
|
[["english", "l"], "number"],
|
|
@@ -381,29 +381,29 @@ random(
|
|
|
381
381
|
);
|
|
382
382
|
```
|
|
383
383
|
|
|
384
|
-
<b>
|
|
384
|
+
<b>Randex.email</b>
|
|
385
385
|
|
|
386
386
|
```ts
|
|
387
|
-
random([
|
|
387
|
+
Randex.random([
|
|
388
388
|
[["english", "l"], "number"],
|
|
389
389
|
[6, 10],
|
|
390
390
|
]) +
|
|
391
391
|
"@" +
|
|
392
|
-
random([
|
|
392
|
+
Randex.random([
|
|
393
393
|
["english", "l"],
|
|
394
394
|
[2, 4],
|
|
395
395
|
]) +
|
|
396
396
|
"." +
|
|
397
|
-
random([
|
|
397
|
+
Randex.random([
|
|
398
398
|
["english", "l"],
|
|
399
399
|
[1, 6],
|
|
400
400
|
]);
|
|
401
401
|
```
|
|
402
402
|
|
|
403
|
-
<b>
|
|
403
|
+
<b>Randex.singleName</b>
|
|
404
404
|
|
|
405
405
|
```ts
|
|
406
|
-
random(
|
|
406
|
+
Randex.random(
|
|
407
407
|
["english", "u"],
|
|
408
408
|
[
|
|
409
409
|
["english", "l"],
|
|
@@ -412,10 +412,10 @@ random(
|
|
|
412
412
|
);
|
|
413
413
|
```
|
|
414
414
|
|
|
415
|
-
<b>
|
|
415
|
+
<b>Randex.fullName</b>
|
|
416
416
|
|
|
417
417
|
```ts
|
|
418
|
-
random(
|
|
418
|
+
Randex.random(
|
|
419
419
|
["english", "u"],
|
|
420
420
|
[
|
|
421
421
|
["english", "l"],
|
|
@@ -423,7 +423,7 @@ random(
|
|
|
423
423
|
]
|
|
424
424
|
) +
|
|
425
425
|
" " +
|
|
426
|
-
random(
|
|
426
|
+
Randex.random(
|
|
427
427
|
["english", "u"],
|
|
428
428
|
[
|
|
429
429
|
["english", "l"],
|
|
@@ -445,11 +445,11 @@ Possible types:
|
|
|
445
445
|
Example:
|
|
446
446
|
|
|
447
447
|
```ts
|
|
448
|
-
random({ set: "bit", length: 5 });
|
|
449
|
-
random({ set: "bit", length: [5, 10] });
|
|
448
|
+
Randex.random({ set: "bit", length: 5 });
|
|
449
|
+
Randex.random({ set: "bit", length: [5, 10] });
|
|
450
450
|
// or short:
|
|
451
|
-
random(["bit", 5]);
|
|
452
|
-
random(["bit", [5, 10]]);
|
|
451
|
+
Randex.random(["bit", 5]);
|
|
452
|
+
Randex.random(["bit", [5, 10]]);
|
|
453
453
|
```
|
|
454
454
|
|
|
455
455
|
## RandexSet
|
|
@@ -463,13 +463,13 @@ Possible types:
|
|
|
463
463
|
Example:
|
|
464
464
|
|
|
465
465
|
```ts
|
|
466
|
-
random({ set: "bit" });
|
|
467
|
-
random({ set: "spanish" });
|
|
468
|
-
random({ set: ["spanish", "lower"] });
|
|
466
|
+
Randex.random({ set: "bit" });
|
|
467
|
+
Randex.random({ set: "spanish" });
|
|
468
|
+
Randex.random({ set: ["spanish", "lower"] });
|
|
469
469
|
// or short:
|
|
470
|
-
random("bit");
|
|
471
|
-
random("spanish");
|
|
472
|
-
random(["spanish", "l"]);
|
|
470
|
+
Randex.random("bit");
|
|
471
|
+
Randex.random("spanish");
|
|
472
|
+
Randex.random(["spanish", "l"]);
|
|
473
473
|
```
|
|
474
474
|
|
|
475
475
|
## RandexAlphabet
|
|
@@ -481,9 +481,9 @@ An alphabet of chars
|
|
|
481
481
|
Example:
|
|
482
482
|
|
|
483
483
|
```ts
|
|
484
|
-
random({ set: "spanish" });
|
|
484
|
+
Randex.random({ set: "spanish" });
|
|
485
485
|
// or short:
|
|
486
|
-
random("spanish");
|
|
486
|
+
Randex.random("spanish");
|
|
487
487
|
```
|
|
488
488
|
|
|
489
489
|
## RandexKit
|
|
@@ -495,9 +495,9 @@ A kit of chars
|
|
|
495
495
|
Example:
|
|
496
496
|
|
|
497
497
|
```ts
|
|
498
|
-
random({ set: "hex" });
|
|
498
|
+
Randex.random({ set: "hex" });
|
|
499
499
|
// or short:
|
|
500
|
-
random("hex");
|
|
500
|
+
Randex.random("hex");
|
|
501
501
|
```
|
|
502
502
|
|
|
503
503
|
## RandexCase
|
|
@@ -509,7 +509,7 @@ A case of alphabet
|
|
|
509
509
|
Example:
|
|
510
510
|
|
|
511
511
|
```ts
|
|
512
|
-
random({ set: ["spanish", "lower"] });
|
|
512
|
+
Randex.random({ set: ["spanish", "lower"] });
|
|
513
513
|
// or short:
|
|
514
|
-
random(["spanish", "l"]);
|
|
514
|
+
Randex.random(["spanish", "l"]);
|
|
515
515
|
```
|
package/lib/custom/email.d.ts
CHANGED
|
@@ -10,7 +10,4 @@ interface DomainEmailOptions {
|
|
|
10
10
|
domain?: string;
|
|
11
11
|
}
|
|
12
12
|
export type RandexEmailOptions = BasicEmailOptions & (DomainLengthEmailOptions | DomainEmailOptions);
|
|
13
|
-
export declare function randomEmail(options?: RandexEmailOptions): any;
|
|
14
|
-
export declare function randomEmail(prefixLength: RandexLength, lowDomainLength?: RandexLength, hightDomainLength?: RandexLength): any;
|
|
15
|
-
export declare function randomEmail(domain: string): any;
|
|
16
13
|
export {};
|
package/lib/custom/email.js
CHANGED
|
@@ -1,43 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.randomEmail = void 0;
|
|
4
|
-
var basic_1 = require("../basic");
|
|
5
|
-
var set_1 = require("../basic/set");
|
|
6
|
-
var type_1 = require("../basic/type");
|
|
7
|
-
function randomEmail(p1, p2, p3) {
|
|
8
|
-
var prefixLength = set_1.RandexSetUtil.defaultEmailPrefixLength;
|
|
9
|
-
var hightDomainLength = set_1.RandexSetUtil.defaultHightDomainEmailLength;
|
|
10
|
-
var lowDomainLength = set_1.RandexSetUtil.defaultLowDomainEmailLength;
|
|
11
|
-
var domain = "";
|
|
12
|
-
if (type_1.RandexTypeParser.isLength(p1)) {
|
|
13
|
-
prefixLength = p1;
|
|
14
|
-
if (type_1.RandexTypeParser.isLength(p2)) {
|
|
15
|
-
lowDomainLength = p2;
|
|
16
|
-
}
|
|
17
|
-
if (type_1.RandexTypeParser.isLength(p3)) {
|
|
18
|
-
hightDomainLength = p3;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
else if (typeof p1 === "string") {
|
|
22
|
-
domain = p1;
|
|
23
|
-
}
|
|
24
|
-
else if (typeof p1 === "object") {
|
|
25
|
-
if (p1.prefixLength) {
|
|
26
|
-
prefixLength = p1.prefixLength;
|
|
27
|
-
}
|
|
28
|
-
if (p1.hightDomainLength) {
|
|
29
|
-
hightDomainLength = p1.hightDomainLength;
|
|
30
|
-
}
|
|
31
|
-
if (p1.lowDomainLength) {
|
|
32
|
-
lowDomainLength = p1.lowDomainLength;
|
|
33
|
-
}
|
|
34
|
-
if (p1.domain) {
|
|
35
|
-
domain = p1.domain;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
if (!domain) {
|
|
39
|
-
domain = (0, basic_1.random)([["english", "l"], lowDomainLength]) + "." + (0, basic_1.random)([["english", "l"], hightDomainLength]);
|
|
40
|
-
}
|
|
41
|
-
return (0, basic_1.random)([[["english", "l"], "number"], prefixLength]) + "@" + domain;
|
|
42
|
-
}
|
|
43
|
-
exports.randomEmail = randomEmail;
|
package/lib/custom/filename.d.ts
CHANGED
|
@@ -9,8 +9,4 @@ interface ExtensionFileNameOptions {
|
|
|
9
9
|
extension?: string;
|
|
10
10
|
}
|
|
11
11
|
export type RandexFileNameOptions = BasicFileNameOptions & (ExtensionFileNameOptions | ExtensionLengthFileNameOptions);
|
|
12
|
-
export declare function randomFileName(options?: RandexFileNameOptions): any;
|
|
13
|
-
export declare function randomFileName(fileNameLength: RandexLength, extensionLength?: RandexLength): any;
|
|
14
|
-
export declare function randomFileName(fileNameLength: RandexLength, extension: string): any;
|
|
15
|
-
export declare function randomFileName(extension: string): any;
|
|
16
12
|
export {};
|
package/lib/custom/filename.js
CHANGED
|
@@ -1,43 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.randomFileName = void 0;
|
|
4
|
-
var basic_1 = require("../basic");
|
|
5
|
-
var set_1 = require("../basic/set");
|
|
6
|
-
var type_1 = require("../basic/type");
|
|
7
|
-
function randomFileName(p1, p2) {
|
|
8
|
-
var fileNameLength = set_1.RandexSetUtil.defaultFileNameLength;
|
|
9
|
-
var extensionLength = set_1.RandexSetUtil.defaultExtensionLength;
|
|
10
|
-
var extension = "";
|
|
11
|
-
if (type_1.RandexTypeParser.isLength(p1)) {
|
|
12
|
-
fileNameLength = p1;
|
|
13
|
-
if (type_1.RandexTypeParser.isLength(p2)) {
|
|
14
|
-
extensionLength = p2;
|
|
15
|
-
}
|
|
16
|
-
else if (typeof p2 === "string") {
|
|
17
|
-
extension = p2;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
else if (typeof p1 === "string") {
|
|
21
|
-
extension = p1;
|
|
22
|
-
}
|
|
23
|
-
else if (typeof p1 === "object") {
|
|
24
|
-
if (p1.fileNameLength) {
|
|
25
|
-
fileNameLength = p1.fileNameLength;
|
|
26
|
-
}
|
|
27
|
-
if (p1.extensionLength) {
|
|
28
|
-
extensionLength = p1.extensionLength;
|
|
29
|
-
}
|
|
30
|
-
if (p1.extension) {
|
|
31
|
-
extension = p1.extension;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
fileNameLength = set_1.RandexSetUtil.getLength(1, fileNameLength, fileNameLength);
|
|
35
|
-
if (!extension) {
|
|
36
|
-
extension = (0, basic_1.random)([["english", "l"], extensionLength]);
|
|
37
|
-
}
|
|
38
|
-
return ((0, basic_1.random)([["english", "number"], set_1.RandexSetUtil.fileNameExtraChars, fileNameLength]) +
|
|
39
|
-
(0, basic_1.random)(["english", "number"]) +
|
|
40
|
-
"." +
|
|
41
|
-
(extension ? extension.replace(/^\./, "") : (0, basic_1.random)([["english", "l"], extensionLength])));
|
|
42
|
-
}
|
|
43
|
-
exports.randomFileName = randomFileName;
|
package/lib/custom/fullname.d.ts
CHANGED
|
@@ -4,8 +4,3 @@ export interface RandexFullNameOptions {
|
|
|
4
4
|
firstLength?: RandexLength;
|
|
5
5
|
secondLength?: RandexLength;
|
|
6
6
|
}
|
|
7
|
-
export declare function randomFullName(options?: RandexFullNameOptions): any;
|
|
8
|
-
export declare function randomFullName(length: RandexLength): any;
|
|
9
|
-
export declare function randomFullName(alphabet?: RandexAlphabet): any;
|
|
10
|
-
export declare function randomFullName(alphabet: RandexAlphabet, length: RandexLength): any;
|
|
11
|
-
export declare function randomFullName(alphabet: RandexAlphabet, firstLength: RandexLength, secondLength: RandexLength): any;
|
package/lib/custom/fullname.js
CHANGED
|
@@ -1,35 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.randomFullName = void 0;
|
|
4
|
-
var type_1 = require("../basic/type");
|
|
5
|
-
var name_1 = require("./name");
|
|
6
|
-
function randomFullName(p1, p2, p3) {
|
|
7
|
-
var firstLength = 0;
|
|
8
|
-
var secondLength = 0;
|
|
9
|
-
var alphabet = "english";
|
|
10
|
-
if (type_1.RandexTypeParser.isLength(p1)) {
|
|
11
|
-
firstLength = secondLength = p1;
|
|
12
|
-
}
|
|
13
|
-
else if (type_1.RandexTypeParser.inAlphabet(p1)) {
|
|
14
|
-
alphabet = p1;
|
|
15
|
-
if (type_1.RandexTypeParser.isLength(p2)) {
|
|
16
|
-
firstLength = secondLength = p2;
|
|
17
|
-
}
|
|
18
|
-
if (type_1.RandexTypeParser.isLength(p3)) {
|
|
19
|
-
secondLength = p3;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
else if (typeof p1 === "object") {
|
|
23
|
-
if (p1.alphabet) {
|
|
24
|
-
alphabet = p1.alphabet;
|
|
25
|
-
}
|
|
26
|
-
if (p1.firstLength) {
|
|
27
|
-
firstLength = p1.firstLength;
|
|
28
|
-
}
|
|
29
|
-
if (p1.secondLength) {
|
|
30
|
-
secondLength = p1.secondLength;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return (0, name_1.randomName)({ length: firstLength, alphabet: alphabet }) + " " + (0, name_1.randomName)({ length: secondLength, alphabet: alphabet });
|
|
34
|
-
}
|
|
35
|
-
exports.randomFullName = randomFullName;
|
package/lib/custom/index.d.ts
CHANGED
|
@@ -1,10 +1,46 @@
|
|
|
1
|
+
import { RandexAlphabet, RandexContentOptions, RandexLength } from "../interfaces";
|
|
2
|
+
import { RandexEmailOptions } from "./email";
|
|
3
|
+
import { RandexFileNameOptions } from "./filename";
|
|
4
|
+
import { RandexSingleNameOptions } from "./singleName";
|
|
5
|
+
import { RandomNumberOptions } from "./number";
|
|
6
|
+
import { RandexUsernameOptions } from "./username";
|
|
7
|
+
import { RandexFullNameOptions } from "./fullname";
|
|
1
8
|
export * from "./email";
|
|
2
9
|
export * from "./filename";
|
|
3
|
-
export * from "./
|
|
10
|
+
export * from "./singleName";
|
|
4
11
|
export * from "./username";
|
|
5
12
|
export * from "./fullname";
|
|
6
13
|
export * from "./number";
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
14
|
+
export declare class Randex {
|
|
15
|
+
private static randomString;
|
|
16
|
+
private static toContent;
|
|
17
|
+
private static toRangeOptions;
|
|
18
|
+
static random(...options: RandexContentOptions[]): string;
|
|
19
|
+
static arrayItem<T>(array: T[]): T;
|
|
20
|
+
static arrayItem<T>(array: T[], defaultValue: T): T;
|
|
21
|
+
static array<T>(array: T[], count: number): T[];
|
|
22
|
+
static bool(): boolean;
|
|
23
|
+
static email(options?: RandexEmailOptions): any;
|
|
24
|
+
static email(prefixLength: RandexLength, lowDomainLength?: RandexLength, hightDomainLength?: RandexLength): any;
|
|
25
|
+
static email(domain: string): any;
|
|
26
|
+
static fileName(options?: RandexFileNameOptions): any;
|
|
27
|
+
static fileName(fileNameLength: RandexLength, extensionLength?: RandexLength): any;
|
|
28
|
+
static fileName(fileNameLength: RandexLength, extension: string): any;
|
|
29
|
+
static fileName(extension: string): any;
|
|
30
|
+
static fullName(options?: RandexFullNameOptions): any;
|
|
31
|
+
static fullName(length: RandexLength): any;
|
|
32
|
+
static fullName(alphabet?: RandexAlphabet): any;
|
|
33
|
+
static fullName(alphabet: RandexAlphabet, length: RandexLength): any;
|
|
34
|
+
static fullName(alphabet: RandexAlphabet, firstLength: RandexLength, secondLength: RandexLength): any;
|
|
35
|
+
static singleName(options?: RandexSingleNameOptions): any;
|
|
36
|
+
static singleName(length: RandexLength): any;
|
|
37
|
+
static singleName(alphabet?: RandexAlphabet): any;
|
|
38
|
+
static singleName(alphabet: RandexAlphabet, length: RandexLength): any;
|
|
39
|
+
static numberArray(length: RandexLength, count: number): number[];
|
|
40
|
+
private static getNumberBase;
|
|
41
|
+
private static getNumberValue;
|
|
42
|
+
private static innerRandomNumber;
|
|
43
|
+
static number(length: RandexLength, options?: RandomNumberOptions): number;
|
|
44
|
+
static number(from: number, to: number, options?: RandomNumberOptions): number;
|
|
45
|
+
static username(options?: RandexUsernameOptions | RandexLength): string;
|
|
46
|
+
}
|