Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

Commit 51fe319

Browse files
tylerantonJulien Gilli
authored and
Julien Gilli
committed
docs: add return value for sync fs functions
Clarify that synchronous functions in fs with no return value return undefined. Specify that fs.openSync() returns an integer and fs.existsSync() returns true or false. Fixes #9313 PR: #9359 PR-URL: #9359 Reviewed-By: Julien Gilli <[email protected]>
1 parent a5be84f commit 51fe319

File tree

1 file changed

+31
-22
lines changed

1 file changed

+31
-22
lines changed

doc/api/fs.markdown

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ to the completion callback.
7777

7878
## fs.renameSync(oldPath, newPath)
7979

80-
Synchronous rename(2).
80+
Synchronous rename(2). Returns `undefined`.
8181

8282
## fs.ftruncate(fd, len, callback)
8383

@@ -86,7 +86,7 @@ given to the completion callback.
8686

8787
## fs.ftruncateSync(fd, len)
8888

89-
Synchronous ftruncate(2).
89+
Synchronous ftruncate(2). Returns `undefined`.
9090

9191
## fs.truncate(path, len, callback)
9292

@@ -95,7 +95,7 @@ given to the completion callback.
9595

9696
## fs.truncateSync(path, len)
9797

98-
Synchronous truncate(2).
98+
Synchronous truncate(2). Returns `undefined`.
9999

100100
## fs.chown(path, uid, gid, callback)
101101

@@ -104,7 +104,7 @@ to the completion callback.
104104

105105
## fs.chownSync(path, uid, gid)
106106

107-
Synchronous chown(2).
107+
Synchronous chown(2). Returns `undefined`.
108108

109109
## fs.fchown(fd, uid, gid, callback)
110110

@@ -113,7 +113,7 @@ to the completion callback.
113113

114114
## fs.fchownSync(fd, uid, gid)
115115

116-
Synchronous fchown(2).
116+
Synchronous fchown(2). Returns `undefined`.
117117

118118
## fs.lchown(path, uid, gid, callback)
119119

@@ -122,7 +122,7 @@ to the completion callback.
122122

123123
## fs.lchownSync(path, uid, gid)
124124

125-
Synchronous lchown(2).
125+
Synchronous lchown(2). Returns `undefined`.
126126

127127
## fs.chmod(path, mode, callback)
128128

@@ -131,7 +131,7 @@ to the completion callback.
131131

132132
## fs.chmodSync(path, mode)
133133

134-
Synchronous chmod(2).
134+
Synchronous chmod(2). Returns `undefined`.
135135

136136
## fs.fchmod(fd, mode, callback)
137137

@@ -140,7 +140,7 @@ are given to the completion callback.
140140

141141
## fs.fchmodSync(fd, mode)
142142

143-
Synchronous fchmod(2).
143+
Synchronous fchmod(2). Returns `undefined`.
144144

145145
## fs.lchmod(path, mode, callback)
146146

@@ -151,7 +151,7 @@ Only available on Mac OS X.
151151

152152
## fs.lchmodSync(path, mode)
153153

154-
Synchronous lchmod(2).
154+
Synchronous lchmod(2). Returns `undefined`.
155155

156156
## fs.stat(path, callback)
157157

@@ -191,7 +191,7 @@ the completion callback.
191191

192192
## fs.linkSync(srcpath, dstpath)
193193

194-
Synchronous link(2).
194+
Synchronous link(2). Returns `undefined`.
195195

196196
## fs.symlink(srcpath, dstpath, [type], callback)
197197

@@ -204,7 +204,7 @@ Note that Windows junction points require the destination path to be absolute.
204204

205205
## fs.symlinkSync(srcpath, dstpath, [type])
206206

207-
Synchronous symlink(2).
207+
Synchronous symlink(2). Returns `undefined`.
208208

209209
## fs.readlink(path, callback)
210210

@@ -241,7 +241,7 @@ to the completion callback.
241241

242242
## fs.unlinkSync(path)
243243

244-
Synchronous unlink(2).
244+
Synchronous unlink(2). Returns `undefined`.
245245

246246
## fs.rmdir(path, callback)
247247

@@ -250,7 +250,7 @@ to the completion callback.
250250

251251
## fs.rmdirSync(path)
252252

253-
Synchronous rmdir(2).
253+
Synchronous rmdir(2). Returns `undefined`.
254254

255255
## fs.mkdir(path, [mode], callback)
256256

@@ -259,7 +259,7 @@ to the completion callback. `mode` defaults to `0777`.
259259

260260
## fs.mkdirSync(path, [mode])
261261

262-
Synchronous mkdir(2).
262+
Synchronous mkdir(2). Returns `undefined`.
263263

264264
## fs.readdir(path, callback)
265265

@@ -279,7 +279,7 @@ to the completion callback.
279279

280280
## fs.closeSync(fd)
281281

282-
Synchronous close(2).
282+
Synchronous close(2). Returns `undefined`.
283283

284284
## fs.open(path, flags, [mode], callback)
285285

@@ -340,27 +340,35 @@ the end of the file.
340340

341341
## fs.openSync(path, flags, [mode])
342342

343-
Synchronous version of `fs.open()`.
343+
Synchronous version of `fs.open()`. Returns an integer representing the file
344+
descriptor.
344345

345346
## fs.utimes(path, atime, mtime, callback)
346-
## fs.utimesSync(path, atime, mtime)
347347

348348
Change file timestamps of the file referenced by the supplied path.
349349

350+
## fs.utimesSync(path, atime, mtime)
351+
352+
Synchronous version of `fs.utimes()`. Returns `undefined`.
353+
354+
350355
## fs.futimes(fd, atime, mtime, callback)
351-
## fs.futimesSync(fd, atime, mtime)
352356

353357
Change the file timestamps of a file referenced by the supplied file
354358
descriptor.
355359

360+
## fs.futimesSync(fd, atime, mtime)
361+
362+
Synchronous version of `fs.futimes()`. Returns `undefined`.
363+
356364
## fs.fsync(fd, callback)
357365

358366
Asynchronous fsync(2). No arguments other than a possible exception are given
359367
to the completion callback.
360368

361369
## fs.fsyncSync(fd)
362370

363-
Synchronous fsync(2).
371+
Synchronous fsync(2). Returns `undefined`.
364372

365373
## fs.write(fd, buffer, offset, length, position, callback)
366374

@@ -461,7 +469,7 @@ Example:
461469

462470
## fs.writeFileSync(filename, data, [options])
463471

464-
The synchronous version of `fs.writeFile`.
472+
The synchronous version of `fs.writeFile`. Returns `undefined`.
465473

466474
## fs.appendFile(filename, data, [options], callback)
467475

@@ -485,7 +493,7 @@ Example:
485493

486494
## fs.appendFileSync(filename, data, [options])
487495

488-
The synchronous version of `fs.appendFile`.
496+
The synchronous version of `fs.appendFile`. Returns `undefined`.
489497

490498
## fs.watchFile(filename, [options], listener)
491499

@@ -605,7 +613,8 @@ and handle the error when it's not there.
605613

606614
## fs.existsSync(path)
607615

608-
Synchronous version of `fs.exists`.
616+
Synchronous version of `fs.exists()`. Returns `true` if the file exists,
617+
`false` otherwise.
609618

610619
## Class: fs.Stats
611620

0 commit comments

Comments
 (0)