This repository has been archived by the owner on Jul 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 398
Style Guide
yurydelendik edited this page Feb 20, 2013
·
13 revisions
Note: This wasn't always followed, but any new code should do this.
- Indentation - 2 spaces
- Line Length - 80 characters
- Required License in File Header
- variables and functions - lowerCamelCase
- constructor like functions - UpperCamelCase
- constants - ALL_UPPER_CASE_WITH_UNDERSCORES
- Always use braces and put them on same line even for single line control statements
if (someVar) {
return true;
} else {
return null;
}
- Space after control statements (if, else, while, for, ...)
if (someVar) {
- Use only strict equalities (and inequalities) in control statements, e.g.
if (someVar === conditionA) {
return true;
} else if (someVar !== conditionB) {
return false;
}
Note: This wasn't always followed, but any new code should do this.
The standard way of creating classes in pdf.js is the following. Please note that by class we mean an object that is class-like. Also, note the naming of all anonymous functions.
var ClassName = (function ClassNameClosure() {
function ClassName(...) {
...
}
ClassName.prototype = {
functionName: function ClassName_functionName(...) {
...
}
};
return ClassName;
})();
Mozilla 2019