@archoleat/reglib 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. package/index.d.ts +92 -0
  2. package/index.js +1 -1
  3. package/package.json +8 -4
package/index.d.ts ADDED
@@ -0,0 +1,92 @@
1
+ const LETTERS_REGEX = '[A-Z][a-z]';
2
+ const FONT_FAMILY_REGEX = `^${LETTERS_REGEX}+(${LETTERS_REGEX}+)?`;
3
+ const ALLOWED_FONT_WEIGHT_REGEX = [
4
+ 'Thin',
5
+ 'Hairline',
6
+ 'ExtraLight',
7
+ 'UltraLight',
8
+ 'Light',
9
+ 'Regular',
10
+ 'Medium',
11
+ 'SemiBold',
12
+ 'DemiBold',
13
+ 'Bold',
14
+ 'ExtraBold',
15
+ 'UltraBold',
16
+ 'Black',
17
+ 'Heavy',
18
+ 'ExtraBlack',
19
+ 'UltraBlack',
20
+ ].join('|');
21
+ const ALLOWED_FONT_EXTENSION_REGEX = ['otf', 'ttf', 'woff', 'woff2'].join('|');
22
+ const FAMILY_REGEX = `(${FONT_FAMILY_REGEX})`;
23
+ const WEIGHT_REGEX = `(${ALLOWED_FONT_WEIGHT_REGEX})`;
24
+ const EXTENSION_REGEX = `(${ALLOWED_FONT_EXTENSION_REGEX})$`;
25
+ const FONT_FILE_NAME_REGEX = new RegExp(
26
+ `${FAMILY_REGEX}-${WEIGHT_REGEX}\\.${EXTENSION_REGEX}`,
27
+ );
28
+
29
+ const SPLIT_CHARS_REGEX = String.raw`(?:_|__|-|\s)`;
30
+
31
+ const ITALIC_REGEX = new RegExp(`${SPLIT_CHARS_REGEX}?(italic)`, 'i');
32
+
33
+ const VARIABLE_FONT_REGEX = new RegExp(`${SPLIT_CHARS_REGEX}?(var)`, 'i');
34
+
35
+ const EMAIL_REGEX = new RegExp(
36
+ String.raw`^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$`,
37
+ );
38
+
39
+ const LETTERS_WITH_SPACES_REGEX = new RegExp(String.raw`^[\sA-Za-zЁА-яё]+$`);
40
+
41
+ const NOT_SEPARATE_REGEX = new RegExp(String.raw`^\+[\d-]+$`);
42
+
43
+ const NOT_SPACE_REGEX = new RegExp(String.raw`^\S+$`, 'i');
44
+
45
+ const HTML_EXTENSION_REGEX = '.html';
46
+ const PUG_EXTENSION_REGEX = '.pug';
47
+
48
+ const extensions = {
49
+ HTML_EXTENSION_REGEX,
50
+ PUG_EXTENSION_REGEX,
51
+ FILE_EXTENSION_REGEX: new RegExp(String.raw`\.[^.]+$`),
52
+ JS_EXTENSION_REGEX: new RegExp(String.raw`\.js$`),
53
+ PUG_EXTENSION_REGEX_REGEX: new RegExp(`${PUG_EXTENSION_REGEX}$`),
54
+ SCSS_EXTENSION_REGEX: new RegExp(String.raw`\.s[ac]ss$`),
55
+
56
+ NODE_MODULES_REGEX: new RegExp('node_modules'),
57
+ };
58
+
59
+ const numbers = {
60
+ ALL_REGEX: new RegExp(String.raw`^\d+$`),
61
+ };
62
+
63
+ const phones = {
64
+ RU_REGEX: new RegExp(String.raw`^\+7 \((9\d{2,3})\) \d{3}-\d{2}-\d{2}$`),
65
+ US_REGEX: new RegExp(String.raw`^\+1 \((\d{3})\) \d{3}-\d{4}$`),
66
+ };
67
+
68
+ const SYMBOLS_REGEX = '[a-z0-9]';
69
+ const ATTRIBUTE_REGEX = String.raw`?\[(.*)\]`;
70
+ const CLASS_REGEX = String.raw`?\.(.*)`;
71
+ const MODIFIER_REGEX = '--';
72
+ const ELEMENT_REGEX = '__';
73
+
74
+ const selectors = {
75
+ bem: {
76
+ BLOCK_REGEX: `[a-z]${SYMBOLS_REGEX}*(-${SYMBOLS_REGEX}+)`,
77
+ ELEMENT_REGEX: `(${ELEMENT_REGEX}${SYMBOLS_REGEX}+(-${SYMBOLS_REGEX}+)*)`,
78
+ MODIFIER_REGEX: `(${MODIFIER_REGEX}${SYMBOLS_REGEX}+(-${SYMBOLS_REGEX}+)*)`,
79
+ },
80
+ nested: {
81
+ ATTRIBUTE_REGEX,
82
+ CLASS_REGEX,
83
+ ELEMENT_REGEX,
84
+ MODIFIER_REGEX,
85
+ },
86
+ child: {
87
+ ATTRIBUTE_REGEX: `${ATTRIBUTE_REGEX} &`,
88
+ CLASS_REGEX: `${CLASS_REGEX} &`,
89
+ },
90
+ };
91
+
92
+ export { EMAIL_REGEX, FONT_FILE_NAME_REGEX, ITALIC_REGEX, LETTERS_WITH_SPACES_REGEX, NOT_SEPARATE_REGEX, NOT_SPACE_REGEX, VARIABLE_FONT_REGEX, extensions, numbers, phones, selectors };
package/index.js CHANGED
@@ -1 +1 @@
1
- const n="[A-Z][a-z]",S=`^${n}+(${n}+)?`,s=["Thin","Hairline","ExtraLight","UltraLight","Light","Regular","Medium","SemiBold","DemiBold","Bold","ExtraBold","UltraBold","Black","Heavy","ExtraBlack","UltraBlack"].join("|"),G=["otf","ttf","woff","woff2"].join("|"),r=`(${S})`,T=`(${s})`,c=`(${G})$`,w=new RegExp(`${r}-${T}\\.${c}`),_=String.raw`(?:_|__|-|\s)`,$=new RegExp(`${_}?(italic)`,"i"),a=new RegExp(`${_}?(var)`,"i"),g=new RegExp(String.raw`^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$`),i=new RegExp(String.raw`^[\sA-Za-zЁА-яё]+$`),L=new RegExp(String.raw`^\+[\d-]+$`),N=new RegExp(String.raw`^\S+$`,"i"),I=".html",R=".pug",O={HTML_EXTENSION_REGEX:I,PUG_EXTENSION_REGEX:R,FILE_EXTENSION_REGEX:new RegExp(String.raw`\.[^.]+$`),JS_EXTENSION_REGEX:new RegExp(String.raw`\.js$`),PUG_EXTENSION_REGEX_REGEX:new RegExp(`${R}$`),SCSS_EXTENSION_REGEX:new RegExp(String.raw`\.s[ac]ss$`),NODE_MODULES_REGEX:new RegExp("node_modules")},A={ALL_REGEX:new RegExp(String.raw`^\d+$`)},x={RU_REGEX:new RegExp(String.raw`^\+7 \((9\d{2,3})\) \d{3}-\d{2}-\d{2}$`)},E="[a-z0-9]",t=String.raw`?\[(.*)\]`,e=String.raw`?\.(.*)`,X="--",o="__",l={bem:{BLOCK_REGEX:`[a-z]${E}*(-${E}+)`,ELEMENT_REGEX:`(${o}${E}+(-${E}+)*)`,MODIFIER_REGEX:`(${X}${E}+(-${E}+)*)`},nested:{ATTRIBUTE_REGEX:t,CLASS_REGEX:e,ELEMENT_REGEX:o,MODIFIER_REGEX:X},child:{ATTRIBUTE_REGEX:`${t} &`,CLASS_REGEX:`${e} &`}};export{g as EMAIL_REGEX,w as FONT_FILE_NAME_REGEX,$ as ITALIC_REGEX,i as LETTERS_WITH_SPACES_REGEX,L as NOT_SEPARATE_REGEX,N as NOT_SPACE_REGEX,a as VARIABLE_FONT_REGEX,O as extensions,A as numbers,x as phones,l as selectors};
1
+ const n="[A-Z][a-z]",o=`^${n}+(${n}+)?`,s=["Thin","Hairline","ExtraLight","UltraLight","Light","Regular","Medium","SemiBold","DemiBold","Bold","ExtraBold","UltraBold","Black","Heavy","ExtraBlack","UltraBlack"].join("|"),G=["otf","ttf","woff","woff2"].join("|"),r=`(${o})`,w=`(${s})`,T=`(${G})$`,c=new RegExp(`${r}-${w}\\.${T}`),R=String.raw`(?:_|__|-|\s)`,g=new RegExp(`${R}?(italic)`,"i"),$=new RegExp(`${R}?(var)`,"i"),a=new RegExp(String.raw`^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$`),i=new RegExp(String.raw`^[\sA-Za-zЁА-яё]+$`),L=new RegExp(String.raw`^\+[\d-]+$`),N=new RegExp(String.raw`^\S+$`,"i"),I=".html",_=".pug",O={HTML_EXTENSION_REGEX:I,PUG_EXTENSION_REGEX:_,FILE_EXTENSION_REGEX:new RegExp(String.raw`\.[^.]+$`),JS_EXTENSION_REGEX:new RegExp(String.raw`\.js$`),PUG_EXTENSION_REGEX_REGEX:new RegExp(`${_}$`),SCSS_EXTENSION_REGEX:new RegExp(String.raw`\.s[ac]ss$`),NODE_MODULES_REGEX:new RegExp("node_modules")},A={ALL_REGEX:new RegExp(String.raw`^\d+$`)},x={RU_REGEX:new RegExp(String.raw`^\+7 \((9\d{2,3})\) \d{3}-\d{2}-\d{2}$`),US_REGEX:new RegExp(String.raw`^\+1 \((\d{3})\) \d{3}-\d{4}$`)},E="[a-z0-9]",t=String.raw`?\[(.*)\]`,e=String.raw`?\.(.*)`,X="--",S="__",d={bem:{BLOCK_REGEX:`[a-z]${E}*(-${E}+)`,ELEMENT_REGEX:`(${S}${E}+(-${E}+)*)`,MODIFIER_REGEX:`(${X}${E}+(-${E}+)*)`},nested:{ATTRIBUTE_REGEX:t,CLASS_REGEX:e,ELEMENT_REGEX:S,MODIFIER_REGEX:X},child:{ATTRIBUTE_REGEX:`${t} &`,CLASS_REGEX:`${e} &`}};export{a as EMAIL_REGEX,c as FONT_FILE_NAME_REGEX,g as ITALIC_REGEX,i as LETTERS_WITH_SPACES_REGEX,L as NOT_SEPARATE_REGEX,N as NOT_SPACE_REGEX,$ as VARIABLE_FONT_REGEX,O as extensions,A as numbers,x as phones,d as selectors};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@archoleat/reglib",
3
3
  "description": "Library with ready-to-use regex",
