trumank / scratch-api

An API to interact with the Scratch website
MIT License
94 stars 32 forks source link

Get the email of a user #29

Closed YodaLightsabr closed 3 years ago

YodaLightsabr commented 3 years ago

adds a UserSession.getEmail() method

YodaLightsabr commented 3 years ago

@trumank Please read. Thanks!

edqx commented 3 years ago

https://bundlephobia.com/result?p=cheerio@1.0.0-rc.5 Adding cheerio as a dependency? Are you sure you can't just use a RegExp?

edqx commented 3 years ago

The email is also accessible without a separate http request, see https://github.com/edqx/node-scratch-client/blob/c1bb6e8c7086e40abbb7789a7a47a2ec5fe65fcb/src/Struct/AuthorizedUser.js#L14 https://github.com/edqx/node-scratch-client/blob/c1bb6e8c7086e40abbb7789a7a47a2ec5fe65fcb/src/Struct/SessionFlags.js#L29 When you fetch the current user session. See https://github.com/edqx/node-scratch-client/blob/c1bb6e8c7086e40abbb7789a7a47a2ec5fe65fcb/src/Client.js#L66

YodaLightsabr commented 3 years ago

https://bundlephobia.com/result?p=cheerio@1.0.0-rc.5 Adding cheerio as a dependency? Are you sure you can't just use a RegExp?

@edqx That would be a better way of doing it. If you're so good at RegExp, why not show me how you would?

YodaLightsabr commented 3 years ago

The email is also accessible without a separate http request, see https://github.com/edqx/node-scratch-client/blob/c1bb6e8c7086e40abbb7789a7a47a2ec5fe65fcb/src/Struct/AuthorizedUser.js#L14 https://github.com/edqx/node-scratch-client/blob/c1bb6e8c7086e40abbb7789a7a47a2ec5fe65fcb/src/Struct/SessionFlags.js#L29 When you fetch the current user session. See https://github.com/edqx/node-scratch-client/blob/c1bb6e8c7086e40abbb7789a7a47a2ec5fe65fcb/src/Client.js#L66

Well this package does not use classes for representing data, and I hadn't seen that. Look, if you're going to get upset because I was trying to contribute and you can do so much better, than go ahead.

edqx commented 3 years ago

Excuse me? Pull requests have to be critiqued, that's the entire point of someone to review them before they get merged.

Look, I'm just suggesting better ways of doing what you want to do.

If you don't want anyone to be critical of your methods or your code then I'm not sure computer science is a good career path.

edqx commented 3 years ago

Cheerio is a 300kb dependency, for a package that should really have as little dependencies as possible, I don't think this is a good method.

It might be worth learning regex if you need to do simple finding in a div, especially if the data is quite predictable like it is in this situation.

Please don't get angry at me for suggesting a better method.