| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5436057 commit 4fcbfdc
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4180,7 +4180,7 @@ recommended. | |||
| 4180 | 4180 | When `file` is a file descriptor, the behavior is almost identical to directly | |
| 4181 | 4181 | calling `fs.write()` like: | |
| 4182 | 4182 | ||
| 4183 | - ```javascript | ||
| 4183 | + ```js | ||
| 4184 | 4184 | fs.write(fd, Buffer.from(data, options.encoding), callback); | |
| 4185 | 4185 | ``` | |
| 4186 | 4186 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -881,7 +881,7 @@ The `'readable'` event is emitted when there is data available to be read from | |||
| 881 | 881 | the stream. In some cases, attaching a listener for the `'readable'` event will | |
| 882 | 882 | cause some amount of data to be read into an internal buffer. | |
| 883 | 883 | ||
| 884 | - ```javascript | ||
| 884 | + ```js | ||
| 885 | 885 | const readable = getReadableStreamSomehow(); | |
| 886 | 886 | readable.on('readable', function() { | |
| 887 | 887 | // There is some data to read now. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,7 +29,7 @@ For example, look for `test-streams` when writing a test for `lib/streams.js`. | |||
| 29 | 29 | ||
| 30 | 30 | Let's analyze this basic test from the Node.js test suite: | |
| 31 | 31 | ||
| 32 | - ```javascript | ||
| 32 | + ```js | ||
| 33 | 33 | 'use strict'; // 1 | |
| 34 | 34 | const common = require('../common'); // 2 | |
| 35 | 35 | const fixtures = require('../common/fixtures'); // 3 | |
@@ -57,7 +57,7 @@ server.listen(0, () => { // 14 | |||
| 57 | 57 | ||
| 58 | 58 | ### **Lines 1-3** | |
| 59 | 59 | ||
| 60 | - ```javascript | ||
| 60 | + ```js | ||
| 61 | 61 | 'use strict'; | |
| 62 | 62 | const common = require('../common'); | |
| 63 | 63 | const fixtures = require('../common/fixtures'); | |
@@ -78,13 +78,13 @@ the test leaks variables into the global space. In situations where a test uses | |||
| 78 | 78 | no functions or other properties exported by `common`, include it without | |
| 79 | 79 | assigning it to an identifier: | |
| 80 | 80 | ||
| 81 | - ```javascript | ||
| 81 | + ```js | ||
| 82 | 82 | require('../common'); | |
| 83 | 83 | ``` | |
| 84 | 84 | ||
| 85 | 85 | ### **Lines 5-6** | |
| 86 | 86 | ||
| 87 | - ```javascript | ||
| 87 | + ```js | ||
| 88 | 88 | // This test ensures that the http-parser can handle UTF-8 characters | |
| 89 | 89 | // in the http header. | |
| 90 | 90 | ``` | |
@@ -94,7 +94,7 @@ designed to test. | |||
| 94 | 94 | ||
| 95 | 95 | ### **Lines 8-9** | |
| 96 | 96 | ||
| 97 | - ```javascript | ||
| 97 | + ```js | ||
| 98 | 98 | const assert = require('assert'); | |
| 99 | 99 | const http = require('http'); | |
| 100 | 100 | ``` | |
@@ -136,7 +136,7 @@ In the event a test needs a timer, consider using the | |||
| 136 | 136 | `common.platformTimeout()` method. It allows setting specific timeouts | |
| 137 | 137 | depending on the platform: | |
| 138 | 138 | ||
| 139 | - ```javascript | ||
| 139 | + ```js | ||
| 140 | 140 | const timer = setTimeout(fail, common.platformTimeout(4000)); | |
| 141 | 141 | ``` | |
| 142 | 142 | ||
@@ -155,7 +155,7 @@ One interesting case is `common.mustCall`. The use of `common.mustCall` may | |||
| 155 | 155 | avoid the use of extra variables and the corresponding assertions. Let's | |
| 156 | 156 | explain this with a real test from the test suite. | |
| 157 | 157 | ||
| 158 | - ```javascript | ||
| 158 | + ```js | ||
| 159 | 159 | 'use strict'; | |
| 160 | 160 | require('../common'); | |
| 161 | 161 | const assert = require('assert'); | |
@@ -189,7 +189,7 @@ const server = http.createServer((req, res) => { | |||
| 189 | 189 | ||
| 190 | 190 | This test could be greatly simplified by using `common.mustCall` like this: | |
| 191 | 191 | ||
| 192 | - ```javascript | ||
| 192 | + ```js | ||
| 193 | 193 | 'use strict'; | |
| 194 | 194 | const common = require('../common'); | |
| 195 | 195 | const http = require('http'); | |
@@ -216,7 +216,7 @@ provides a simple countdown mechanism for tests that require a particular | |||
| 216 | 216 | action to be taken after a given number of completed tasks (for instance, | |
| 217 | 217 | shutting down an HTTP server after a specific number of requests). | |
| 218 | 218 | ||
| 219 | - ```javascript | ||
| 219 | + ```js | ||
| 220 | 220 | const Countdown = require('../common/countdown'); | |
| 221 | 221 | ||
| 222 | 222 | const countdown = new Countdown(2, () => { | |
@@ -237,7 +237,7 @@ hence, the test fail - in the case of an `unhandledRejection` event. It is | |||
| 237 | 237 | possible to disable it with `common.disableCrashOnUnhandledRejection()` if | |
| 238 | 238 | needed. | |
| 239 | 239 | ||
| 240 | - ```javascript | ||
| 240 | + ```js | ||
| 241 | 241 | const common = require('../common'); | |
| 242 | 242 | const assert = require('assert'); | |
| 243 | 243 | const fs = require('fs').promises; | |
@@ -257,7 +257,7 @@ test followed by the flags. For example, to allow a test to require some of the | |||
| 257 | 257 | `internal/*` modules, add the `--expose-internals` flag. | |
| 258 | 258 | A test that would require `internal/freelist` could start like this: | |
| 259 | 259 | ||
| 260 | - ```javascript | ||
| 260 | + ```js | ||
| 261 | 261 | 'use strict'; | |
| 262 | 262 | ||
| 263 | 263 | // Flags: --expose-internals | |
| Back | FazBrowse Home | New Git URL |
0 commit comments