Skip to content

Commit 9dbc947

Browse files
tylerantonFishrock123
authored andcommitted
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 nodejs#9313 PR: nodejs#9359 PR-URL: nodejs/node-v0.x-archive#9359 Reviewed-By: Julien Gilli <[email protected]> Conflicts: doc/api/fs.markdown
1 parent 7532d24 commit 9dbc947

File tree

1 file changed

+30
-21
lines changed

1 file changed

+30
-21
lines changed

doc/api/fs.markdown

+30-21
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ to the completion callback.
9292

9393
## fs.renameSync(oldPath, newPath)
9494

95-
Synchronous rename(2).
95+
Synchronous rename(2). Returns `undefined`.
9696

9797
## fs.ftruncate(fd, len, callback)
9898

@@ -101,7 +101,7 @@ given to the completion callback.
101101

102102
## fs.ftruncateSync(fd, len)
103103

104-
Synchronous ftruncate(2).
104+
Synchronous ftruncate(2). Returns `undefined`.
105105

106106
## fs.truncate(path, len, callback)
107107

@@ -111,7 +111,7 @@ first argument. In this case, `fs.ftruncate()` is called.
111111

112112
## fs.truncateSync(path, len)
113113

114-
Synchronous truncate(2).
114+
Synchronous truncate(2). Returns `undefined`.
115115

116116
## fs.chown(path, uid, gid, callback)
117117

@@ -120,7 +120,7 @@ to the completion callback.
120120

121121
## fs.chownSync(path, uid, gid)
122122

123-
Synchronous chown(2).
123+
Synchronous chown(2). Returns `undefined`.
124124

125125
## fs.fchown(fd, uid, gid, callback)
126126

@@ -129,7 +129,7 @@ to the completion callback.
129129

130130
## fs.fchownSync(fd, uid, gid)
131131

132-
Synchronous fchown(2).
132+
Synchronous fchown(2). Returns `undefined`.
133133

134134
## fs.lchown(path, uid, gid, callback)
135135

@@ -138,7 +138,7 @@ to the completion callback.
138138

139139
## fs.lchownSync(path, uid, gid)
140140

141-
Synchronous lchown(2).
141+
Synchronous lchown(2). Returns `undefined`.
142142

143143
## fs.chmod(path, mode, callback)
144144

@@ -147,7 +147,7 @@ to the completion callback.
147147

148148
## fs.chmodSync(path, mode)
149149

150-
Synchronous chmod(2).
150+
Synchronous chmod(2). Returns `undefined`.
151151

152152
## fs.fchmod(fd, mode, callback)
153153

@@ -156,7 +156,7 @@ are given to the completion callback.
156156

157157
## fs.fchmodSync(fd, mode)
158158

159-
Synchronous fchmod(2).
159+
Synchronous fchmod(2). Returns `undefined`.
160160

161161
## fs.lchmod(path, mode, callback)
162162

@@ -167,7 +167,7 @@ Only available on Mac OS X.
167167

168168
## fs.lchmodSync(path, mode)
169169

170-
Synchronous lchmod(2).
170+
Synchronous lchmod(2). Returns `undefined`.
171171

172172
## fs.stat(path, callback)
173173

@@ -207,7 +207,7 @@ the completion callback.
207207

208208
## fs.linkSync(srcpath, dstpath)
209209

210-
Synchronous link(2).
210+
Synchronous link(2). Returns `undefined`.
211211

212212
## fs.symlink(destination, path[, type], callback)
213213

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

221221
## fs.symlinkSync(destination, path[, type])
222222

223-
Synchronous symlink(2).
223+
Synchronous symlink(2). Returns `undefined`.
224224

225225
## fs.readlink(path, callback)
226226

@@ -257,7 +257,7 @@ to the completion callback.
257257

258258
## fs.unlinkSync(path)
259259

260-
Synchronous unlink(2).
260+
Synchronous unlink(2). Returns `undefined`.
261261

262262
## fs.rmdir(path, callback)
263263

@@ -266,7 +266,7 @@ to the completion callback.
266266

267267
## fs.rmdirSync(path)
268268

269-
Synchronous rmdir(2).
269+
Synchronous rmdir(2). Returns `undefined`.
270270

271271
## fs.mkdir(path[, mode], callback)
272272

@@ -275,7 +275,7 @@ to the completion callback. `mode` defaults to `0o777`.
275275

276276
## fs.mkdirSync(path[, mode])
277277

278-
Synchronous mkdir(2).
278+
Synchronous mkdir(2). Returns `undefined`.
279279

280280
## fs.readdir(path, callback)
281281

@@ -295,7 +295,7 @@ to the completion callback.
295295

296296
## fs.closeSync(fd)
297297

298-
Synchronous close(2).
298+
Synchronous close(2). Returns `undefined`.
299299

300300
## fs.open(path, flags[, mode], callback)
301301

@@ -356,27 +356,35 @@ the end of the file.
356356

357357
## fs.openSync(path, flags[, mode])
358358

359-
Synchronous version of `fs.open()`.
359+
Synchronous version of `fs.open()`. Returns an integer representing the file
360+
descriptor.
360361

361362
## fs.utimes(path, atime, mtime, callback)
362-
## fs.utimesSync(path, atime, mtime)
363363

364364
Change file timestamps of the file referenced by the supplied path.
365365

366+
## fs.utimesSync(path, atime, mtime)
367+
368+
Synchronous version of `fs.utimes()`. Returns `undefined`.
369+
370+
366371
## fs.futimes(fd, atime, mtime, callback)
367-
## fs.futimesSync(fd, atime, mtime)
368372

369373
Change the file timestamps of a file referenced by the supplied file
370374
descriptor.
371375

376+
## fs.futimesSync(fd, atime, mtime)
377+
378+
Synchronous version of `fs.futimes()`. Returns `undefined`.
379+
372380
## fs.fsync(fd, callback)
373381

374382
Asynchronous fsync(2). No arguments other than a possible exception are given
375383
to the completion callback.
376384

377385
## fs.fsyncSync(fd)
378386

379-
Synchronous fsync(2).
387+
Synchronous fsync(2). Returns `undefined`.
380388

381389
## fs.write(fd, buffer, offset, length[, position], callback)
382390

@@ -506,7 +514,7 @@ Example:
506514

507515
## fs.writeFileSync(filename, data[, options])
508516

509-
The synchronous version of `fs.writeFile`.
517+
The synchronous version of `fs.writeFile`. Returns `undefined`.
510518

511519
## fs.appendFile(filename, data[, options], callback)
512520

@@ -530,7 +538,7 @@ Example:
530538

531539
## fs.appendFileSync(filename, data[, options])
532540

533-
The synchronous version of `fs.appendFile`.
541+
The synchronous version of `fs.appendFile`. Returns `undefined`.
534542

535543
## fs.watchFile(filename[, options], listener)
536544

@@ -666,6 +674,7 @@ and handle the error when it's not there.
666674
## fs.existsSync(path)
667675

668676
Synchronous version of [`fs.exists`](fs.html#fs_fs_exists_path_callback).
677+
Returns `true` if the file exists, `false` otherwise.
669678

670679
`fs.existsSync()` is **deprecated**. For supported alternatives please check
671680
out [`fs.statSync`](fs.html#fs_fs_statsync_path) or

0 commit comments

Comments
 (0)