-
Notifications
You must be signed in to change notification settings - Fork 13
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
Return the original response in @exec-time #168
base: 2.11.0
Are you sure you want to change the base?
Conversation
@vlio20 It looks like you should update the CI job. |
trying... |
@masoud-msk do you want to try and updated |
@vlio20 Sorry, I don't have any experience with GitHub Actions! |
@@ -1,5 +1,5 @@ | |||
export function isPromise(obj: any): obj is Promise<any> { | |||
return !!(obj && obj.then !== undefined); | |||
return !!(obj && typeof obj.then === 'function'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this had to be changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Firstly, to exactly reflect the specs.
Secondly, the checked variable was used with await
keyword and it doesn't error on a non-Promise
but I changed the code to call the .then
method on the variable and the runtime throws if it's not a valid Promise
. The reason for this change is that I think it's impossible to implement otherwise.
For clarification see this:
const o1 = { then: func => func(42) }
const o2 = { then: 42 }
await o1 // 42
await o1 // { then: 42 }
o1.then(console.log) // 42
o2.then(console.log) // Uncaught TypeError: o2.then is not a function
P.S. Maybe it's better to write test for this utility function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would you mind to write this utility function as you suggested?
@masoud-msk I fixed the CI. I have few questions regarding your PR. |
This example implies that
@execTime
decorator doesn't change the method signature:But it's not true. This PR is fixing this.
Addressing #171