package alba

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file process.ml

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
open Js_of_ocaml
open Js


class type process =
  object
    method argv: (js_string t) js_array t readonly_prop
    method cwd: js_string t meth
    method exit: int -> 'a meth
    method nextTick: (unit -> unit) callback -> unit meth
  end

let process: process t = Unsafe.eval_string "require('process')"

let next_tick (k:unit -> unit): unit =
  process##nextTick
    (wrap_callback k)

let exit (code:int): 'a  =
  Printf.printf "exiting with code %d\n" code;
  process##exit code

let command_line: string array =
  let arr = to_array process##.argv in
  let len = Array.length arr in
  assert (0 < len);
  Array.map to_string (Array.sub arr 1 (len - 1))

let current_working_directory (_:unit): string =
  to_string process##cwd
OCaml

Innovation. Community. Security.