4
- "version": "1.0.2",
4
+ "version": "1.1.0",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "email": "archoleat@gmail.com",
@@ -42,9 +42,11 @@
42
42
  "#shared": "./src/shared/index.ts"
43
43
  },
44
44
  "exports": {
45
- ".": "./index.js"
45
+ ".": "./index.js",
46
+ "./index.d.ts": "./index.d.ts"
46
47
  },
47
48
  "files": [
49
+ "index.d.ts",
48
50
  "index.js"
49
51
  ],
50
52
  "scripts": {
@@ -67,12 +69,13 @@
67
69
  "@commitlint/cli": "^19.3.0",
68
70
  "@commitlint/config-conventional": "^19.2.2",
69
71
  "@commitlint/types": "^19.0.3",
72
+ "@rollup/plugin-alias": "^5.1.0",
70
73
  "@rollup/plugin-typescript": "^11.1.6",
71
74
  "@semantic-release/changelog": "^6.0.3",
72
75
  "@semantic-release/git": "^10.0.1",
73
76
  "@typescript-eslint/eslint-plugin": "^7.18.0",
74
77
  "@typescript-eslint/parser": "^7.18.0",
75
- "@vitest/coverage-v8": "^2.0.4",
78
+ "@vitest/coverage-v8": "^2.0.5",
76
79
  "conventional-changelog-conventionalcommits": "^8.0.0",
77
80
  "cz-conventional-changelog": "^3.3.0",
78
81
  "editorconfig-checker": "^5.1.8",
@@ -93,9 +96,10 @@
93
96
  "remark-preset-lint-markdown-style-guide": "^6.0.0",
94
97
  "remark-preset-lint-recommended": "^7.0.0",
95
98
  "rollup": "^4.19.1",
99
+ "rollup-plugin-dts": "^6.1.1",
96
100
  "rollup-plugin-esbuild": "^6.1.1",
97
101
  "semantic-release": "^24.0.0",
98
102
  "typescript": "^5.5.4",
99
- "vitest": "^2.0.4"
103
+ "vitest": "^2.0.5"
100
104
  }
101
105
  }