You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[tong@localhost test]$ node genTest.js
rtn1 1
error TypeError: You may only yield a function, promise, generator, array, or object, but the following object was passed: "0"
Expect:
[tong@localhost test]$ node genTest.js
rtn1 1
rtn0 0
result 0
The text was updated successfully, but these errors were encountered:
This should be: if(!(seconds > 0)) return Promise.resolve(0);
Mixing return types in an un-typed language like JS is just asking for maintainability and debugging nightmares. By returning a synchronous Promise, you keep the structure of the code relatively the same and don't introduce any sort of type-handling (was I returned a Promise or a primitive?)
Will get:
[tong@localhost test]$ node genTest.js rtn1 1 error TypeError: You may only yield a function, promise, generator, array, or object, but the following object was passed: "0"
Expect:
The text was updated successfully, but these errors were encountered: