We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Like Number.parse this would be a nice addition.
const parseInt = (str: string, radix?: number): Option.Option<number> => { const num = Number.parseInt(str, radix); if (Number.isNaN(num)) { return Option.none(); } return Option.some(num); };
Exists internally here:
effect/packages/effect/src/internal/configProvider.ts
Line 696 in 3e7ce97
No response
The text was updated successfully, but these errors were encountered:
@jessekelly881 you can define a simple parseInt from Effect's Schema library.
parseInt
Schema
import { Schema } from "effect" const parseInt = Schema.decodeOption(Schema.NumberFromString); const decodedNumber = parseInt("2"); const decodedNaN = parseInt(""); console.log(decodedNumber); // decodes to { _id: 'Option', _tag: 'Some', value: 2 } console.log(decodedNaN); // decodes to { _id: 'Option', _tag: 'None' }
Demo
Let me know if that works for you.
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
What is the problem this feature would solve?
Like Number.parse this would be a nice addition.
What is the feature you are proposing to solve the problem?
Exists internally here:
effect/packages/effect/src/internal/configProvider.ts
Line 696 in 3e7ce97
What alternatives have you considered?
No response
The text was updated successfully, but these errors were encountered: