Hyperlinkv0.8.0-beta.28

String

String.charAtconsteffect/String.ts:598
(index: number): (self: string) => Option.Option<string>
(self: string, index: number): Option.Option<string>

Returns the character at the specified non-negative index safely, or None if the index is out of bounds.

Example (Reading characters safely)

import { pipe, String } from "effect"

pipe("abc", String.charAt(1)) // Option.some("b")
pipe("abc", String.charAt(4)) // Option.none()
elements
Source effect/String.ts:5987 lines
export const charAt: {
  (index: number): (self: string) => Option.Option<string>
  (self: string, index: number): Option.Option<string>
} = dual(
  2,
  (self: string, index: number): Option.Option<string> => Option.filter(Option.some(self.charAt(index)), isNonEmpty)
)