forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJs.html
396 lines (306 loc) · 20 KB
/
Js.html
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="../api_static/tomorrow-night.css">
<link rel="stylesheet" href="../api_static/style.css" type="text/css">
<script src="../api_static//highlight.pack.js"></script>
<script src="../api_static//script.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<meta charset="utf8">
<link rel="previous" href="Dom.html"><link rel="next" href="Js_array.html">
<title> Js </title></head>
<body>
<nav class="module-index"><ul><li><a href="Bs.html">Bs</a></li>
<li><a href="Bs_dyn.html">Bs_dyn</a></li>
<li><a href="Bs_dyn_lib.html">Bs_dyn_lib</a></li>
<li><a href="Dom.html">Dom</a></li>
<li><a href="Js.html">Js</a></li>
<li><a href="Js_array.html">Js_array</a></li>
<li><a href="Js_boolean.html">Js_boolean</a></li>
<li><a href="Js_cast.html">Js_cast</a></li>
<li><a href="Js_date.html">Js_date</a></li>
<li><a href="Js_dict.html">Js_dict</a></li>
<li><a href="Js_exn.html">Js_exn</a></li>
<li><a href="Js_float.html">Js_float</a></li>
<li><a href="Js_global.html">Js_global</a></li>
<li><a href="Js_int.html">Js_int</a></li>
<li><a href="Js_int64.html">Js_int64</a></li>
<li><a href="Js_json.html">Js_json</a></li>
<li><a href="Js_list.html">Js_list</a></li>
<li><a href="Js_math.html">Js_math</a></li>
<li><a href="Js_nativeint.html">Js_nativeint</a></li>
<li><a href="Js_null.html">Js_null</a></li>
<li><a href="Js_null_undefined.html">Js_null_undefined</a></li>
<li><a href="Js_obj.html">Js_obj</a></li>
<li><a href="Js_option.html">Js_option</a></li>
<li><a href="Js_primitive.html">Js_primitive</a></li>
<li><a href="Js_promise.html">Js_promise</a></li>
<li><a href="Js_re.html">Js_re</a></li>
<li><a href="Js_result.html">Js_result</a></li>
<li><a href="Js_string.html">Js_string</a></li>
<li><a href="Js_typed_array.html">Js_typed_array</a></li>
<li><a href="Js_types.html">Js_types</a></li>
<li><a href="Js_undefined.html">Js_undefined</a></li>
<li><a href="Js_unsafe.html">Js_unsafe</a></li>
<li><a href="Js_vector.html">Js_vector</a></li>
<li><a href="Node.html">Node</a></li>
<li><a href="Node_buffer.html">Node_buffer</a></li>
<li><a href="Node_child_process.html">Node_child_process</a></li>
<li><a href="Node_fs.html">Node_fs</a></li>
<li><a href="Node_module.html">Node_module</a></li>
<li><a href="Node_path.html">Node_path</a></li>
<li><a href="Node_process.html">Node_process</a></li></ul></nav>
<div class="navbar"><a class="pre" href="Dom.html" title="Dom">Previous</a>
<a class="up" href="index.html" title="Index">Up</a>
<a class="post" href="Js_array.html" title="Js_array">Next</a>
</div>
<h1>Module <a href="type_Js.html">Js</a></h1>
<pre><span class="keyword">module</span> Js: <code class="code">sig</code> <a href="Js.html">..</a> <code class="code">end</code></pre><div class="info module top">
<div class="not-examples">
This library provides bindings and necessary support for JS FFI.
It contains all bindings into <code class="code">Js</code> namespace.<br>
</div>
<div class="examples">
<pre class="example"> <pre class="codepre"><code class="code"> [| 1;2;3;4|]
|> Js.Array.map (fun x -> x + 1 )
|> Js.Array.reduce (+) 0
|> Js.log
</code></pre> </pre>
</div>
</div>
<hr width="100%">
<div class="type-declaration">
<pre><span id="TYPEt"><span class="keyword">type</span> <code class="type">+'a</code> t</span> </pre>
</div>
<div class="info ">
<div class="not-examples">
Js object type.<br>
</div>
<div class="examples">
<pre class="example"> <pre class="codepre"><code class="code"> let x : < x : int ; y : int > Js.t =
[%obj{ x = 1 ; y = 2}]
</code></pre> </pre>
</div>
</div>
<div class="type-declaration">
<pre><span id="TYPEnull"><span class="keyword">type</span> <code class="type">+'a</code> null</span> </pre>
</div>
<div class="info ">
<div class="not-examples">
nullable, value of this type can be either <code class="code">null</code> or <code class="code">'a</code>
this type is the same as type <code class="code">t</code> in <a href="Js.Null.html"><code class="code">Js.Null</code></a><br>
</div>
</div>
<div class="type-declaration">
<pre><span id="TYPEundefined"><span class="keyword">type</span> <code class="type">+'a</code> undefined</span> </pre>
</div>
<div class="info ">
<div class="not-examples">
value of this type can be either <code class="code">undefined</code> or <code class="code">'a</code>
this type is the same as type <code class="code">t</code> in <a href="Js.Undefined.html"><code class="code">Js.Undefined</code></a><br>
</div>
</div>
<div class="type-declaration">
<pre><span id="TYPEnull_undefined"><span class="keyword">type</span> <code class="type">+'a</code> null_undefined</span> </pre>
</div>
<div class="info ">
<div class="not-examples">
value of this type can be <code class="code">undefined</code>, <code class="code">null</code> or <code class="code">'a</code>
this type is the same as type <code class="code">t</code> n <a href="Js.Null_undefined.html"><code class="code">Js.Null_undefined</code></a><br>
</div>
</div>
<div class="type-declaration">
<pre><span id="TYPEboolean"><span class="keyword">type</span> <code class="type"></code>boolean</span> </pre>
</div>
<div class="info ">
<div class="not-examples">
The value could be either <a href="Js.html#VALtrue_"><code class="code">Js.true_</code></a> or <a href="Js.html#VALfalse_"><code class="code">Js.false_</code></a>.
Note in BuckleScript, <code class="code">boolean</code> has different representation from OCaml's <code class="code">bool</code>,
see conversion functions in <a href="Js.Boolean.html"><code class="code">Js.Boolean</code></a><br>
</div>
</div>
<div class="type-declaration">
<pre><span id="TYPEpromise"><span class="keyword">type</span> <code class="type">(+'a, +'e)</code> promise</span> </pre>
</div>
<div class="info ">
<div class="not-examples">
<div class="warning">
<span class="label">Deprecated.</span>
please use <a href="Js.Promise.html"><code class="code">Js.Promise</code></a>
</div>
The promise type, defined here for interoperation across packages<br>
</div>
</div>
<pre><span id="VALtrue_"><span class="keyword">val</span> true_</span> : <code class="type"><a href="Js.html#TYPEboolean">boolean</a></code></pre>
<pre><span id="VALfalse_"><span class="keyword">val</span> false_</span> : <code class="type"><a href="Js.html#TYPEboolean">boolean</a></code></pre>
<pre><span id="VALnull"><span class="keyword">val</span> null</span> : <code class="type">'a <a href="Js.html#TYPEnull">null</a></code></pre><div class="info ">
<div class="not-examples">
The same as <code class="code">empty</code> in <a href="Js.Null.html"><code class="code">Js.Null</code></a> will be compiled as <code class="code">null</code><br>
</div>
</div>
<pre><span id="VALundefined"><span class="keyword">val</span> undefined</span> : <code class="type">'a <a href="Js.html#TYPEundefined">undefined</a></code></pre><div class="info ">
<div class="not-examples">
The same as <code class="code">empty</code> <a href="Js.Undefined.html"><code class="code">Js.Undefined</code></a> will be compiled as <code class="code">undefined</code><br>
</div>
</div>
<pre><span id="VALto_bool"><span class="keyword">val</span> to_bool</span> : <code class="type"><a href="Js.html#TYPEboolean">boolean</a> -> bool</code></pre><div class="info ">
<div class="not-examples">
convert Js boolean to OCaml bool<br>
</div>
</div>
<pre><span id="VALtypeof"><span class="keyword">val</span> typeof</span> : <code class="type">'a -> string</code></pre><div class="info ">
<div class="not-examples">
<code class="code">typeof x</code> will be compiled as <code class="code">typeof x</code> in JS
Please consider functions in <a href="Js.Types.html"><code class="code">Js.Types</code></a> for a type safe way of reflection<br>
</div>
</div>
<pre><span id="VALlog"><span class="keyword">val</span> log</span> : <code class="type">'a -> unit</code></pre><div class="info ">
<div class="not-examples">
<code class="code">typeof x</code> will be compiled as <code class="code">typeof x</code> in JS<br>
</div>
</div>
<pre><span id="VALlog2"><span class="keyword">val</span> log2</span> : <code class="type">'a -> 'b -> unit</code></pre>
<pre><span id="VALlog3"><span class="keyword">val</span> log3</span> : <code class="type">'a -> 'b -> 'c -> unit</code></pre><div class="info ">
<div class="not-examples">
A convenience function to log everything<br>
</div>
</div>
<pre><span id="VALunsafe_lt"><span class="keyword">val</span> unsafe_lt</span> : <code class="type">'a -> 'a -> bool</code></pre><div class="info ">
<div class="not-examples">
<code class="code">unsafe_lt a b</code> will be compiled as <code class="code">a < b</code>.
It is marked as unsafe, since it is impossible
to give a proper semantics for comparision which applies to any type<br>
</div>
</div>
<pre><span id="VALunsafe_le"><span class="keyword">val</span> unsafe_le</span> : <code class="type">'a -> 'a -> bool</code></pre><div class="info ">
<div class="not-examples">
<code class="code">unsafe_le a b</code> will be compiled as <code class="code">a <= b</code>.
See also <a href="Js.html#VALunsafe_lt"><code class="code">Js.unsafe_lt</code></a><br>
</div>
</div>
<pre><span id="VALunsafe_gt"><span class="keyword">val</span> unsafe_gt</span> : <code class="type">'a -> 'a -> bool</code></pre><div class="info ">
<div class="not-examples">
<code class="code">unsafe_gt a b</code> will be compiled as <code class="code">a > b</code>.
See also <a href="Js.html#VALunsafe_lt"><code class="code">Js.unsafe_lt</code></a><br>
</div>
</div>
<pre><span id="VALunsafe_ge"><span class="keyword">val</span> unsafe_ge</span> : <code class="type">'a -> 'a -> bool</code></pre><div class="info ">
<div class="not-examples">
<code class="code">unsafe_ge a b</code> will be compiled as <code class="code">a >= b</code>.
See also <a href="Js.html#VALunsafe_lt"><code class="code">Js.unsafe_lt</code></a><br>
</div>
</div>
<pre><span class="keyword">module</span> <a href="Js.Null.html">Null</a>: <code class="type"><a href="Js_null.html">Js_null</a></code></pre> <div class="info">
<div class="not-examples">
Provide utilities arond <code class="code">'a null</code><br>
</div>
</div>
<pre><span class="keyword">module</span> <a href="Js.Undefined.html">Undefined</a>: <code class="type"><a href="Js_undefined.html">Js_undefined</a></code></pre> <div class="info">
<div class="not-examples">
Provide utilities around <a href="Js.html#VALundefined"><code class="code">Js.undefined</code></a><br>
</div>
</div>
<pre><span class="keyword">module</span> <a href="Js.Null_undefined.html">Null_undefined</a>: <code class="type"><a href="Js_null_undefined.html">Js_null_undefined</a></code></pre> <div class="info">
<div class="not-examples">
Provide utilities arond <a href="Js.html#TYPEnull_undefined"><code class="code">Js.null_undefined</code></a><br>
</div>
</div>
<pre><span class="keyword">module</span> <a href="Js.Exn.html">Exn</a>: <code class="type"><a href="Js_exn.html">Js_exn</a></code></pre> <div class="info">
<div class="not-examples">
Provide utilities for dealing with Js exceptions<br>
</div>
</div>
<pre><span class="keyword">module</span> <a href="Js.Array.html">Array</a>: <code class="type"><a href="Js_array.html">Js_array</a></code></pre> <div class="info">
<div class="not-examples">
Provide bindings to Js array<br>
</div>
</div>
<pre><span class="keyword">module</span> <a href="Js.String.html">String</a>: <code class="type"><a href="Js_string.html">Js_string</a></code></pre> <div class="info">
<div class="not-examples">
Provide bindings to JS string<br>
</div>
</div>
<pre><span class="keyword">module</span> <a href="Js.Boolean.html">Boolean</a>: <code class="type"><a href="Js_boolean.html">Js_boolean</a></code></pre> <div class="info">
<div class="not-examples">
Provide utilties for <a href="Js.html#TYPEboolean"><code class="code">Js.boolean</code></a><br>
</div>
</div>
<pre><span class="keyword">module</span> <a href="Js.Re.html">Re</a>: <code class="type"><a href="Js_re.html">Js_re</a></code></pre> <div class="info">
<div class="not-examples">
Provide bindings to Js regex expression<br>
</div>
</div>
<pre><span class="keyword">module</span> <a href="Js.Promise.html">Promise</a>: <code class="type"><a href="Js_promise.html">Js_promise</a></code></pre> <div class="info">
<div class="not-examples">
Provide bindings to JS promise<br>
</div>
</div>
<pre><span class="keyword">module</span> <a href="Js.Date.html">Date</a>: <code class="type"><a href="Js_date.html">Js_date</a></code></pre> <div class="info">
<div class="not-examples">
Provide bindings for JS Date<br>
</div>
</div>
<pre><span class="keyword">module</span> <a href="Js.Dict.html">Dict</a>: <code class="type"><a href="Js_dict.html">Js_dict</a></code></pre> <div class="info">
<div class="not-examples">
Provide utilities for JS dictionary object<br>
</div>
</div>
<pre><span class="keyword">module</span> <a href="Js.Global.html">Global</a>: <code class="type"><a href="Js_global.html">Js_global</a></code></pre> <div class="info">
<div class="not-examples">
Provide bindings to JS global functions in global namespace<br>
</div>
</div>
<pre><span class="keyword">module</span> <a href="Js.Json.html">Json</a>: <code class="type"><a href="Js_json.html">Js_json</a></code></pre> <div class="info">
<div class="not-examples">
Provide utilities for json<br>
</div>
</div>
<pre><span class="keyword">module</span> <a href="Js.Math.html">Math</a>: <code class="type"><a href="Js_math.html">Js_math</a></code></pre> <div class="info">
<div class="not-examples">
Provide bindings for JS <code class="code">Math</code> object<br>
</div>
</div>
<pre><span class="keyword">module</span> <a href="Js.Obj.html">Obj</a>: <code class="type"><a href="Js_obj.html">Js_obj</a></code></pre> <div class="info">
<div class="not-examples">
Provide utilities for <a href="Js.html#TYPEt"><code class="code">Js.t</code></a><br>
</div>
</div>
<pre><span class="keyword">module</span> <a href="Js.Typed_array.html">Typed_array</a>: <code class="type"><a href="Js_typed_array.html">Js_typed_array</a></code></pre> <div class="info">
<div class="not-examples">
Provide bindings for JS typed array<br>
</div>
</div>
<pre><span class="keyword">module</span> <a href="Js.Types.html">Types</a>: <code class="type"><a href="Js_types.html">Js_types</a></code></pre> <div class="info">
<div class="not-examples">
Provide utilities for maninpulatig JS types<br>
</div>
</div>
<pre><span class="keyword">module</span> <a href="Js.Float.html">Float</a>: <code class="type"><a href="Js_float.html">Js_float</a></code></pre> <div class="info">
<div class="not-examples">
Provide utilities for JS float<br>
</div>
</div>
<pre><span class="keyword">module</span> <a href="Js.Int.html">Int</a>: <code class="type"><a href="Js_int.html">Js_int</a></code></pre> <div class="info">
<div class="not-examples">
Provide utilities for int<br>
</div>
</div>
<pre><span class="keyword">module</span> <a href="Js.Option.html">Option</a>: <code class="type"><a href="Js_option.html">Js_option</a></code></pre> <div class="info">
<div class="not-examples">
Provide utilities for option<br>
</div>
</div>
<pre><span class="keyword">module</span> <a href="Js.Result.html">Result</a>: <code class="type"><a href="Js_result.html">Js_result</a></code></pre> <div class="info">
<div class="not-examples">
definie the interface for result<br>
</div>
</div>
<pre><span class="keyword">module</span> <a href="Js.List.html">List</a>: <code class="type"><a href="Js_list.html">Js_list</a></code></pre> <div class="info">
<div class="not-examples">
Provide utilties for list<br>
</div>
</div>
<pre><span class="keyword">module</span> <a href="Js.Vector.html">Vector</a>: <code class="type"><a href="Js_vector.html">Js_vector</a></code></pre> <div class="info">
<div class="not-examples">
</div>
</div> </body></html>