@jeefo/javascript_preprocessor
Advanced tools
Comparing version 0.0.6 to 0.0.7
42
index.js
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. | ||
* File Name : index.js | ||
* Created at : 2020-05-30 | ||
* Updated at : 2020-11-24 | ||
* Updated at : 2021-01-05 | ||
* Author : jeefo | ||
@@ -64,2 +64,3 @@ * Purpose : | ||
case "Identifier" : | ||
case "Identifier name" : | ||
case "Label identifier" : | ||
@@ -78,4 +79,10 @@ case "Binding identifier" : | ||
// Keyword | ||
case "Keyword" : | ||
case "This keyword" : | ||
// Others | ||
case "Comment" : | ||
case "Undefined" : | ||
case "Punctuator" : | ||
case "New target" : | ||
@@ -87,13 +94,2 @@ case "Debugger statement" : | ||
case "Keyword" : | ||
case "Punctuator" : | ||
case "This keyword" : | ||
case "Identifier name" : | ||
if (node.pre_comment) await this.walk(node.pre_comment); | ||
break; | ||
case "Comment" : | ||
if (node.previous_comment) await this.walk(node.previous_comment); | ||
break; | ||
case "Binding pattern" : | ||
@@ -229,5 +225,3 @@ case "Assignment pattern" : | ||
case "Async arrow function body" : | ||
await this.walk(node.open_curly_bracket); | ||
for (const n of node.statement_list) await this.walk(n); | ||
await this.walk(node.close_curly_bracket); | ||
break; | ||
@@ -244,5 +238,3 @@ | ||
case "Grouping expression" : | ||
await this.walk(node.open_parenthesis); | ||
for (const n of node.expressions_list) await this.walk(n); | ||
await this.walk(node.close_parenthesis); | ||
break; | ||
@@ -502,2 +494,3 @@ | ||
// TODO: fix replacement's end index | ||
async compile (module) { | ||
@@ -509,6 +502,7 @@ this.module = module; | ||
module.replacements.sort(sort_by_start_index); | ||
let i = module.replacements.length; | ||
while (i--) { | ||
let {replacement, start, end} = module.replacements[i]; | ||
const {replacements} = module; | ||
replacements.sort(sort_by_start_index); | ||
while (replacements.length) { | ||
const _replacement = replacements.pop(); | ||
let {replacement, start, end} = _replacement; | ||
if (typeof replacement === "function") { | ||
@@ -520,4 +514,10 @@ replacement = await replacement(); | ||
replacement, | ||
module.content.slice(end), | ||
module.content.slice(end + 1), | ||
].join(''); | ||
const delta = replacement.length - ((end+1) - start); | ||
for (const r of replacements) { | ||
if (r.end > end) r.end += delta; | ||
if (r.start > end) r.start += delta; | ||
} | ||
} | ||
@@ -524,0 +524,0 @@ } |
{ | ||
"name": "@jeefo/javascript_preprocessor", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"homepage": "https://github.com/je3f0o/jeefo_javascript_preprocessor", | ||
@@ -5,0 +5,0 @@ "copyright": "2020", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21492