Skip to content

Commit a79dece

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/node-v0.x-archive#9313 PR: nodejs/node-v0.x-archive#9359 Reviewed-By: Julien Gilli <[email protected]> PORT-FROM: joyent/node @ 51fe319 PR-URL: #1770 Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]> Conflicts: doc/api/fs.markdown
1 parent 1cb72c1 commit a79dece

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

@@ -514,7 +522,7 @@ If `options` is a string, then it specifies the encoding. Example:
514522

515523
## fs.writeFileSync(filename, data[, options])
516524

517-
The synchronous version of `fs.writeFile`.
525+
The synchronous version of `fs.writeFile`. Returns `undefined`.
518526

519527
## fs.appendFile(filename, data[, options], callback)
520528

@@ -542,7 +550,7 @@ If `options` is a string, then it specifies the encoding. Example:
542550

543551
## fs.appendFileSync(filename, data[, options])
544552

545-
The synchronous version of `fs.appendFile`.
553+
The synchronous version of `fs.appendFile`. Returns `undefined`.
546554

547555
## fs.watchFile(filename[, options], listener)
548556

@@ -680,6 +688,7 @@ and handle the error when it's not there.
680688
## fs.existsSync(path)
681689

682690
Synchronous version of [`fs.exists`](fs.html#fs_fs_exists_path_callback).
691+
Returns `true` if the file exists, `false` otherwise.
683692

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

0 commit comments

Comments
 (0)