danielwerg / r6api.js

🍫 Node.js wrapper around Rainbow Six Siege APIs
https://npm.im/r6api.js
MIT License
111 stars 19 forks source link

Methods script is broken #48

Closed danielwerg closed 3 years ago

danielwerg commented 3 years ago

methods.ts script is broken after these two commits: https://github.com/danielwerg/r6api.js/commit/62ac72c37bcdff72f70ac695346f0e03a4db4a96#diff-8fa4b52909f895e8cda060d2035234e0a42ca2c7d3f8f8de1b35a056537bf199 https://github.com/danielwerg/r6api.js/commit/c0fdf5046a8befab0107a7e7e42f8b02e18f30af#diff-8fa4b52909f895e8cda060d2035234e0a42ca2c7d3f8f8de1b35a056537bf199

structureChange will always return true because it's writing string to json but originally we have object for season release date.

https://github.com/danielwerg/r6api.js/blob/typescript/docs/methods/getRanks.json#L12 https://github.com/danielwerg/r6api.js/tree/typescript#getranks https://github.com/danielwerg/r6api.js/blob/typescript/src/constants.ts#L65

Solutions?

Return string instead of date object, but I'm not sure what's is a best practice for that because of timezones stuff.

EndBug commented 3 years ago

I think the problem is the fact that you're not writing a JSON output to the file anymore, but you're still parsing it as JSON: you're currently writing with stringify-object to the readme, but you're still parsing with JSON.parse from the saved file

I can think of two solutions:

If you ask me, it seems like all this work isn't worth returning a couple of dates: you can just return the string since that can be parsed back into a Date object. You don't need to worry about timezones because if they're able to re-parse it back to a Date they can also deal with their specific timezone as they would do with any other date.