-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathrandexp.javascript.txt
41 lines (32 loc) · 2.14 KB
/
randexp.javascript.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
┏━━━━━━━━━━━━━┓
┃ RANDEXP ┃
┗━━━━━━━━━━━━━┛
VERSION ==> #0.5.3
#Node/browser
#Generates random STR matching a REGEXP
┌──────────┐
│ CORE │
└──────────┘
new Randexp(REGEXP[_STR][,'FLGS'])#
RANDEXP.gen()->STR #
Randexp.randexp(...) #Same as new Randexp(...).gen()
Randexp.sugar() #Patches REGEXP.gen() so it calls Randexp.randexp(REGEXP)
REGEXP.randInt(NUM, NUM2) #Customize randomness generation (def: uses Math.random())
┌─────────────┐
│ DETAILS │
└─────────────┘
GENERATION ==> #Tokenizes REGEXP with ret.js (see its doc)
# - CHAR: as is
# - [...] ...|...:
# - random element among possible ones
# - only among REGEXP|RANDEXP.defaultRange
# - def: new DRange(32, 126), i.e. visible ASCII
# - * + ? {...}:
# - repeats a random number of times
# - for * + {NUM,} instead of Infinity, uses REGEXP|RANDEXP.max (def: 100)
# - \NUM: uses parenthesis group NUM
# - (?=) (?!): not supported (a GitHub issue is ongoing)
# - ^ $ \b \B: not supported
FLAGS ==> #Supports only flag i:
# - for CHAR and [...]
# - only ASCII supported