forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcaml_io.js
137 lines (122 loc) · 3.49 KB
/
caml_io.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.3 , PLEASE EDIT WITH CARE
'use strict';
var Caml_builtin_exceptions = require("./caml_builtin_exceptions");
var Curry = require("./curry");
function $caret(prim, prim$1) {
return prim + prim$1;
}
var stdin = undefined;
var stdout = /* record */[
/* buffer */"",
/* output */function (_, s) {
var v = s.length - 1 | 0;
if (( (typeof process !== "undefined") && process.stdout && process.stdout.write)) {
return ( process.stdout.write )(s);
}
else if (s[v] === "\n") {
console.log(s.slice(0, v));
return /* () */0;
}
else {
console.log(s);
return /* () */0;
}
}
];
var stderr = /* record */[
/* buffer */"",
/* output */function (_, s) {
var v = s.length - 1 | 0;
if (s[v] === "\n") {
console.log(s.slice(0, v));
return /* () */0;
}
else {
console.log(s);
return /* () */0;
}
}
];
function caml_ml_open_descriptor_in() {
throw [
Caml_builtin_exceptions.failure,
"caml_ml_open_descriptor_in not implemented"
];
}
function caml_ml_open_descriptor_out() {
throw [
Caml_builtin_exceptions.failure,
"caml_ml_open_descriptor_out not implemented"
];
}
function caml_ml_flush(oc) {
if (oc[/* buffer */0] !== "") {
Curry._2(oc[/* output */1], oc, oc[/* buffer */0]);
oc[/* buffer */0] = "";
return /* () */0;
}
else {
return 0;
}
}
var node_std_output = (function (s){
return (typeof process !== "undefined") && process.stdout && (process.stdout.write(s), true);
}
);
function caml_ml_output(oc, str, offset, len) {
var str$1 = offset === 0 && len === str.length ? str : str.slice(offset, len);
if (( (typeof process !== "undefined") && process.stdout && process.stdout.write ) && oc === stdout) {
return ( process.stdout.write )(str$1);
}
else {
var id = str$1.lastIndexOf("\n");
if (id < 0) {
oc[/* buffer */0] = oc[/* buffer */0] + str$1;
return /* () */0;
}
else {
oc[/* buffer */0] = oc[/* buffer */0] + str$1.slice(0, id + 1 | 0);
caml_ml_flush(oc);
oc[/* buffer */0] = oc[/* buffer */0] + str$1.slice(id + 1 | 0);
return /* () */0;
}
}
}
function caml_ml_output_char(oc, $$char) {
return caml_ml_output(oc, String.fromCharCode($$char), 0, 1);
}
function caml_ml_input(_, _$1, _$2, _$3) {
throw [
Caml_builtin_exceptions.failure,
"caml_ml_input ic not implemented"
];
}
function caml_ml_input_char() {
throw [
Caml_builtin_exceptions.failure,
"caml_ml_input_char not implemnted"
];
}
function caml_ml_out_channels_list() {
return /* :: */[
stdout,
/* :: */[
stderr,
/* [] */0
]
];
}
exports.$caret = $caret;
exports.stdin = stdin;
exports.stdout = stdout;
exports.stderr = stderr;
exports.caml_ml_open_descriptor_in = caml_ml_open_descriptor_in;
exports.caml_ml_open_descriptor_out = caml_ml_open_descriptor_out;
exports.caml_ml_flush = caml_ml_flush;
exports.node_std_output = node_std_output;
exports.caml_ml_output = caml_ml_output;
exports.caml_ml_output_char = caml_ml_output_char;
exports.caml_ml_input = caml_ml_input;
exports.caml_ml_input_char = caml_ml_input_char;
exports.caml_ml_out_channels_list = caml_ml_out_channels_list;
/* stdin Not a pure module */