Skip to content

Commit e5c5b0d

Browse files
committed
Docs
1 parent eddb4e3 commit e5c5b0d

File tree

3 files changed

+221
-0
lines changed

3 files changed

+221
-0
lines changed

docs/Node/Platform.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
## Module Node.Platform
2+
3+
This module defines data type for the different platforms supported by
4+
Node.js
5+
6+
#### `Platform`
7+
8+
``` purescript
9+
data Platform
10+
= Darwin
11+
| FreeBSD
12+
| Linux
13+
| SunOS
14+
| Win32
15+
```
16+
17+
##### Instances
18+
``` purescript
19+
Show Platform
20+
Eq Platform
21+
Ord Platform
22+
```
23+
24+
#### `toString`
25+
26+
``` purescript
27+
toString :: Platform -> String
28+
```
29+
30+
The String representation for a platform, recognised by Node.js.
31+
32+
#### `fromString`
33+
34+
``` purescript
35+
fromString :: String -> Maybe Platform
36+
```
37+
38+

docs/Node/Process.md

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
## Module Node.Process
2+
3+
Bindings to the global `process` object in Node.js. See also [the Node API documentation](https://nodejs.org/api/process.html)
4+
5+
#### `PROCESS`
6+
7+
``` purescript
8+
data PROCESS :: !
9+
```
10+
11+
An effect tracking interaction with the global `process` object.
12+
13+
#### `onBeforeExit`
14+
15+
``` purescript
16+
onBeforeExit :: forall eff. Eff (process :: PROCESS | eff) Unit -> Eff (process :: PROCESS | eff) Unit
17+
```
18+
19+
Register a callback to be performed when the event loop empties, and
20+
Node.js is about to exit. Asynchronous calls can be made in the callback,
21+
and if any are made, it will cause the process to continue a little longer.
22+
23+
#### `onExit`
24+
25+
``` purescript
26+
onExit :: forall eff. (Int -> Eff (process :: PROCESS | eff) Unit) -> Eff (process :: PROCESS | eff) Unit
27+
```
28+
29+
Register a callback to be performed when the process is about to exit.
30+
Any work scheduled via asynchronous calls made here will not be performed
31+
in time.
32+
33+
The argument to the callback is the exit code which the process is about
34+
to exit with.
35+
36+
#### `onSignal`
37+
38+
``` purescript
39+
onSignal :: forall eff. String -> Eff (process :: PROCESS | eff) Unit -> Eff (process :: PROCESS | eff) Unit
40+
```
41+
42+
Install a handler for a particular signal.
43+
44+
#### `argv`
45+
46+
``` purescript
47+
argv :: forall eff. Eff (process :: PROCESS | eff) (Array String)
48+
```
49+
50+
Get an array containing the command line arguments. Be aware
51+
that this can change over the course of the program.
52+
53+
#### `execArgv`
54+
55+
``` purescript
56+
execArgv :: forall eff. Eff (process :: PROCESS | eff) (Array String)
57+
```
58+
59+
Node-specific options passed to the `node` executable. Be aware that
60+
this can change over the course of the program.
61+
62+
#### `execPath`
63+
64+
``` purescript
65+
execPath :: forall eff. Eff (process :: PROCESS | eff) String
66+
```
67+
68+
The absolute pathname of the `node` executable that started the
69+
process.
70+
71+
#### `chdir`
72+
73+
``` purescript
74+
chdir :: forall eff. String -> Eff (err :: EXCEPTION, process :: PROCESS | eff) Unit
75+
```
76+
77+
Change the current working directory of the process. If the current
78+
directory could not be changed, an exception will be thrown.
79+
80+
#### `cwd`
81+
82+
``` purescript
83+
cwd :: forall eff. Eff (process :: PROCESS | eff) String
84+
```
85+
86+
Get the current working directory of the process.
87+
88+
#### `getEnv`
89+
90+
``` purescript
91+
getEnv :: forall eff. Eff (process :: PROCESS | eff) (StrMap String)
92+
```
93+
94+
Get a copy of the current environment.
95+
96+
#### `lookupEnv`
97+
98+
``` purescript
99+
lookupEnv :: forall eff. String -> Eff (process :: PROCESS | eff) (Maybe String)
100+
```
101+
102+
Lookup a particular environment variable.
103+
104+
#### `setEnv`
105+
106+
``` purescript
107+
setEnv :: forall eff. String -> String -> Eff (process :: PROCESS | eff) Unit
108+
```
109+
110+
Set an environment variable.
111+
112+
#### `pid`
113+
114+
``` purescript
115+
pid :: Int
116+
```
117+
118+
#### `platform`
119+
120+
``` purescript
121+
platform :: Platform
122+
```
123+
124+
#### `exit`
125+
126+
``` purescript
127+
exit :: forall eff. Int -> Eff (process :: PROCESS | eff) Unit
128+
```
129+
130+
Cause the process to exit with the supplied integer code. An exit code
131+
of 0 is normally considered successful, and anything else is considered a
132+
failure.
133+
134+
#### `stdin`
135+
136+
``` purescript
137+
stdin :: forall eff. Readable () (console :: CONSOLE | eff)
138+
```
139+
140+
The standard input stream. Note that this stream will never emit an `end`
141+
event, so any handlers attached via `onEnd` will never be called.
142+
143+
#### `stdout`
144+
145+
``` purescript
146+
stdout :: forall eff. Writable () (console :: CONSOLE | eff)
147+
```
148+
149+
The standard output stream. Note that this stream cannot be closed; calling
150+
`end` will result in an exception being thrown.
151+
152+
#### `stderr`
153+
154+
``` purescript
155+
stderr :: forall eff. Writable () (console :: CONSOLE | eff)
156+
```
157+
158+
The standard error stream. Note that this stream cannot be closed; calling
159+
`end` will result in an exception being thrown.
160+
161+
#### `stdoutIsTTY`
162+
163+
``` purescript
164+
stdoutIsTTY :: Boolean
165+
```
166+
167+
Check whether the process is being run inside a TTY context
168+
169+
#### `version`
170+
171+
``` purescript
172+
version :: String
173+
```
174+
175+
Get the Node.js version.
176+
177+

src/Node/Process.purs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,18 @@ platform = fromJust (Platform.fromString process.platform)
111111
-- | failure.
112112
foreign import exit :: forall eff. Int -> Eff (process :: PROCESS | eff) Unit
113113

114+
-- | The standard input stream. Note that this stream will never emit an `end`
115+
-- | event, so any handlers attached via `onEnd` will never be called.
114116
stdin :: forall eff. Readable () (console :: CONSOLE | eff)
115117
stdin = process.stdin
116118

119+
-- | The standard output stream. Note that this stream cannot be closed; calling
120+
-- | `end` will result in an exception being thrown.
117121
stdout :: forall eff. Writable () (console :: CONSOLE | eff)
118122
stdout = process.stdout
119123

124+
-- | The standard error stream. Note that this stream cannot be closed; calling
125+
-- | `end` will result in an exception being thrown.
120126
stderr :: forall eff. Writable () (console :: CONSOLE | eff)
121127
stderr = process.stderr
122128

0 commit comments

Comments
 (0)