MCPcopy Create free account
hub / github.com/Effect-TS/effect / parse

Function parse

packages/effect/src/Number.ts:721–736  ·  view source on GitHub ↗
(s: string)

Source from the content-addressed store, hash-verified

719 * @since 2.0.0
720 */
721export const parse = (s: string): Option.Option<number> => {
722 if (s === "NaN") {
723 return Option.some(NaN)
724 }
725 if (s === "Infinity") {
726 return Option.some(Infinity)
727 }
728 if (s === "-Infinity") {
729 return Option.some(-Infinity)
730 }
731 if (s.trim() === "") {
732 return Option.none()
733 }
734 const n = Number(s)
735 return Number.isNaN(n) ? Option.none() : Option.some(n)
736}
737
738/**
739 * Returns the number rounded with the given precision.

Callers

nothing calls this directly

Calls 2

someMethod · 0.80
NumberInterface · 0.70

Tested by

no test coverage detected