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

First stab at classes #336

Merged
merged 2 commits into from
May 14, 2018
Merged

First stab at classes #336

merged 2 commits into from
May 14, 2018

Conversation

hildjj
Copy link
Contributor

@hildjj hildjj commented May 8, 2018

source-map-consumer.js is a mess in order to keep the API the same. That file needs careful review. Everything else is pretty straightforward. Fixes #334. Fixes #259.

Don't merge yet; I want to double-check the coverage and think about it a bit more. But I'd love a few extra eyeballs on this in the meantime. Feel free to be brutal in comments.

… the API the same. That file needs careful review. Everything else is pretty straightforward. Fixes mozilla#334.  Fixes mozilla#259.
@hildjj hildjj mentioned this pull request May 10, 2018
Copy link
Contributor Author

@hildjj hildjj left a comment

Choose a reason for hiding this comment

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

One minor change to make. Would like another solid review before merge, but I'm ready to go.

@@ -5,116 +5,96 @@
* http://opensource.org/licenses/BSD-3-Clause
*/

const util = require("./util");
const has = Object.prototype.hasOwnProperty;
const hasNativeMap = typeof Map !== "undefined";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Everywhere that has classes has Map. No need for this backward-compat anymore.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

*
* @returns Number
*/
size() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note to self: next time don't reorder functions at the same time. Yes, it's nice to have the static's at the top, but it makes the patch harder to read.


class SourceMapConsumer {
constructor(aSourceMap, aSourceMapURL) {
// If the constructor was called by super(), just return Promise<this>.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this enough comment for the hack?

sourceMap = util.parseSourceMapInput(aSourceMap);
}

return Promise.resolve().then(_ => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's no reason to put a then() here. We can just put the trigraph inside resolve().

});
}
static initialize(opts) {
readWasm.initialize(opts["lib/mappings.wasm"]);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This line isn't covered in the tests. Does running the tests in the browser depend on #158 ?

Copy link
Contributor

Choose a reason for hiding this comment

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

This line isn't covered in the tests.

Yeah, that's because it isn't needed on node.

Does running the tests in the browser depend on #158 ?

I don't think so... Unsure if that issue is still relevant at all or not.

}
class BasicSourceMapConsumer extends SourceMapConsumer {
constructor(aSourceMap, aSourceMapURL) {
return super(INTERNAL).then(that => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

You thought that was a holdover from before arrow functions. But in this case, the constructor returns a Promise, which is pretty non-standard. So hence the workaround.

/**
* The version of the source mapping spec that we are consuming.
*/
BasicSourceMapConsumer.prototype._version = 3;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Used the one off the base class prototype. Don't know if that's strictly what was desired, but this whole conglomeration of classes is unlikely to work for another version number than 3.

Copy link
Contributor

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

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

LGTM! Let me know when you think this is not WIP anymore.

Thanks!

@@ -5,116 +5,96 @@
* http://opensource.org/licenses/BSD-3-Clause
*/

const util = require("./util");
const has = Object.prototype.hasOwnProperty;
const hasNativeMap = typeof Map !== "undefined";
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

});
}
static initialize(opts) {
readWasm.initialize(opts["lib/mappings.wasm"]);
Copy link
Contributor

Choose a reason for hiding this comment

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

This line isn't covered in the tests.

Yeah, that's because it isn't needed on node.

Does running the tests in the browser depend on #158 ?

I don't think so... Unsure if that issue is still relevant at all or not.

@hildjj
Copy link
Contributor Author

hildjj commented May 14, 2018

@fitzgen: ready to merge, as far as I can tell.

@fitzgen fitzgen merged commit 86d2f30 into mozilla:master May 14, 2018
@fitzgen
Copy link
Contributor

fitzgen commented May 14, 2018

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants