• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

javascript-obfuscator / javascript-obfuscator / 23399733326

22 Mar 2026 09:03AM UTC coverage: 96.319% (-0.006%) from 96.325%
23399733326

push

github

web-flow
Updated reserved DOM properties list (#1397)

1948 of 2120 branches covered (91.89%)

Branch coverage included in aggregate %.

6006 of 6138 relevant lines covered (97.85%)

30574346.56 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

98.04
/src/node-transformers/converting-transformers/ObjectPatternPropertiesTransformer.ts
1
import { inject, injectable } from 'inversify';
6✔
2
import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
6✔
3

4
import * as ESTree from 'estree';
5

6
import { TNodeWithLexicalScope } from '../../types/node/TNodeWithLexicalScope';
7

8
import { IOptions } from '../../interfaces/options/IOptions';
9
import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
10
import { IVisitor } from '../../interfaces/node-transformers/IVisitor';
11

12
import { NodeTransformationStage } from '../../enums/node-transformers/NodeTransformationStage';
6✔
13

14
import { AbstractNodeTransformer } from '../AbstractNodeTransformer';
6✔
15
import { NodeGuards } from '../../node/NodeGuards';
6✔
16
import { NodeLexicalScopeUtils } from '../../node/NodeLexicalScopeUtils';
6✔
17
import { NodeUtils } from '../../node/NodeUtils';
6✔
18

19
@injectable()
20
export class ObjectPatternPropertiesTransformer extends AbstractNodeTransformer {
6✔
21
    /**
22
     * @param {IRandomGenerator} randomGenerator
23
     * @param {IOptions} options
24
     */
25
    public constructor(
26
        @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
27
        @inject(ServiceIdentifiers.IOptions) options: IOptions
28
    ) {
29
        super(randomGenerator, options);
199,666✔
30
    }
31

32
    /**
33
     * @param {NodeTransformationStage} nodeTransformationStage
34
     * @returns {IVisitor | null}
35
     */
36
    public getVisitor(nodeTransformationStage: NodeTransformationStage): IVisitor | null {
37
        switch (nodeTransformationStage) {
1,629,049✔
38
            case NodeTransformationStage.Converting:
1,629,049✔
39
                return {
398,840✔
40
                    enter: (node: ESTree.Node, parentNode: ESTree.Node | null): ESTree.Node | undefined => {
41
                        if (parentNode && NodeGuards.isPropertyNode(node)) {
32,654,367✔
42
                            return this.transformNode(node, parentNode);
978,814✔
43
                        }
44
                    }
45
                };
46

47
            default:
48
                return null;
1,230,209✔
49
        }
50
    }
51

52
    /**
53
     * replaces:
54
     *     const {foo} = bar;
55
     *
56
     * on:
57
     *     const {foo: foo} = bar;
58
     *
59
     * @param {Property} propertyNode
60
     * @param {NodeGuards} parentNode
61
     * @returns {NodeGuards}
62
     */
63
    public transformNode(propertyNode: ESTree.Property, parentNode: ESTree.Node): ESTree.Node {
64
        if (!NodeGuards.isObjectPatternNode(parentNode) || !propertyNode.shorthand) {
978,814✔
65
            return propertyNode;
978,718✔
66
        }
67

68
        if (!this.options.renameGlobals) {
96✔
69
            const lexicalScope: TNodeWithLexicalScope | undefined = NodeLexicalScopeUtils.getLexicalScope(propertyNode);
72✔
70
            const isInsideStaticBlock: boolean = this.isInsideStaticBlock(propertyNode);
72✔
71
            const shouldNotTransformGlobalPropertyNode: boolean =
72
                !!lexicalScope && NodeGuards.isProgramNode(lexicalScope) && !isInsideStaticBlock;
72✔
73

74
            if (shouldNotTransformGlobalPropertyNode) {
72✔
75
                return propertyNode;
12✔
76
            }
77
        }
78

79
        propertyNode.shorthand = false;
84✔
80
        propertyNode.value = NodeUtils.clone(propertyNode.value);
84✔
81

82
        NodeUtils.parentizeNode(propertyNode.value, propertyNode);
84✔
83

84
        return propertyNode;
84✔
85
    }
86

87
    /**
88
     * @param {Node} node
89
     * @returns {boolean}
90
     */
91
    private isInsideStaticBlock(node: ESTree.Node): boolean {
92
        let currentNode: ESTree.Node | undefined = node;
72✔
93

94
        while (currentNode) {
72✔
95
            if (NodeGuards.isStaticBlockNode(currentNode)) {
402✔
96
                return true;
12✔
97
            }
98

99
            if (NodeGuards.isFunctionNode(currentNode) || NodeGuards.isProgramNode(currentNode)) {
390✔
100
                return false;
60✔
101
            }
102

103
            currentNode = currentNode.parentNode;
330✔
104
        }
105

106
        return false;
×
107
    }
108
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc