@@ -213,19 +213,36 @@ external charAt: (string, int) => string = "charAt"
213
213
`charCodeAt(str, index)` returns the character code at position `index` in
214
214
string `str` the result is in the range 0-65535, unlike `codePointAt`, so it
215
215
will 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.
218
217
See [`String.charCodeAt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt) on MDN.
219
218
220
219
## Examples
221
220
222
221
```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
224
241
String.codePointAt(`😺`, 0) == Some(0x1f63a)
225
242
```
226
243
*/
227
244
@send
228
- external charCodeAt : (string , int ) => int = "charCodeAt"
245
+ external charCodeAtUnsafe : (string , int ) => int = "charCodeAt"
229
246
230
247
/**
231
248
`codePointAt(str, index)` returns the code point at position `index` within
0 commit comments