Skip to content

Commit d5d9510

Browse files
Merge branch 'release/2.0.0'
2 parents ea52d9c + 60bc095 commit d5d9510

File tree

6 files changed

+231
-73
lines changed

6 files changed

+231
-73
lines changed

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "regex-to-strings",
3-
"version": "1.1.0",
3+
"version": "2.0.0",
44
"repository": {
55
"type": "git",
66
"url": "git+https://github.com/wimpyprogrammer/regex-to-strings.git"

Diff for: src/constants/index.ts

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const nbsp = String.fromCharCode(160);
2+
const whitespace = ` \t\r\n${nbsp}`.split('');
3+
4+
const digits = '0123456789'.split('');
5+
6+
const underscore = '_';
7+
const basicLowercase = 'abcdefghijklmnopqrstuvwxyz'.split('');
8+
const basicUppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
9+
const basicAlpha = [...basicLowercase, ...basicUppercase, underscore];
10+
11+
const basicSpecial = '~`!@#$%^&*()-=+<,>.?/[]{}|\\:;"\''.split('');
12+
13+
const extendedLowercase = 'àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ'.split('');
14+
const extendedUppercase = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞß'.split('');
15+
const shy = String.fromCharCode(173);
16+
const extendedSpecial = `¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿×÷${shy}`.split('');
17+
18+
// Special Windows-1252 display characters in the extended ASCII range
19+
// https://www.ascii-code.com/#extendedASCIIDescription
20+
const windows1252Special = '€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ'.split('');
21+
22+
const extended = [
23+
...extendedLowercase,
24+
...extendedUppercase,
25+
...extendedSpecial,
26+
...windows1252Special,
27+
];
28+
29+
const all = [
30+
...whitespace,
31+
...digits,
32+
...basicAlpha,
33+
...basicSpecial,
34+
...extended,
35+
];
36+
37+
export const Chars = {
38+
all,
39+
basicAlpha,
40+
basicSpecial,
41+
digits,
42+
extended,
43+
whitespace,
44+
};

Diff for: src/expanders/character-class-pattern.ts

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { CharacterClass } from 'regexp-tree/ast';
2+
import { Chars } from '../constants';
23
import Expander from '../Expander';
34
import Expansion from '../Expansion';
45
import sortRandom from '../sorts/fisher-yates-random';
@@ -18,16 +19,7 @@ function getReferencedCodePoints(
1819
return [expression.codePoint];
1920
}
2021

21-
const allCharOptions =
22-
' \t\r\n' +
23-
'abcdefghijklmnopqrstuvwxyz' +
24-
'ABCDEFGHIJKLMNOPQRSTUVWXYZ' +
25-
'0123456789' +
26-
'~`!@#$%^&*()-_=+<,>.?/[]{}|\\:;"\'';
27-
28-
const allCodePointOptions = allCharOptions
29-
.split('')
30-
.map(char => char.charCodeAt(0));
22+
const allCodePointOptions = Chars.all.map(char => char.charCodeAt(0));
3123

3224
/**
3325
* Expand an expression which represents a single character from a

0 commit comments

Comments
 (0)