sugar-high 0.1.1 → 0.1.2
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/lib/index.mjs +9 -4
- package/package.json +1 -1
package/lib/index.mjs
CHANGED
|
@@ -147,7 +147,7 @@ function isRegexStart(str) {
|
|
|
147
147
|
export function tokenize(code) {
|
|
148
148
|
let current = ''
|
|
149
149
|
let type = -1
|
|
150
|
-
let
|
|
150
|
+
let last = [null, null]
|
|
151
151
|
/** @type {Array<[number, string]>} */
|
|
152
152
|
const tokens = []
|
|
153
153
|
|
|
@@ -197,8 +197,12 @@ export function tokenize(code) {
|
|
|
197
197
|
const append = () => {
|
|
198
198
|
if (current) {
|
|
199
199
|
type = classify(current)
|
|
200
|
-
|
|
201
|
-
|
|
200
|
+
/** @type [number, string] */
|
|
201
|
+
const pair = [type, current]
|
|
202
|
+
if (type !== T_SPACE && type !== T_BREAK) {
|
|
203
|
+
last = pair
|
|
204
|
+
}
|
|
205
|
+
tokens.push(pair)
|
|
202
206
|
}
|
|
203
207
|
current = ''
|
|
204
208
|
}
|
|
@@ -226,7 +230,8 @@ export function tokenize(code) {
|
|
|
226
230
|
(isStringQuotation(curr) || !jsx.tag && isRegexStart(c_n))
|
|
227
231
|
) {
|
|
228
232
|
append()
|
|
229
|
-
|
|
233
|
+
const [lastType, lastToken] = last
|
|
234
|
+
if (!((lastType === T_SIGN && !'()[]'.includes(lastToken)) || lastType === T_COMMENT)) {
|
|
230
235
|
current = curr
|
|
231
236
|
append()
|
|
232
237
|
continue
|