Hyperlinkv0.8.0-beta.28

String

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

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

Example (Reading character codes)

import { String } from "effect"

String.charCodeAt("abc", 1) // Option.some(98)
String.charCodeAt("abc", 4) // Option.none()
elements
Source effect/String.ts:5378 lines
export const charCodeAt: {
  (index: number): (self: string) => Option.Option<number>
  (self: string, index: number): Option.Option<number>
} = dual(
  2,
  (self: string, index: number): Option.Option<number> =>
    Option.filter(Option.some(self.charCodeAt(index)), (charCode) => !isNaN(charCode))
)