| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6de88bc commit 621266a
58 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -235,6 +235,7 @@ NODE_MODULE_INIT(/* exports, module, context */) { | |||
| 235 | 235 | ``` | |
| 236 | 236 | ||
| 237 | 237 | #### Worker support | |
| 238 | + | ||
| 238 | 239 | <!-- YAML | |
| 239 | 240 | changes: | |
| 240 | 241 | - version: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,6 +10,7 @@ The `assert` module provides a set of assertion functions for verifying | |||
| 10 | 10 | invariants. | |
| 11 | 11 | ||
| 12 | 12 | ## Strict assertion mode | |
| 13 | + | ||
| 13 | 14 | <!-- YAML | |
| 14 | 15 | added: v9.9.0 | |
| 15 | 16 | changes: | |
@@ -138,6 +139,7 @@ Indicates the failure of an assertion. All errors thrown by the `assert` module | |||
| 138 | 139 | will be instances of the `AssertionError` class. | |
| 139 | 140 | ||
| 140 | 141 | ### `new assert.AssertionError(options)` | |
| 142 | + | ||
| 141 | 143 | <!-- YAML | |
| 142 | 144 | added: v0.1.21 | |
| 143 | 145 | --> | |
@@ -216,6 +218,7 @@ try { | |||
| 216 | 218 | ``` | |
| 217 | 219 | ||
| 218 | 220 | ## Class: `assert.CallTracker` | |
| 221 | + | ||
| 219 | 222 | <!-- YAML | |
| 220 | 223 | added: | |
| 221 | 224 | - v14.2.0 | |
@@ -227,6 +230,7 @@ added: | |||
| 227 | 230 | This feature is currently experimental and behavior might still change. | |
| 228 | 231 | ||
| 229 | 232 | ### `new assert.CallTracker()` | |
| 233 | + | ||
| 230 | 234 | <!-- YAML | |
| 231 | 235 | added: | |
| 232 | 236 | - v14.2.0 | |
@@ -278,6 +282,7 @@ process.on('exit', () => { | |||
| 278 | 282 | ``` | |
| 279 | 283 | ||
| 280 | 284 | ### `tracker.calls([fn][, exact])` | |
| 285 | + | ||
| 281 | 286 | <!-- YAML | |
| 282 | 287 | added: | |
| 283 | 288 | - v14.2.0 | |
@@ -320,6 +325,7 @@ const callsfunc = tracker.calls(func); | |||
| 320 | 325 | ``` | |
| 321 | 326 | ||
| 322 | 327 | ### `tracker.report()` | |
| 328 | + | ||
| 323 | 329 | <!-- YAML | |
| 324 | 330 | added: | |
| 325 | 331 | - v14.2.0 | |
@@ -396,6 +402,7 @@ tracker.report(); | |||
| 396 | 402 | ``` | |
| 397 | 403 | ||
| 398 | 404 | ### `tracker.verify()` | |
| 405 | + | ||
| 399 | 406 | <!-- YAML | |
| 400 | 407 | added: | |
| 401 | 408 | - v14.2.0 | |
@@ -443,6 +450,7 @@ tracker.verify(); | |||
| 443 | 450 | ``` | |
| 444 | 451 | ||
| 445 | 452 | ## `assert(value[, message])` | |
| 453 | + | ||
| 446 | 454 | <!-- YAML | |
| 447 | 455 | added: v0.5.9 | |
| 448 | 456 | --> | |
@@ -453,6 +461,7 @@ added: v0.5.9 | |||
| 453 | 461 | An alias of [`assert.ok()`][]. | |
| 454 | 462 | ||
| 455 | 463 | ## `assert.deepEqual(actual, expected[, message])` | |
| 464 | + | ||
| 456 | 465 | <!-- YAML | |
| 457 | 466 | added: v0.1.21 | |
| 458 | 467 | changes: | |
@@ -627,6 +636,7 @@ parameter is an instance of an [`Error`][] then it will be thrown instead of the | |||
| 627 | 636 | [`AssertionError`][]. | |
| 628 | 637 | ||
| 629 | 638 | ## `assert.deepStrictEqual(actual, expected[, message])` | |
| 639 | + | ||
| 630 | 640 | <!-- YAML | |
| 631 | 641 | added: v1.2.0 | |
| 632 | 642 | changes: | |
@@ -877,6 +887,7 @@ parameter is an instance of an [`Error`][] then it will be thrown instead of the | |||
| 877 | 887 | `AssertionError`. | |
| 878 | 888 | ||
| 879 | 889 | ## `assert.doesNotMatch(string, regexp[, message])` | |
| 890 | + | ||
| 880 | 891 | <!-- YAML | |
| 881 | 892 | added: | |
| 882 | 893 | - v13.6.0 | |
@@ -927,6 +938,7 @@ instance of an [`Error`][] then it will be thrown instead of the | |||
| 927 | 938 | [`AssertionError`][]. | |
| 928 | 939 | ||
| 929 | 940 | ## `assert.doesNotReject(asyncFn[, error][, message])` | |
| 941 | + | ||
| 930 | 942 | <!-- YAML | |
| 931 | 943 | added: v10.0.0 | |
| 932 | 944 | --> | |
@@ -999,6 +1011,7 @@ assert.doesNotReject(Promise.reject(new TypeError('Wrong value'))) | |||
| 999 | 1011 | ``` | |
| 1000 | 1012 | ||
| 1001 | 1013 | ## `assert.doesNotThrow(fn[, error][, message])` | |
| 1014 | + | ||
| 1002 | 1015 | <!-- YAML | |
| 1003 | 1016 | added: v0.1.21 | |
| 1004 | 1017 | changes: | |
@@ -1115,6 +1128,7 @@ assert.doesNotThrow( | |||
| 1115 | 1128 | ``` | |
| 1116 | 1129 | ||
| 1117 | 1130 | ## `assert.equal(actual, expected[, message])` | |
| 1131 | + | ||
| 1118 | 1132 | <!-- YAML | |
| 1119 | 1133 | added: v0.1.21 | |
| 1120 | 1134 | changes: | |
@@ -1183,6 +1197,7 @@ parameter is an instance of an [`Error`][] then it will be thrown instead of the | |||
| 1183 | 1197 | `AssertionError`. | |
| 1184 | 1198 | ||
| 1185 | 1199 | ## `assert.fail([message])` | |
| 1200 | + | ||
| 1186 | 1201 | <!-- YAML | |
| 1187 | 1202 | added: v0.1.21 | |
| 1188 | 1203 | --> | |
@@ -1223,6 +1238,7 @@ Using `assert.fail()` with more than two arguments is possible but deprecated. | |||
| 1223 | 1238 | See below for further details. | |
| 1224 | 1239 | ||
| 1225 | 1240 | ## `assert.fail(actual, expected[, message[, operator[, stackStartFn]]])` | |
| 1241 | + | ||
| 1226 | 1242 | <!-- YAML | |
| 1227 | 1243 | added: v0.1.21 | |
| 1228 | 1244 | changes: | |
@@ -1320,6 +1336,7 @@ suppressFrame(); | |||
| 1320 | 1336 | ``` | |
| 1321 | 1337 | ||
| 1322 | 1338 | ## `assert.ifError(value)` | |
| 1339 | + | ||
| 1323 | 1340 | <!-- YAML | |
| 1324 | 1341 | added: v0.1.97 | |
| 1325 | 1342 | changes: | |
@@ -1393,6 +1410,7 @@ let err; | |||
| 1393 | 1410 | ``` | |
| 1394 | 1411 | ||
| 1395 | 1412 | ## `assert.match(string, regexp[, message])` | |
| 1413 | + | ||
| 1396 | 1414 | <!-- YAML | |
| 1397 | 1415 | added: | |
| 1398 | 1416 | - v13.6.0 | |
@@ -1443,6 +1461,7 @@ instance of an [`Error`][] then it will be thrown instead of the | |||
| 1443 | 1461 | [`AssertionError`][]. | |
| 1444 | 1462 | ||
| 1445 | 1463 | ## `assert.notDeepEqual(actual, expected[, message])` | |
| 1464 | + | ||
| 1446 | 1465 | <!-- YAML | |
| 1447 | 1466 | added: v0.1.21 | |
| 1448 | 1467 | changes: | |
@@ -1564,6 +1583,7 @@ If the values are deeply equal, an [`AssertionError`][] is thrown with a | |||
| 1564 | 1583 | instead of the `AssertionError`. | |
| 1565 | 1584 | ||
| 1566 | 1585 | ## `assert.notDeepStrictEqual(actual, expected[, message])` | |
| 1586 | + | ||
| 1567 | 1587 | <!-- YAML | |
| 1568 | 1588 | added: v1.2.0 | |
| 1569 | 1589 | changes: | |
@@ -1623,6 +1643,7 @@ the `message` parameter is an instance of an [`Error`][] then it will be thrown | |||
| 1623 | 1643 | instead of the [`AssertionError`][]. | |
| 1624 | 1644 | ||
| 1625 | 1645 | ## `assert.notEqual(actual, expected[, message])` | |
| 1646 | + | ||
| 1626 | 1647 | <!-- YAML | |
| 1627 | 1648 | added: v0.1.21 | |
| 1628 | 1649 | changes: | |
@@ -1685,6 +1706,7 @@ parameter is an instance of an [`Error`][] then it will be thrown instead of the | |||
| 1685 | 1706 | `AssertionError`. | |
| 1686 | 1707 | ||
| 1687 | 1708 | ## `assert.notStrictEqual(actual, expected[, message])` | |
| 1709 | + | ||
| 1688 | 1710 | <!-- YAML | |
| 1689 | 1711 | added: v0.1.21 | |
| 1690 | 1712 | changes: | |
@@ -1737,6 +1759,7 @@ If the values are strictly equal, an [`AssertionError`][] is thrown with a | |||
| 1737 | 1759 | instead of the `AssertionError`. | |
| 1738 | 1760 | ||
| 1739 | 1761 | ## `assert.ok(value[, message])` | |
| 1762 | + | ||
| 1740 | 1763 | <!-- YAML | |
| 1741 | 1764 | added: v0.1.21 | |
| 1742 | 1765 | changes: | |
@@ -1854,6 +1877,7 @@ assert(0); | |||
| 1854 | 1877 | ``` | |
| 1855 | 1878 | ||
| 1856 | 1879 | ## `assert.rejects(asyncFn[, error][, message])` | |
| 1880 | + | ||
| 1857 | 1881 | <!-- YAML | |
| 1858 | 1882 | added: v10.0.0 | |
| 1859 | 1883 | --> | |
@@ -1974,6 +1998,7 @@ example in [`assert.throws()`][] carefully if using a string as the second | |||
| 1974 | 1998 | argument gets considered. | |
| 1975 | 1999 | ||
| 1976 | 2000 | ## `assert.strictEqual(actual, expected[, message])` | |
| 2001 | + | ||
| 1977 | 2002 | <!-- YAML | |
| 1978 | 2003 | added: v0.1.21 | |
| 1979 | 2004 | changes: | |
@@ -2052,6 +2077,7 @@ If the values are not strictly equal, an [`AssertionError`][] is thrown with a | |||
| 2052 | 2077 | instead of the [`AssertionError`][]. | |
| 2053 | 2078 | ||
| 2054 | 2079 | ## `assert.throws(fn[, error][, message])` | |
| 2080 | + | ||
| 2055 | 2081 | <!-- YAML | |
| 2056 | 2082 | added: v0.1.21 | |
| 2057 | 2083 | changes: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,6 +7,7 @@ | |||
| 7 | 7 | <!-- source_link=lib/async_hooks.js --> | |
| 8 | 8 | ||
| 9 | 9 | ## Introduction | |
| 10 | + | ||
| 10 | 11 | These classes are used to associate state and propagate it throughout | |
| 11 | 12 | callbacks and promise chains. | |
| 12 | 13 | They allow storing data throughout the lifetime of a web request | |
@@ -25,6 +26,7 @@ const async_hooks = require('async_hooks'); | |||
| 25 | 26 | ``` | |
| 26 | 27 | ||
| 27 | 28 | ## Class: `AsyncLocalStorage` | |
| 29 | + | ||
| 28 | 30 | <!-- YAML | |
| 29 | 31 | added: | |
| 30 | 32 | - v13.10.0 | |
@@ -115,6 +117,7 @@ Multiple instances can safely exist simultaneously without risk of interfering | |||
| 115 | 117 | with each other data. | |
| 116 | 118 | ||
| 117 | 119 | ### `new AsyncLocalStorage()` | |
| 120 | + | ||
| 118 | 121 | <!-- YAML | |
| 119 | 122 | added: | |
| 120 | 123 | - v13.10.0 | |
@@ -125,6 +128,7 @@ Creates a new instance of `AsyncLocalStorage`. Store is only provided within a | |||
| 125 | 128 | `run()` call or after an `enterWith()` call. | |
| 126 | 129 | ||
| 127 | 130 | ### `asyncLocalStorage.disable()` | |
| 131 | + | ||
| 128 | 132 | <!-- YAML | |
| 129 | 133 | added: | |
| 130 | 134 | - v13.10.0 | |
@@ -149,6 +153,7 @@ Use this method when the `asyncLocalStorage` is not in use anymore | |||
| 149 | 153 | in the current process. | |
| 150 | 154 | ||
| 151 | 155 | ### `asyncLocalStorage.getStore()` | |
| 156 | + | ||
| 152 | 157 | <!-- YAML | |
| 153 | 158 | added: | |
| 154 | 159 | - v13.10.0 | |
@@ -163,6 +168,7 @@ calling `asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()`, it | |||
| 163 | 168 | returns `undefined`. | |
| 164 | 169 | ||
| 165 | 170 | ### `asyncLocalStorage.enterWith(store)` | |
| 171 | + | ||
| 166 | 172 | <!-- YAML | |
| 167 | 173 | added: | |
| 168 | 174 | - v13.11.0 | |
@@ -212,6 +218,7 @@ asyncLocalStorage.getStore(); // Returns the same object | |||
| 212 | 218 | ``` | |
| 213 | 219 | ||
| 214 | 220 | ### `asyncLocalStorage.run(store, callback[, ...args])` | |
| 221 | + | ||
| 215 | 222 | <!-- YAML | |
| 216 | 223 | added: | |
| 217 | 224 | - v13.10.0 | |
@@ -251,6 +258,7 @@ try { | |||
| 251 | 258 | ``` | |
| 252 | 259 | ||
| 253 | 260 | ### `asyncLocalStorage.exit(callback[, ...args])` | |
| 261 | + | ||
| 254 | 262 | <!-- YAML | |
| 255 | 263 | added: | |
| 256 | 264 | - v13.10.0 | |
@@ -326,6 +334,7 @@ the loss. When the code logs `undefined`, the last callback called is probably | |||
| 326 | 334 | responsible for the context loss. | |
| 327 | 335 | ||
| 328 | 336 | ## Class: `AsyncResource` | |
| 337 | + | ||
| 329 | 338 | <!-- YAML | |
| 330 | 339 | changes: | |
| 331 | 340 | - version: v16.4.0 | |
@@ -434,6 +443,7 @@ class DBQuery extends AsyncResource { | |||
| 434 | 443 | ``` | |
| 435 | 444 | ||
| 436 | 445 | ### Static method: `AsyncResource.bind(fn[, type, [thisArg]])` | |
| 446 | + | ||
| 437 | 447 | <!-- YAML | |
| 438 | 448 | added: | |
| 439 | 449 | - v14.8.0 | |
@@ -455,6 +465,7 @@ The returned function will have an `asyncResource` property referencing | |||
| 455 | 465 | the `AsyncResource` to which the function is bound. | |
| 456 | 466 | ||
| 457 | 467 | ### `asyncResource.bind(fn[, thisArg])` | |
| 468 | + | ||
| 458 | 469 | <!-- YAML | |
| 459 | 470 | added: | |
| 460 | 471 | - v14.8.0 | |
@@ -474,6 +485,7 @@ The returned function will have an `asyncResource` property referencing | |||
| 474 | 485 | the `AsyncResource` to which the function is bound. | |
| 475 | 486 | ||
| 476 | 487 | ### `asyncResource.runInAsyncScope(fn[, thisArg, ...args])` | |
| 488 | + | ||
| 477 | 489 | <!-- YAML | |
| 478 | 490 | added: v9.6.0 | |
| 479 | 491 | --> | |
@@ -507,6 +519,7 @@ never be called. | |||
| 507 | 519 | `AsyncResource` constructor. | |
| 508 | 520 | ||
| 509 | 521 | <a id="async-resource-worker-pool"></a> | |
| 522 | + | ||
| 510 | 523 | ### Using `AsyncResource` for a `Worker` thread pool | |
| 511 | 524 | ||
| 512 | 525 | The following example shows how to use the `AsyncResource` class to properly | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -190,7 +190,7 @@ const asyncHook = async_hooks.createHook(new MyAddedCallbacks()); | |||
| 190 | 190 | ||
| 191 | 191 | Because promises are asynchronous resources whose lifecycle is tracked | |
| 192 | 192 | via the async hooks mechanism, the `init()`, `before()`, `after()`, and | |
| 193 | - `destroy()` callbacks *must not* be async functions that return promises. | ||
| 193 | + `destroy()` callbacks _must not_ be async functions that return promises. | ||
| 194 | 194 | ||
| 195 | 195 | ### Error handling | |
| 196 | 196 | ||
@@ -350,8 +350,8 @@ listening to the hooks. | |||
| 350 | 350 | ||
| 351 | 351 | `triggerAsyncId` is the `asyncId` of the resource that caused (or "triggered") | |
| 352 | 352 | the new resource to initialize and that caused `init` to call. This is different | |
| 353 | - from `async_hooks.executionAsyncId()` that only shows *when* a resource was | ||
| 354 | - created, while `triggerAsyncId` shows *why* a resource was created. | ||
| 353 | + from `async_hooks.executionAsyncId()` that only shows _when_ a resource was | ||
| 354 | + created, while `triggerAsyncId` shows _why_ a resource was created. | ||
| 355 | 355 | ||
| 356 | 356 | The following is a simple demonstration of `triggerAsyncId`: | |
| 357 | 357 | ||
@@ -499,13 +499,13 @@ TickObject(6) | |||
| 499 | 499 | ||
| 500 | 500 | The `TCPSERVERWRAP` is not part of this graph, even though it was the reason for | |
| 501 | 501 | `console.log()` being called. This is because binding to a port without a host | |
| 502 | - name is a *synchronous* operation, but to maintain a completely asynchronous | ||
| 502 | + name is a _synchronous_ operation, but to maintain a completely asynchronous | ||
| 503 | 503 | API the user's callback is placed in a `process.nextTick()`. Which is why | |
| 504 | 504 | `TickObject` is present in the output and is a 'parent' for `.listen()` | |
| 505 | 505 | callback. | |
| 506 | 506 | ||
| 507 | - The graph only shows *when* a resource was created, not *why*, so to track | ||
| 508 | - the *why* use `triggerAsyncId`. Which can be represented with the following | ||
| 507 | + The graph only shows _when_ a resource was created, not _why_, so to track | ||
| 508 | + the _why_ use `triggerAsyncId`. Which can be represented with the following | ||
| 509 | 509 | graph: | |
| 510 | 510 | ||
| 511 | 511 | ```console | |
@@ -545,7 +545,7 @@ it only once. | |||
| 545 | 545 | Called immediately after the callback specified in `before` is completed. | |
| 546 | 546 | ||
| 547 | 547 | If an uncaught exception occurs during execution of the callback, then `after` | |
| 548 | - will run *after* the `'uncaughtException'` event is emitted or a `domain`'s | ||
| 548 | + will run _after_ the `'uncaughtException'` event is emitted or a `domain`'s | ||
| 549 | 549 | handler runs. | |
| 550 | 550 | ||
| 551 | 551 | #### `destroy(asyncId)` | |
| Back | FazBrowse Home | New Git URL |
0 commit comments