Closed codetheweb closed 5 years ago
@codetheweb I had a quick play but my knowledge of js is very limited so I only made some changes which should help but someone should properly test them out first. Also I've removed some throw errors since a missing id can now be resolved and all get commands work without a key. So I don't think an error should be thrown on init but there probably should be some check on the functions to make sure the person has run resolveID and/or isn't using set without a key. I really don't understand js well enough when it comes to Promises so decided to not touch the get/set functions.
Edit: Can you let me know how to fix what I've done. I tried to fix all the errors but... https://github.com/codetheweb/tuyapi/pull/141
As @unparagoned pointed out, if empty strings are provided for the ID or key, TuyAPI doesn't complain.
This needs to be fixed with stricter type checking, and not just for the constructor arguments. All functions should be checked to ensure their arguments are correctly checked.
Also, I've heard that TypeScript has these kinds of things built in. May want to look into porting TuyAPI to TypeScript.