From 4ff83bdc3faf12ee0513feed9de62b68a6952aca Mon Sep 17 00:00:00 2001 From: LuanRT Date: Wed, 2 Feb 2022 06:04:39 -0300 Subject: [PATCH] style: add missing semi & rename some variables --- lib/NToken.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/NToken.js b/lib/NToken.js index f7fd4539..b05164fe 100644 --- a/lib/NToken.js +++ b/lib/NToken.js @@ -6,8 +6,8 @@ const Constants = require('./Constants'); class NToken { constructor(raw_code) { this.raw_code = raw_code; - this.null_placeholder_regex = /c\[(.*?)\]=c/g; - this.transformation_calls_regex = /c\[(.*?)\]\((.+?)\)/g; + this.placeholders_regex = /c\[(.*?)\]=c/g; + this.calls_regex = /c\[(.*?)\]\((.+?)\)/g; } /** @@ -41,21 +41,21 @@ class NToken { return el; }); - // Fills the null placeholders with a copy of the transformations array - const null_placeholder_positions = [...this.raw_code.matchAll(this.null_placeholder_regex)].map((item) => parseInt(item[1])); - null_placeholder_positions.forEach((pos) => transformations[pos] = transformations); + // Fills all placeholders with the transformations array + const placeholder_indexes = [...this.raw_code.matchAll(this.placeholders_regex)].map((item) => parseInt(item[1])); + placeholder_indexes.forEach((i) => transformations[i] = transformations); // Parses and emulates calls to the functions of the transformations array - const transformation_calls = [...Utils.getStringBetweenStrings(this.raw_code.replace(/\n/g, ''), 'try{', '}catch') - .matchAll(this.transformation_calls_regex)].map((params) => ({ index: params[1], params: params[2] })); + const function_calls = [...Utils.getStringBetweenStrings(this.raw_code.replace(/\n/g, ''), 'try{', '}catch') + .matchAll(this.calls_regex)].map((params) => ({ index: params[1], params: params[2] })); - transformation_calls.forEach((data) => { + function_calls.forEach((data) => { const param_index = data.params.split(',').map((param) => param.match(/c\[(.*?)\]/)[1]); const base64_dia = (param_index[2] && transformations[param_index[2]]()); transformations[data.index](transformations[param_index[0]], transformations[param_index[1]], base64_dia); }); } catch (err) { - console.error(`Could not transform n-token (${n}), download may be throttled:`, err) + console.error(`Could not transform n-token (${n}), download may be throttled:`, err); return n; } return n_token.join('');