forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcaml_weak.js
45 lines (37 loc) · 992 Bytes
/
caml_weak.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
40
41
42
43
44
45
'use strict';
var Caml_obj = require("./caml_obj.js");
var Caml_array = require("./caml_array.js");
var Js_primitive = require("./js_primitive.js");
function caml_weak_create(n) {
return new Array(n);
}
function caml_weak_set(xs, i, v) {
if (v) {
xs[i] = v[0];
return /* () */0;
} else {
return /* () */0;
}
}
function caml_weak_get(xs, i) {
return Js_primitive.undefined_to_opt(xs[i]);
}
function caml_weak_get_copy(xs, i) {
var match = xs[i];
if (match !== undefined) {
return /* Some */[Caml_obj.caml_obj_dup(match)];
} else {
return /* None */0;
}
}
function caml_weak_check(xs, i) {
return xs[i] !== undefined;
}
var caml_weak_blit = Caml_array.caml_array_blit;
exports.caml_weak_create = caml_weak_create;
exports.caml_weak_set = caml_weak_set;
exports.caml_weak_get = caml_weak_get;
exports.caml_weak_get_copy = caml_weak_get_copy;
exports.caml_weak_check = caml_weak_check;
exports.caml_weak_blit = caml_weak_blit;
/* No side effect */