From 1ac99b8c930ef5274f4465eb6be1f79f2f7a86ef Mon Sep 17 00:00:00 2001 From: Ethan Arrowood Date: Thu, 7 May 2020 11:18:20 -0400 Subject: [PATCH 1/4] Add fs multiple constants example --- doc/api/fs.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/doc/api/fs.md b/doc/api/fs.md index ec8e49d5b12adc..d71b5057ede2d2 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -5367,6 +5367,20 @@ The following constants are exported by `fs.constants`. Not every constant will be available on every operating system. +To use more than one constant, use the bitwise OR `|` operator. + +Example: + +```js +const fs = require('fs') + +const flags = fs.constants.O_RDWR | fs.constants.O_CREAT | fs.constants.O_EXCL + +fs.open('', flags, (err, fd) => { + // ... +}) +``` + ### File Access Constants The following constants are meant for use with [`fs.access()`][]. From 6286df58c4ecb904cebef2bef248949c89f2d267 Mon Sep 17 00:00:00 2001 From: Ethan Arrowood Date: Thu, 7 May 2020 11:26:59 -0400 Subject: [PATCH 2/4] Fix linting errors --- doc/api/fs.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index d71b5057ede2d2..ba9ec7815f4b64 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -5372,13 +5372,13 @@ To use more than one constant, use the bitwise OR `|` operator. Example: ```js -const fs = require('fs') +const fs = require('fs'); -const flags = fs.constants.O_RDWR | fs.constants.O_CREAT | fs.constants.O_EXCL +const flags = fs.constants.O_RDWR | fs.constants.O_CREAT | fs.constants.O_EXCL; -fs.open('', flags, (err, fd) => { +fs.open('', flags, (err, fd) => { // ... -}) +}); ``` ### File Access Constants From 32feeb8980841cdaccce5b955faee60df4c35664 Mon Sep 17 00:00:00 2001 From: Ethan Arrowood Date: Thu, 7 May 2020 11:47:55 -0400 Subject: [PATCH 3/4] Update doc/api/fs.md Co-authored-by: James M Snell --- doc/api/fs.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index ba9ec7815f4b64..3b35841e45a29d 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -5374,9 +5374,13 @@ Example: ```js const fs = require('fs'); -const flags = fs.constants.O_RDWR | fs.constants.O_CREAT | fs.constants.O_EXCL; +const { + O_RDWR, + O_CREAT, + O_EXCL +} = fs.constants -fs.open('', flags, (err, fd) => { +fs.open('/path/to/my/file', O_RDWR | O_CREAT | O_EXCL, (err, fd) => { // ... }); ``` From 0eee10b0adbc5963d747cffc76514c119eba94d4 Mon Sep 17 00:00:00 2001 From: Ethan Arrowood Date: Thu, 7 May 2020 11:53:22 -0400 Subject: [PATCH 4/4] add missing semi --- doc/api/fs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index 3b35841e45a29d..32c3fcdba1d9ef 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -5378,7 +5378,7 @@ const { O_RDWR, O_CREAT, O_EXCL -} = fs.constants +} = fs.constants; fs.open('/path/to/my/file', O_RDWR | O_CREAT | O_EXCL, (err, fd) => { // ...