@@ -213,19 +213,36 @@ external charAt: (string, int) => string = "charAt"
213213`charCodeAt(str, index)` returns the character code at position `index` in
214214string `str` the result is in the range 0-65535, unlike `codePointAt`, so it
215215will not work correctly for characters with code points greater than or equal
216- to 0x10000. The return type is `float` because this function returns NaN if
217- `index` is less than zero or greater than the length of the string.
216+ to 0x10000.
218217See [`String.charCodeAt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt) on MDN.
219218
220219## Examples
221220
222221```rescript
223- String.charCodeAt(`😺`, 0) == 0xd83d
222+ String.charCodeAt(`😺`, 0) == Some(0xd83d)
223+ String.charCodeAt("", 0) == None
224+ String.codePointAt(`😺`, 0) == Some(0x1f63a)
225+ ```
226+ */
227+ let charCodeAt : (string , int ) => option <int >
228+
229+ /**
230+ `charCodeAtUnsafe(str, index)` returns the character code at position `index` in
231+ string `str` the result is in the range 0-65535, unlike `codePointAt`, so it
232+ will not work correctly for characters with code points greater than or equal
233+ to 0x10000.
234+ Beware: If the index is out of range, it will return `NaN` which is not actually a valid int.
235+ See [`String.charCodeAt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt) on MDN.
236+
237+ ## Examples
238+
239+ ```rescript
240+ String.charCodeAtUnsafe(`😺`, 0) == 0xd83d
224241String.codePointAt(`😺`, 0) == Some(0x1f63a)
225242```
226243*/
227244@send
228- external charCodeAt : (string , int ) => int = "charCodeAt"
245+ external charCodeAtUnsafe : (string , int ) => int = "charCodeAt"
229246
230247/**
231248`codePointAt(str, index)` returns the code point at position `index` within
0 commit comments