forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcaml_string.js
39 lines (33 loc) · 970 Bytes
/
caml_string.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
'use strict';
var Caml_builtin_exceptions = require("./caml_builtin_exceptions.js");
function caml_string_get(s, i) {
if (i >= s.length || i < 0) {
throw [
Caml_builtin_exceptions.invalid_argument,
"index out of bounds"
];
} else {
return s.charCodeAt(i);
}
}
function caml_string_get16(s, i) {
return s.charCodeAt(i) + (s.charCodeAt(i + 1 | 0) << 8) | 0;
}
function caml_string_get32(s, i) {
return ((s.charCodeAt(i) + (s.charCodeAt(i + 1 | 0) << 8) | 0) + (s.charCodeAt(i + 2 | 0) << 16) | 0) + (s.charCodeAt(i + 3 | 0) << 24) | 0;
}
function get(s, i) {
if (i < 0 || i >= s.length) {
throw [
Caml_builtin_exceptions.invalid_argument,
"index out of bounds"
];
} else {
return s.charCodeAt(i);
}
}
exports.caml_string_get = caml_string_get;
exports.caml_string_get16 = caml_string_get16;
exports.caml_string_get32 = caml_string_get32;
exports.get = get;
/* No side effect */