Skip to content

Latest commit

 

History

History
85 lines (61 loc) · 1.48 KB

File metadata and controls

85 lines (61 loc) · 1.48 KB

Representer normalizations

The JavaScript representer applies the following normalizations:

Remove comments

All comments are removed. The following examples are equivalent:

Example with comments

/**
 * Returns the string literal 'hi there' just to say hello
 * @return [String]
 */
function hello(/* nothing*/) {
  // just return it
  return 'hi there';
}

Example without comments

function hello() {
  return 'hi there';
}

Normalize whitespace

When the code is represented, it's order is significant, but its physical location is not. This means that whitespace is normalized. The following examples are equivalent:

Example with two-space indentation

function hello() {
  return 'hello world';
}

Example with four-space indentation

function hello() {
  return 'hello world';
}

Example with interesting indentation

function hello() {
  return 'hello world';
}

Normalize identifiers

Identifiers are normalized to a placeholder value.

Before

const MY_CONSTANT = 42;

function answer(multiplier, addition = 1) {
  return MY_CONSTANT * multiplier + addition;
}

After

const PLACEHOLDER_1 = 42;

function PLACEHOLDER_2(PLACEHOLDER_3, PLACEHOLDER_4 = 1) {
  return PLACEHOLDER_1 * PLACEHOLDER_3 + PLACEHOLDER_4;
}