Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor Dependency.js to es6 #3696

Merged
merged 2 commits into from Jan 8, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
67 changes: 36 additions & 31 deletions lib/Dependency.js
Expand Up @@ -2,43 +2,48 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
function Dependency() {
this.module = null;
}
module.exports = Dependency;
"use strict";
const compareLocations = require("./compareLocations");

class Dependency {
constructor() {
this.module = null;
}

Dependency.prototype.isEqualResource = function(other) {
return false;
};
isEqualResource() {
return false;
}

// Returns the referenced module and export
Dependency.prototype.getReference = function() {
if(!this.module) return null;
return {
module: this.module,
importedNames: true, // true: full object, false: only sideeffects/no export, array of strings: the exports with this names
// Returns the referenced module and export
getReference() {
if(!this.module) return null;
return {
module: this.module,
importedNames: true, // true: full object, false: only sideeffects/no export, array of strings: the exports with this names
};
}
};

// Returns the exported names
Dependency.prototype.getExports = function() {
return null;
};
// Returns the exported names
getExports() {
return null;
}

Dependency.prototype.getWarnings = function() {
return null;
};
getWarnings() {
return null;
}

Dependency.prototype.updateHash = function(hash) {
hash.update((this.module && this.module.id) + "");
};
updateHash(hash) {
hash.update((this.module && this.module.id) + "");
}

Dependency.prototype.disconnect = function() {
this.module = null;
};
disconnect() {
this.module = null;
}

Dependency.compare = function(a, b) {
return Dependency.compareLocations(a.loc, b.loc);
};
compare(a, b) {
return compareLocations(a.loc, b.loc);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is technically an API change; nothing left around that assumes it can find compareLocations in the constructor?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope :)

}
}
Dependency.compare = (a, b) => compareLocations(a.loc, b.loc);

Dependency.compareLocations = require("./compareLocations");
module.exports = Dependency;