| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e8355c4 commit b2c533e
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,24 +14,20 @@ way modeled on standard POSIX functions. | |||
| 14 | 14 | To use the promise-based APIs: | |
| 15 | 15 | ||
| 16 | 16 | ```mjs | |
| 17 | - // Using ESM Module syntax: | ||
| 18 | 17 | import * as fs from 'fs/promises'; | |
| 19 | 18 | ``` | |
| 20 | 19 | ||
| 21 | 20 | ```cjs | |
| 22 | - // Using CommonJS syntax: | ||
| 23 | 21 | const fs = require('fs/promises'); | |
| 24 | 22 | ``` | |
| 25 | 23 | ||
| 26 | 24 | To use the callback and sync APIs: | |
| 27 | 25 | ||
| 28 | 26 | ```mjs | |
| 29 | - // Using ESM Module syntax: | ||
| 30 | 27 | import * as fs from 'fs'; | |
| 31 | 28 | ``` | |
| 32 | 29 | ||
| 33 | 30 | ```cjs | |
| 34 | - // Using CommonJS syntax: | ||
| 35 | 31 | const fs = require('fs'); | |
| 36 | 32 | ``` | |
| 37 | 33 | ||
@@ -44,7 +40,6 @@ Promise-based operations return a promise that is fulfilled when the | |||
| 44 | 40 | asynchronous operation is complete. | |
| 45 | 41 | ||
| 46 | 42 | ```mjs | |
| 47 | - // Using ESM Module syntax: | ||
| 48 | 43 | import { unlink } from 'fs/promises'; | |
| 49 | 44 | ||
| 50 | 45 | try { | |
@@ -56,7 +51,6 @@ try { | |||
| 56 | 51 | ``` | |
| 57 | 52 | ||
| 58 | 53 | ```cjs | |
| 59 | - // Using CommonJS syntax | ||
| 60 | 54 | const { unlink } = require('fs/promises'); | |
| 61 | 55 | ||
| 62 | 56 | (async function(path) { | |
@@ -78,7 +72,6 @@ reserved for an exception. If the operation is completed successfully, then | |||
| 78 | 72 | the first argument is `null` or `undefined`. | |
| 79 | 73 | ||
| 80 | 74 | ```mjs | |
| 81 | - // Using ESM syntax | ||
| 82 | 75 | import { unlink } from 'fs'; | |
| 83 | 76 | ||
| 84 | 77 | unlink('/tmp/hello', (err) => { | |
@@ -88,7 +81,6 @@ unlink('/tmp/hello', (err) => { | |||
| 88 | 81 | ``` | |
| 89 | 82 | ||
| 90 | 83 | ```cjs | |
| 91 | - // Using CommonJS syntax | ||
| 92 | 84 | const { unlink } = require('fs'); | |
| 93 | 85 | ||
| 94 | 86 | unlink('/tmp/hello', (err) => { | |
@@ -108,7 +100,6 @@ execution until the operation is complete. Exceptions are thrown immediately | |||
| 108 | 100 | and can be handled using `try…catch`, or can be allowed to bubble up. | |
| 109 | 101 | ||
| 110 | 102 | ```mjs | |
| 111 | - // Using ESM syntax | ||
| 112 | 103 | import { unlinkSync } from 'fs'; | |
| 113 | 104 | ||
| 114 | 105 | try { | |
@@ -120,7 +111,6 @@ try { | |||
| 120 | 111 | ``` | |
| 121 | 112 | ||
| 122 | 113 | ```cjs | |
| 123 | - // Using CommonJS syntax | ||
| 124 | 114 | const { unlinkSync } = require('fs'); | |
| 125 | 115 | ||
| 126 | 116 | try { | |
@@ -6258,7 +6248,6 @@ It is important to correctly order the operations by awaiting the results | |||
| 6258 | 6248 | of one before invoking the other: | |
| 6259 | 6249 | ||
| 6260 | 6250 | ```mjs | |
| 6261 | - // Using ESM syntax | ||
| 6262 | 6251 | import { rename, stat } from 'fs/promises'; | |
| 6263 | 6252 | ||
| 6264 | 6253 | const from = '/tmp/hello'; | |
@@ -6274,7 +6263,6 @@ try { | |||
| 6274 | 6263 | ``` | |
| 6275 | 6264 | ||
| 6276 | 6265 | ```cjs | |
| 6277 | - // Using CommonJS syntax | ||
| 6278 | 6266 | const { rename, stat } = require('fs/promises'); | |
| 6279 | 6267 | ||
| 6280 | 6268 | (async function(from, to) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments