Skip to content

Commit 0ad3e60

Browse files
committed
Refactoring of Obfuscator class
1 parent bdb5aae commit 0ad3e60

File tree

3 files changed

+7
-15
lines changed

3 files changed

+7
-15
lines changed

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "javascript-obfuscator",
3-
"version": "0.11.0-beta.2",
3+
"version": "0.11.0",
44
"description": "JavaScript obfuscator",
55
"keywords": [
66
"obfuscator",

src/Obfuscator.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,8 @@ export class Obfuscator implements IObfuscator {
135135
private static isBlackListNode (node: ESTree.Node): boolean {
136136
const guardsLength: number = Obfuscator.blackListGuards.length;
137137

138-
let guard: TNodeGuard;
139-
140138
for (let i: number = 0; i < guardsLength; i++) {
141-
guard = Obfuscator.blackListGuards[i];
142-
143-
if (guard(node)) {
139+
if (Obfuscator.blackListGuards[i](node)) {
144140
return true;
145141
}
146142
}
@@ -245,23 +241,19 @@ export class Obfuscator implements IObfuscator {
245241
* @returns {TVisitorFunction}
246242
*/
247243
private mergeVisitorsForDirection (visitors: IVisitor[], direction: TVisitorDirection): TVisitorFunction {
248-
if (!visitors.length) {
249-
return (node: ESTree.Node, parentNode: ESTree.Node) => node;
250-
}
251-
252244
const visitorsLength: number = visitors.length;
253245

254-
let visitor: IVisitor;
246+
if (!visitorsLength) {
247+
return (node: ESTree.Node, parentNode: ESTree.Node) => node;
248+
}
255249

256250
return (node: ESTree.Node, parentNode: ESTree.Node) => {
257251
if (Obfuscator.isBlackListNode(node)) {
258252
return estraverse.VisitorOption.Skip;
259253
}
260254

261255
for (let i: number = 0; i < visitorsLength; i++) {
262-
visitor = visitors[i];
263-
264-
const visitorFunction: TVisitorFunction | undefined = visitor[direction];
256+
const visitorFunction: TVisitorFunction | undefined = visitors[i][direction];
265257

266258
if (!visitorFunction) {
267259
continue;

0 commit comments

Comments
 (0)