Skip to content

Commit 9572701

Browse files
Ethan-Arrowoodcodebytere
authored andcommittedJun 9, 2020
doc: add fs.open() multiple constants example
PR-URL: #33281 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent 7d8a226 commit 9572701

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
 

‎doc/api/fs.md

+18
Original file line numberDiff line numberDiff line change
@@ -5321,6 +5321,24 @@ The following constants are exported by `fs.constants`.
53215321

53225322
Not every constant will be available on every operating system.
53235323

5324+
To use more than one constant, use the bitwise OR `|` operator.
5325+
5326+
Example:
5327+
5328+
```js
5329+
const fs = require('fs');
5330+
5331+
const {
5332+
O_RDWR,
5333+
O_CREAT,
5334+
O_EXCL
5335+
} = fs.constants;
5336+
5337+
fs.open('/path/to/my/file', O_RDWR | O_CREAT | O_EXCL, (err, fd) => {
5338+
// ...
5339+
});
5340+
```
5341+
53245342
### File Access Constants
53255343

53265344
The following constants are meant for use with [`fs.access()`][].

0 commit comments

Comments
 (0)
Please sign in to comment.