Constructor
new CodeMask(source)
Parameters:
| Name | Type | Description |
|---|---|---|
source |
string | The source the mask describes. |
- Source:
Members
mask :Uint8Array
Type:
- Uint8Array
- Source:
regions :Array:.<Region:>
Type:
- Source:
source :string
Type:
- string
- Source:
Methods
isCode(index) → {boolean}
Whether an offset holds executable code rather than literal or comment text.
Parameters:
| Name | Type | Description |
|---|---|---|
index |
number | The offset to test. |
- Source:
Returns:
True when the offset is code.
- Type
- boolean
isLiteral(index) → {boolean}
Whether an offset sits inside a literal whose text is data.
Distinct from CodeMask#isCode: a comment is not code, but its whitespace is still safe to remove, whereas a string or template literal carries its spacing as a value. Anything that rewrites whitespace has to tell those two apart.
Parameters:
| Name | Type | Description |
|---|---|---|
index |
number | The offset to test. |
- Source:
Returns:
True inside a string, template or regex literal.
- Type
- boolean
withoutComments() → {string}
Returns the source with every comment replaced by equivalent whitespace.
Offsets are preserved, so a position found in the blanked text is valid in the original. String and template contents are left alone: they are values, not noise, and blanking them would corrupt the module.
- Source:
Returns:
The comment-free source, same length as the original.
- Type
- string