xulbux 1.6.1__py3-none-any.whl
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.
Potentially problematic release.
This version of xulbux might be problematic. Click here for more details.
- xulbux/__init__.py +57 -0
- xulbux/_cli_.py +53 -0
- xulbux/_consts_.py +145 -0
- xulbux/xx_code.py +105 -0
- xulbux/xx_color.py +955 -0
- xulbux/xx_console.py +378 -0
- xulbux/xx_data.py +531 -0
- xulbux/xx_env_path.py +113 -0
- xulbux/xx_file.py +65 -0
- xulbux/xx_format_codes.py +305 -0
- xulbux/xx_json.py +106 -0
- xulbux/xx_path.py +107 -0
- xulbux/xx_regex.py +156 -0
- xulbux/xx_string.py +159 -0
- xulbux/xx_system.py +85 -0
- xulbux-1.6.1.dist-info/LICENSE +21 -0
- xulbux-1.6.1.dist-info/METADATA +110 -0
- xulbux-1.6.1.dist-info/RECORD +21 -0
- xulbux-1.6.1.dist-info/WHEEL +5 -0
- xulbux-1.6.1.dist-info/entry_points.txt +3 -0
- xulbux-1.6.1.dist-info/top_level.txt +1 -0
xulbux/__init__.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""
|
|
2
|
+
>>> import xulbux as xx
|
|
3
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
4
|
+
• CUSTOM TYPES:
|
|
5
|
+
• rgba(int,int,int,float)
|
|
6
|
+
• hsla(int,int,int,float)
|
|
7
|
+
• hexa(str)
|
|
8
|
+
• PATH OPERATIONS xx.Path
|
|
9
|
+
• FILE OPERATIONS xx.File
|
|
10
|
+
• JSON FILE OPERATIONS xx.Json
|
|
11
|
+
• SYSTEM ACTIONS xx.System
|
|
12
|
+
• MANAGE THE ENV PATH VAR xx.EnvPath
|
|
13
|
+
• CONSOLE LOG AND ACTIONS xx.Console
|
|
14
|
+
• EASY PRETTY PRINTING xx.FormatCodes
|
|
15
|
+
• WORKING WITH COLORS xx.Color
|
|
16
|
+
• DATA OPERATIONS xx.Data
|
|
17
|
+
• STRING OPERATIONS xx.String
|
|
18
|
+
• CODE STRING OPERATIONS xx.Code
|
|
19
|
+
• REGEX PATTERN TEMPLATES xx.Regex
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
__version__ = "1.6.1"
|
|
23
|
+
__author__ = "XulbuX"
|
|
24
|
+
__email__ = "xulbux.real@gmail.com"
|
|
25
|
+
__license__ = "MIT"
|
|
26
|
+
__copyright__ = "Copyright (c) 2024 XulbuX"
|
|
27
|
+
__url__ = "https://github.com/XulbuX-dev/PythonLibraryXulbuX"
|
|
28
|
+
__description__ = "A library which includes a lot of really helpful functions."
|
|
29
|
+
__all__ = [
|
|
30
|
+
"_consts_",
|
|
31
|
+
"xx_console",
|
|
32
|
+
"xx_code",
|
|
33
|
+
"xx_color",
|
|
34
|
+
"xx_data",
|
|
35
|
+
"xx_env_path",
|
|
36
|
+
"xx_file",
|
|
37
|
+
"xx_format_codes",
|
|
38
|
+
"xx_json",
|
|
39
|
+
"xx_path",
|
|
40
|
+
"xx_regex",
|
|
41
|
+
"xx_string",
|
|
42
|
+
"xx_system",
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
from ._consts_ import *
|
|
46
|
+
from .xx_code import *
|
|
47
|
+
from .xx_color import *
|
|
48
|
+
from .xx_console import *
|
|
49
|
+
from .xx_data import *
|
|
50
|
+
from .xx_env_path import *
|
|
51
|
+
from .xx_file import *
|
|
52
|
+
from .xx_format_codes import *
|
|
53
|
+
from .xx_json import *
|
|
54
|
+
from .xx_path import *
|
|
55
|
+
from .xx_regex import *
|
|
56
|
+
from .xx_string import *
|
|
57
|
+
from .xx_system import *
|
xulbux/_cli_.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
from . import __version__
|
|
2
|
+
from ._consts_ import DEFAULT
|
|
3
|
+
from .xx_format_codes import FormatCodes
|
|
4
|
+
from .xx_console import Console
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def help_command():
|
|
8
|
+
"""Show some info about the library, with a brief explanation of how to use it."""
|
|
9
|
+
color = {
|
|
10
|
+
"lib": DEFAULT.color["ice"],
|
|
11
|
+
"import": DEFAULT.color["red"],
|
|
12
|
+
"class": DEFAULT.color["lavender"],
|
|
13
|
+
"types": DEFAULT.color["lightblue"],
|
|
14
|
+
"punctuators": DEFAULT.color["darkgray"],
|
|
15
|
+
}
|
|
16
|
+
FormatCodes.print(
|
|
17
|
+
rf""" [_|b|#7075FF] __ __
|
|
18
|
+
[b|#7075FF] _ __ __ __/ / / /_ __ ___ __
|
|
19
|
+
[b|#7075FF] | |/ // / / / / / __ \/ / / | |/ /
|
|
20
|
+
[b|#7075FF] > , </ /_/ / /_/ /_/ / /_/ /> , <
|
|
21
|
+
[b|#7075FF]/_/|_|\____/\__/\____/\____//_/|_| [*|BG:{DEFAULT.color['gray']}|#000] v[b]{__version__} [*]
|
|
22
|
+
|
|
23
|
+
[i|{DEFAULT.color['coral']}]A TON OF COOL FUNCTIONS, YOU NEED![*]
|
|
24
|
+
|
|
25
|
+
[b|#75A2FF]Usage:[*]
|
|
26
|
+
[{color['punctuators']}]# GENERAL LIBRARY[*]
|
|
27
|
+
[{color['import']}]import [{color['lib']}]xulbux [{color['import']}]as [{color['lib']}]xx[*]
|
|
28
|
+
[{color['punctuators']}]# CUSTOM TYPES[*]
|
|
29
|
+
[{color['import']}]from [{color['lib']}]xulbux [{color['import']}]import [{color['lib']}]rgba[{color['punctuators']}], [{color['lib']}]hsla[{color['punctuators']}], [{color['lib']}]hexa[*]
|
|
30
|
+
|
|
31
|
+
[b|#75A2FF]Includes:[*]
|
|
32
|
+
[dim](•) CUSTOM TYPES:
|
|
33
|
+
[dim](•) [{color['class']}]rgba[{color['punctuators']}]/([i|{color['types']}]int[_|{color['punctuators']}],[i|{color['types']}]int[_|{color['punctuators']}],[i|{color['types']}]int[_|{color['punctuators']}],[i|{color['types']}]float[_|{color['punctuators']}])[*]
|
|
34
|
+
[dim](•) [{color['class']}]hsla[{color['punctuators']}]/([i|{color['types']}]int[_|{color['punctuators']}],[i|{color['types']}]int[_|{color['punctuators']}],[i|{color['types']}]int[_|{color['punctuators']}],[i|{color['types']}]float[_|{color['punctuators']}])[*]
|
|
35
|
+
[dim](•) [{color['class']}]hexa[{color['punctuators']}]/([i|{color['types']}]str[_|{color['punctuators']}]|[i|{color['types']}]int[_|{color['punctuators']}])[*]
|
|
36
|
+
[dim](•) PATH OPERATIONS [{color['lib']}]xx[{color['punctuators']}].[{color['class']}]Path[*]
|
|
37
|
+
[dim](•) FILE OPERATIONS [{color['lib']}]xx[{color['punctuators']}].[{color['class']}]File[*]
|
|
38
|
+
[dim](•) JSON FILE OPERATIONS [{color['lib']}]xx[{color['punctuators']}].[{color['class']}]Json[*]
|
|
39
|
+
[dim](•) SYSTEM ACTIONS [{color['lib']}]xx[{color['punctuators']}].[{color['class']}]System[*]
|
|
40
|
+
[dim](•) MANAGE THE ENV PATH VAR [{color['lib']}]xx[{color['punctuators']}].[{color['class']}]EnvPath[*]
|
|
41
|
+
[dim](•) CONSOLE LOG AND ACTIONS [{color['lib']}]xx[{color['punctuators']}].[{color['class']}]Console[*]
|
|
42
|
+
[dim](•) EASY PRETTY PRINTING [{color['lib']}]xx[{color['punctuators']}].[{color['class']}]FormatCodes[*]
|
|
43
|
+
[dim](•) WORKING WITH COLORS [{color['lib']}]xx[{color['punctuators']}].[{color['class']}]Color[*]
|
|
44
|
+
[dim](•) DATA OPERATIONS [{color['lib']}]xx[{color['punctuators']}].[{color['class']}]Data[*]
|
|
45
|
+
[dim](•) STRING OPERATIONS [{color['lib']}]xx[{color['punctuators']}].[{color['class']}]String[*]
|
|
46
|
+
[dim](•) CODE STRING OPERATIONS [{color['lib']}]xx[{color['punctuators']}].[{color['class']}]Code[*]
|
|
47
|
+
[dim](•) REGEX PATTERN TEMPLATES [{color['lib']}]xx[{color['punctuators']}].[{color['class']}]Regex[*]
|
|
48
|
+
[_]
|
|
49
|
+
[dim](Press any key to exit...)
|
|
50
|
+
""",
|
|
51
|
+
default_color=DEFAULT.text_color,
|
|
52
|
+
)
|
|
53
|
+
Console.pause_exit(pause=True)
|
xulbux/_consts_.py
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
class DEFAULT:
|
|
2
|
+
|
|
3
|
+
text_color: str = "#95B5FF"
|
|
4
|
+
color: dict[str, str] = {
|
|
5
|
+
"white": "#F1F2FF",
|
|
6
|
+
"lightgray": "#B6B7C0",
|
|
7
|
+
"gray": "#7B7C8D",
|
|
8
|
+
"darkgray": "#67686C",
|
|
9
|
+
"black": "#202125",
|
|
10
|
+
"red": "#FF606A",
|
|
11
|
+
"coral": "#FF7069",
|
|
12
|
+
"orange": "#FF876A",
|
|
13
|
+
"tangerine": "#FF9962",
|
|
14
|
+
"gold": "#FFAF60",
|
|
15
|
+
"yellow": "#FFD260",
|
|
16
|
+
"green": "#7EE787",
|
|
17
|
+
"teal": "#50EAAF",
|
|
18
|
+
"cyan": "#3EE6DE",
|
|
19
|
+
"ice": "#77EFEF",
|
|
20
|
+
"lightblue": "#60AAFF",
|
|
21
|
+
"blue": "#8085FF",
|
|
22
|
+
"lavender": "#9B7DFF",
|
|
23
|
+
"purple": "#AD68FF",
|
|
24
|
+
"magenta": "#C860FF",
|
|
25
|
+
"pink": "#EE60BB",
|
|
26
|
+
"rose": "#FF6090",
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class CHARS:
|
|
31
|
+
|
|
32
|
+
# CODE TO SIGNAL, ALL CHARACTERS ARE ALLOWED
|
|
33
|
+
all = "<*allowed>"
|
|
34
|
+
|
|
35
|
+
# DIGIT SETS
|
|
36
|
+
digits = "0123456789"
|
|
37
|
+
float_digits = digits + "."
|
|
38
|
+
hex_digits = digits + "#abcdefABCDEF"
|
|
39
|
+
|
|
40
|
+
# LETTER CATEGORIES
|
|
41
|
+
lowercase = "abcdefghijklmnopqrstuvwxyz"
|
|
42
|
+
lowercase_extended = lowercase + "äëïöüÿàèìòùáéíóúýâêîôûãñõåæç"
|
|
43
|
+
uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
44
|
+
uppercase_extended = uppercase + "ÄËÏÖÜÀÈÌÒÙÁÉÍÓÚÝÂÊÎÔÛÃÑÕÅÆÇß"
|
|
45
|
+
|
|
46
|
+
# COMBINED LETTER SETS
|
|
47
|
+
letters = lowercase + uppercase
|
|
48
|
+
letters_extended = lowercase_extended + uppercase_extended
|
|
49
|
+
|
|
50
|
+
# ASCII sets
|
|
51
|
+
special_ascii = " !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"
|
|
52
|
+
special_ascii_extended = special_ascii + "ø£Ø×ƒªº¿®¬½¼¡«»░▒▓│┤©╣║╗╝¢¥┐└┴┬├─┼╚╔╩╦╠═╬¤ðÐı┘┌█▄¦▀µþÞ¯´≡±‗¾¶§÷¸°¨·¹³²■ "
|
|
53
|
+
standard_ascii = special_ascii + digits + letters
|
|
54
|
+
full_ascii = special_ascii_extended + digits + letters_extended
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class ANSI:
|
|
58
|
+
|
|
59
|
+
global CHAR, START, SEP, END
|
|
60
|
+
|
|
61
|
+
char_esc = r"\x1b"
|
|
62
|
+
CHAR = char = "\x1b"
|
|
63
|
+
START = start = "["
|
|
64
|
+
SEP = sep = ";"
|
|
65
|
+
END = end = "m"
|
|
66
|
+
modifier = {"lighten": "+l", "darken": "-d"}
|
|
67
|
+
|
|
68
|
+
def seq(parts: int = 1) -> str:
|
|
69
|
+
"""Generate an ANSI sequence with `parts` amount of placeholders."""
|
|
70
|
+
return CHAR + START + SEP.join(["{}" for _ in range(parts)]) + END
|
|
71
|
+
|
|
72
|
+
seq_color: str = CHAR + START + "38" + SEP + "2" + SEP + "{}" + SEP + "{}" + SEP + "{}" + END
|
|
73
|
+
seq_bg_color: str = CHAR + START + "48" + SEP + "2" + SEP + "{}" + SEP + "{}" + SEP + "{}" + END
|
|
74
|
+
|
|
75
|
+
color_map: list[str] = [
|
|
76
|
+
########### DEFAULT CONSOLE COLOR NAMES ############
|
|
77
|
+
"black",
|
|
78
|
+
"red",
|
|
79
|
+
"green",
|
|
80
|
+
"yellow",
|
|
81
|
+
"blue",
|
|
82
|
+
"magenta",
|
|
83
|
+
"cyan",
|
|
84
|
+
"white",
|
|
85
|
+
]
|
|
86
|
+
|
|
87
|
+
codes_map: dict[str | tuple[str], int] = {
|
|
88
|
+
###################### RESETS ######################
|
|
89
|
+
"_": 0,
|
|
90
|
+
("_bold", "_b"): 22,
|
|
91
|
+
("_dim", "_d"): 22,
|
|
92
|
+
("_italic", "_i"): 23,
|
|
93
|
+
("_underline", "_u"): 24,
|
|
94
|
+
("_double-underline", "_du"): 24,
|
|
95
|
+
("_inverse", "_invert", "_in"): 27,
|
|
96
|
+
("_hidden", "_hide", "_h"): 28,
|
|
97
|
+
("_strikethrough", "_s"): 29,
|
|
98
|
+
("_color", "_c"): 39,
|
|
99
|
+
("_background", "_bg"): 49,
|
|
100
|
+
################### TEXT FORMATS ###################
|
|
101
|
+
("bold", "b"): 1,
|
|
102
|
+
("dim", "d"): 2,
|
|
103
|
+
("italic", "i"): 3,
|
|
104
|
+
("underline", "u"): 4,
|
|
105
|
+
("inverse", "invert", "in"): 7,
|
|
106
|
+
("hidden", "hide", "h"): 8,
|
|
107
|
+
("strikethrough", "s"): 9,
|
|
108
|
+
("double-underline", "du"): 21,
|
|
109
|
+
############## DEFAULT CONSOLE COLORS ##############
|
|
110
|
+
"black": 30,
|
|
111
|
+
"red": 31,
|
|
112
|
+
"green": 32,
|
|
113
|
+
"yellow": 33,
|
|
114
|
+
"blue": 34,
|
|
115
|
+
"magenta": 35,
|
|
116
|
+
"cyan": 36,
|
|
117
|
+
"white": 37,
|
|
118
|
+
########## BRIGHT DEFAULT CONSOLE COLORS ###########
|
|
119
|
+
("bright:black", "br:black"): 90,
|
|
120
|
+
("bright:red", "br:red"): 91,
|
|
121
|
+
("bright:green", "br:green"): 92,
|
|
122
|
+
("bright:yellow", "br:yellow"): 93,
|
|
123
|
+
("bright:blue", "br:blue"): 94,
|
|
124
|
+
("bright:magenta", "br:magenta"): 95,
|
|
125
|
+
("bright:cyan", "br:cyan"): 96,
|
|
126
|
+
("bright:white", "br:white"): 97,
|
|
127
|
+
######## DEFAULT CONSOLE BACKGROUND COLORS #########
|
|
128
|
+
"bg:black": 40,
|
|
129
|
+
"bg:red": 41,
|
|
130
|
+
"bg:green": 42,
|
|
131
|
+
"bg:yellow": 43,
|
|
132
|
+
"bg:blue": 44,
|
|
133
|
+
"bg:magenta": 45,
|
|
134
|
+
"bg:cyan": 46,
|
|
135
|
+
"bg:white": 47,
|
|
136
|
+
##### BRIGHT DEFAULT CONSOLE BACKGROUND COLORS #####
|
|
137
|
+
("bg:bright:black", "bg:br:black"): 100,
|
|
138
|
+
("bg:bright:red", "bg:br:red"): 101,
|
|
139
|
+
("bg:bright:green", "bg:br:green"): 102,
|
|
140
|
+
("bg:bright:yellow", "bg:br:yellow"): 103,
|
|
141
|
+
("bg:bright:blue", "bg:br:blue"): 104,
|
|
142
|
+
("bg:bright:magenta", "bg:br:magenta"): 105,
|
|
143
|
+
("bg:bright:cyan", "bg:br:cyan"): 106,
|
|
144
|
+
("bg:bright:white", "bg:br:white"): 107,
|
|
145
|
+
}
|
xulbux/xx_code.py
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
from .xx_string import String
|
|
2
|
+
from .xx_regex import Regex
|
|
3
|
+
from .xx_data import Data
|
|
4
|
+
|
|
5
|
+
import regex as _rx
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Code:
|
|
9
|
+
|
|
10
|
+
@staticmethod
|
|
11
|
+
def add_indent(code: str, indent: int) -> str:
|
|
12
|
+
"""Adds `indent` spaces at the beginning of each line."""
|
|
13
|
+
indented_lines = [" " * indent + line for line in code.splitlines()]
|
|
14
|
+
return "\n".join(indented_lines)
|
|
15
|
+
|
|
16
|
+
@staticmethod
|
|
17
|
+
def get_tab_spaces(code: str) -> int:
|
|
18
|
+
"""Will try to get the amount of spaces used for indentation."""
|
|
19
|
+
code_lines = String.get_lines(code, remove_empty_lines=True)
|
|
20
|
+
indents = [len(line) - len(line.lstrip()) for line in code_lines]
|
|
21
|
+
non_zero_indents = [i for i in indents if i > 0]
|
|
22
|
+
return min(non_zero_indents) if non_zero_indents else 0
|
|
23
|
+
|
|
24
|
+
@staticmethod
|
|
25
|
+
def change_tab_size(code: str, new_tab_size: int, remove_empty_lines: bool = False) -> str:
|
|
26
|
+
"""Replaces all tabs with `new_tab_size` spaces.\n
|
|
27
|
+
----------------------------------------------------------------------------------
|
|
28
|
+
If `remove_empty_lines` is `True`, empty lines will be removed in the process."""
|
|
29
|
+
code_lines = String.get_lines(code, remove_empty_lines=True)
|
|
30
|
+
lines = code_lines if remove_empty_lines else String.get_lines(code)
|
|
31
|
+
tab_spaces = Code.get_tab_spaces(code)
|
|
32
|
+
if (tab_spaces == new_tab_size) or tab_spaces == 0:
|
|
33
|
+
if remove_empty_lines:
|
|
34
|
+
return "\n".join(code_lines)
|
|
35
|
+
return code
|
|
36
|
+
result = []
|
|
37
|
+
for line in lines:
|
|
38
|
+
stripped = line.lstrip()
|
|
39
|
+
indent_level = (len(line) - len(stripped)) // tab_spaces
|
|
40
|
+
new_indent = " " * (indent_level * new_tab_size)
|
|
41
|
+
result.append(new_indent + stripped)
|
|
42
|
+
return "\n".join(result)
|
|
43
|
+
|
|
44
|
+
@staticmethod
|
|
45
|
+
def get_func_calls(code: str) -> list:
|
|
46
|
+
"""Will try to get all function calls and return them as a list."""
|
|
47
|
+
funcs = _rx.findall(r"(?i)" + Regex.func_call(), code)
|
|
48
|
+
nested_func_calls = []
|
|
49
|
+
for _, func_attrs in funcs:
|
|
50
|
+
nested_calls = _rx.findall(r"(?i)" + Regex.func_call(), func_attrs)
|
|
51
|
+
if nested_calls:
|
|
52
|
+
nested_func_calls.extend(nested_calls)
|
|
53
|
+
return Data.remove_duplicates(funcs + nested_func_calls)
|
|
54
|
+
|
|
55
|
+
@staticmethod
|
|
56
|
+
def is_js(code: str, funcs: list = ["__", "$t", "$lang"]) -> bool:
|
|
57
|
+
"""Will check if the code is very likely to be JavaScript."""
|
|
58
|
+
funcs = "|".join(funcs)
|
|
59
|
+
js_pattern = _rx.compile(
|
|
60
|
+
Regex.outside_strings(
|
|
61
|
+
r"""^(?:
|
|
62
|
+
(\$[\w_]+)\s* # JQUERY-STYLE VARIABLES
|
|
63
|
+
|(\$[\w_]+\s*\() # JQUERY-STYLE FUNCTION CALLS
|
|
64
|
+
|(("""
|
|
65
|
+
+ funcs
|
|
66
|
+
+ r")"
|
|
67
|
+
+ Regex.brackets("()")
|
|
68
|
+
+ r"""\s*) # PREDEFINED FUNCTION CALLS
|
|
69
|
+
|(\bfunction\s*\() # FUNCTION DECLARATIONS
|
|
70
|
+
|(\b(var|let|const)\s+[\w_]+\s*=) # VARIABLE DECLARATIONS
|
|
71
|
+
|(\b(if|for|while|switch)\s*\() # CONTROL STRUCTURES
|
|
72
|
+
|(\b(return|throw)\s+) # RETURN OR THROW STATEMENTS
|
|
73
|
+
|(\bnew\s+[\w_]+\() # OBJECT INSTANTIATION
|
|
74
|
+
|(\b[\w_]+\s*=>\s*{) # ARROW FUNCTIONS
|
|
75
|
+
|(\b(true|false|null|undefined)\b) # JAVASCRIPT LITERALS
|
|
76
|
+
|(\b(document|window|console)\.) # BROWSER OBJECTS
|
|
77
|
+
|(\b[\w_]+\.(forEach|map|filter|reduce)\() # ARRAY METHODS
|
|
78
|
+
|(/[^/\n\r]*?/[gimsuy]*) # REGULAR EXPRESSIONS
|
|
79
|
+
|(===|!==|\+\+|--|\|\||&&) # JAVASCRIPT-SPECIFIC OPERATORS
|
|
80
|
+
|(\bclass\s+[\w_]+) # CLASS DECLARATIONS
|
|
81
|
+
|(\bimport\s+.*?from\s+) # IMPORT STATEMENTS
|
|
82
|
+
|(\bexport\s+(default\s+)?) # EXPORT STATEMENTS
|
|
83
|
+
|(\basync\s+function) # ASYNC FUNCTIONS
|
|
84
|
+
|(\bawait\s+) # AWAIT KEYWORD
|
|
85
|
+
|(\btry\s*{) # TRY-CATCH BLOCKS
|
|
86
|
+
|(\bcatch\s*\()
|
|
87
|
+
|(\bfinally\s*{)
|
|
88
|
+
|(\byield\s+) # GENERATOR FUNCTIONS
|
|
89
|
+
|(\[.*?\]\s*=) # DESTRUCTURING ASSIGNMENT
|
|
90
|
+
|(\.\.\.) # SPREAD OPERATOR
|
|
91
|
+
|(==|!=|>=|<=|>|<) # COMPARISON OPERATORS
|
|
92
|
+
|(\+=|-=|\*=|/=|%=|\*\*=) # COMPOUND ASSIGNMENT OPERATORS
|
|
93
|
+
|(\+|-|\*|/|%|\*\*) # ARITHMETIC OPERATORS
|
|
94
|
+
|(&|\||\^|~|<<|>>|>>>) # BITWISE OPERATORS
|
|
95
|
+
|(\?|:) # TERNARY OPERATOR
|
|
96
|
+
|(\bin\b) # IN OPERATOR
|
|
97
|
+
|(\binstanceof\b) # INSTANCEOF OPERATOR
|
|
98
|
+
|(\bdelete\b) # DELETE OPERATOR
|
|
99
|
+
|(\btypeof\b) # TYPEOF OPERATOR
|
|
100
|
+
|(\bvoid\b) # VOID OPERATOR
|
|
101
|
+
)[\s\S]*$"""
|
|
102
|
+
),
|
|
103
|
+
_rx.VERBOSE | _rx.IGNORECASE,
|
|
104
|
+
)
|
|
105
|
+
return bool(js_pattern.fullmatch(code))
|