-
Notifications
You must be signed in to change notification settings - Fork 27
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
fix(playground): return the string of NaN and Infinity in the playground #505
base: master
Are you sure you want to change the base?
fix(playground): return the string of NaN and Infinity in the playground #505
Conversation
@YonatanKra thanks for creating another PR 💪 Can you explain your rationale of fixing this and how this PR was tested? As you have noticed in #367 (comment) neither |
What I did was change how the playground works. It returns a string of Infinity or NaN in case these values are returned (instead of returning a json.stringifyof them. Tested on local playground |
export async function compileAskCode( | ||
baseEnvironment: { | ||
values?: { [p: string]: any }; | ||
customValues?: { [p: string]: any }; | ||
resources: { | ||
[p: string]: Resource<any, any>; | ||
}; | ||
}, | ||
askCode: AskCodeOrValue | ||
) { | ||
let result = await runUntyped(baseEnvironment, askCode, []); | ||
if ( | ||
result === Infinity || | ||
result === -Infinity || | ||
(typeof result === 'number' && isNaN(result)) | ||
) { | ||
result = result.toString(); | ||
} | ||
return result; | ||
} |
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.
@mhagmajer this is the "magic". Would it be valid to add this logic to the middleware as well?
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.
Let's wait for discussion at #367 (comment) to resolve
@YonatanKra , I believe we should first finish our discussion in #367 and only after that create any PRs. |
Drafted :) |
Closes #367
See my comment in #367 regarding Infinity and NaN in JSON