content
large_stringlengths
3
20.5k
url
large_stringlengths
53
192
branch
large_stringclasses
4 values
source
large_stringclasses
51 values
embeddings
listlengths
384
384
score
float64
-0.21
0.65
and `error` is emitted. ```cjs const { spawn } = require('node:child\_process'); const grep = spawn('grep', ['ssh']); console.log(`Spawned child pid: ${grep.pid}`); grep.stdin.end(); ``` ```mjs import { spawn } from 'node:child\_process'; const grep = spawn('grep', ['ssh']); console.log(`Spawned child pid: ${grep.pid}`...
https://github.com/nodejs/node/blob/main/doc/api/child_process.md
main
nodejs
[ -0.07473903149366379, -0.003340593772009015, 0.007128054276108742, -0.0005834996700286865, 0.07028288394212723, -0.0025208669248968363, -0.026422273367643356, 0.06644205749034882, 0.06384024024009705, 0.024706007912755013, -0.04588717967271805, -0.025005128234624863, -0.004010539967566729, ...
0.036181
is not supported on Windows. The optional `callback` is a function that is invoked after the message is sent but before the child process may have received it. The function is called with a single argument: `null` on success, or an [`Error`][] object on failure. If no `callback` function is provided and the message can...
https://github.com/nodejs/node/blob/main/doc/api/child_process.md
main
nodejs
[ -0.10113533586263657, -0.011544929817318916, -0.04310967028141022, 0.10458449274301529, -0.0027799755334854126, -0.03475479409098625, 0.02927052229642868, 0.05715186521410942, 0.0819799154996872, 0.012267271988093853, -0.04706013575196266, 0.01908264309167862, -0.035079214721918106, 0.0006...
0.112834
return; } // This is normal priority. normal.send('socket', socket); }); server.listen(1337); ``` The `subprocess.js` would receive the socket handle as the second argument passed to the event callback function: ```js process.on('message', (m, socket) => { if (m === 'socket') { if (socket) { // Check that the client so...
https://github.com/nodejs/node/blob/main/doc/api/child_process.md
main
nodejs
[ -0.09639465063810349, -0.0466325543820858, -0.011745951138436794, 0.00454634940251708, -0.0010624664137139916, -0.07859639823436737, 0.019260860979557037, 0.010539104230701923, 0.10475765913724899, 0.025379562750458717, -0.052307091653347015, 0.11479219049215317, -0.0486646443605423, 0.032...
0.103986
from 'node:assert'; import fs from 'node:fs'; import child\_process from 'node:child\_process'; const subprocess = child\_process.spawn('ls', { stdio: [ 0, // Use parent's stdin for child. 'pipe', // Pipe child's stdout to parent. fs.openSync('err.out', 'w'), // Direct child's stderr to a file. ], }); assert.strictEqua...
https://github.com/nodejs/node/blob/main/doc/api/child_process.md
main
nodejs
[ -0.05054837465286255, 0.0028449799865484238, -0.0516599640250206, 0.015362747944891453, 0.0346195325255394, -0.06021425873041153, -0.06720363348722458, 0.11886417865753174, -0.028716441243886948, 0.010952498763799667, -0.04729372262954712, -0.037963949143886566, -0.005428734701126814, 0.00...
0.049153
deprecations.md#DEP0190 [Default Windows shell]: #default-windows-shell [HTML structured clone algorithm]: https://developer.mozilla.org/en-US/docs/Web/API/Web\_Workers\_API/Structured\_clone\_algorithm [Shell requirements]: #shell-requirements [Signal Events]: process.md#signal-events [`'disconnect'`]: process.md#even...
https://github.com/nodejs/node/blob/main/doc/api/child_process.md
main
nodejs
[ -0.08982066810131073, 0.0009007722837850451, -0.0759715735912323, 0.06771314889192581, -0.0028184775728732347, -0.10884989798069, 0.012503341771662235, -0.004858390428125858, 0.004532970953732729, 0.012551920488476753, -0.0003112804261036217, -0.03110506944358349, 0.00035725420457310975, 0...
0.104922
# Assert > Stability: 2 - Stable The `node:assert` module provides a set of assertion functions for verifying invariants. ## Strict assertion mode In strict assertion mode, non-strict methods behave like their corresponding strict methods. For example, [`assert.deepEqual()`][] will behave like [`assert.deepStrictEqual(...
https://github.com/nodejs/node/blob/main/doc/api/assert.md
main
nodejs
[ -0.09506801515817642, 0.02533201314508915, 0.041743937879800797, 0.08052825927734375, 0.0504646971821785, -0.0780942365527153, -0.035604264587163925, -0.0030536584090441465, -0.08403772860765457, -0.018523558974266052, -0.017994092777371407, -0.03860095515847206, 0.07284962385892868, 0.024...
0.10672
`'full'`, shows the full diff in assertion errors. Defaults to `'simple'`. Accepted values: `'simple'`, `'full'`. A subclass of {Error} that indicates the failure of an assertion. All instances contain the built-in `Error` properties (`message` and `name`) and: \* `actual` {any} Set to the `actual` argument for methods...
https://github.com/nodejs/node/blob/main/doc/api/assert.md
main
nodejs
[ -0.07443275302648544, 0.0585285909473896, 0.0642521008849144, 0.08324945718050003, 0.05340307578444481, -0.10577473789453506, -0.005588962230831385, 0.03297936171293259, -0.05294225364923477, 0.025576207786798477, 0.008824171498417854, -0.055519673973321915, 0.0810461938381195, 0.008697355...
0.045267
when using destructured methods, avoid destructuring and call methods directly on the instance. ## `assert(value[, message])` \* `value` {any} The input that is checked for being truthy. \* `message` {string|Error|Function} An alias of [`assert.ok()`][]. ## `assert.deepEqual(actual, expected[, message])` \* `actual` {a...
https://github.com/nodejs/node/blob/main/doc/api/assert.md
main
nodejs
[ -0.09238405525684357, -0.0031946683302521706, 0.03625648841261864, 0.018374435603618622, -0.008233464322984219, -0.08129649609327316, -0.0380730964243412, 0.02646295726299286, -0.07257416099309921, -0.044689103960990906, -0.02748512104153633, -0.030127063393592834, 0.050876617431640625, 0....
0.078376
value of the `message` parameter. If the `message` parameter is undefined, a default error message is assigned. If the `message` parameter is an instance of {Error} then it will be thrown instead of the [`AssertionError`][]. ## `assert.deepStrictEqual(actual, expected[, message])` \* `actual` {any} \* `expected` {any} ...
https://github.com/nodejs/node/blob/main/doc/api/assert.md
main
nodejs
[ -0.0802910327911377, 0.018312551081180573, 0.0762878805398941, 0.045835014432668686, -0.006460023112595081, -0.08513257652521133, 0.008560416288673878, 0.040033116936683655, -0.023389484733343124, -0.03875456005334854, -0.043094452470541, -0.06580781191587448, 0.013443365693092346, 0.04854...
0.092701
assert.deepStrictEqual(weakMap1, weakMap1); // OK const weakSet1 = new WeakSet(); const weakSet2 = new WeakSet(); weakSet1.add(obj); weakSet2.add(obj); // Comparing different instances fails, even with same contents assert.deepStrictEqual(weakSet1, weakSet2); // AssertionError: Values have same structure but are not re...
https://github.com/nodejs/node/blob/main/doc/api/assert.md
main
nodejs
[ -0.06996538490056992, -0.02246650867164135, 0.07521893084049225, 0.0011178934946656227, 0.007331791799515486, -0.057659812271595, -0.05199552699923515, 0.0015417553950101137, -0.025746550410985947, -0.10711409896612167, -0.05175625905394554, -0.0851336419582367, 0.033442575484514236, -0.01...
0.020793
OK ``` ```cjs const assert = require('node:assert/strict'); assert.doesNotMatch('I will fail', /fail/); // AssertionError [ERR\_ASSERTION]: The input was expected to not match the ... assert.doesNotMatch(123, /pass/); // AssertionError [ERR\_ASSERTION]: The "string" argument must be of type string. assert.doesNotMatch(...
https://github.com/nodejs/node/blob/main/doc/api/assert.md
main
nodejs
[ -0.09647823125123978, 0.055753473192453384, 0.03020447865128517, 0.0683225616812706, 0.012414385564625263, -0.0173322893679142, 0.032196756452322006, 0.012431410141289234, -0.012635407969355583, -0.08159345388412476, -0.047563280910253525, -0.06049487367272377, 0.024688344448804855, 0.0641...
0.076467
import assert from 'node:assert/strict'; assert.doesNotThrow( () => { throw new TypeError('Wrong value'); }, TypeError, ); ``` ```cjs const assert = require('node:assert/strict'); assert.doesNotThrow( () => { throw new TypeError('Wrong value'); }, TypeError, ); ``` If an [`AssertionError`][] is thrown and a value is pr...
https://github.com/nodejs/node/blob/main/doc/api/assert.md
main
nodejs
[ -0.04211072996258736, 0.08788605779409409, 0.06914689391851425, 0.08005188405513763, 0.029154762625694275, -0.051241591572761536, 0.05311218649148941, -0.010600855574011803, -0.01169106550514698, -0.02651141956448555, 0.024566706269979477, -0.043770451098680496, 0.04570501670241356, 0.0401...
0.08896
assert = require('node:assert/strict'); assert.ifError(null); // OK assert.ifError(0); // AssertionError [ERR\_ASSERTION]: ifError got unwanted exception: 0 assert.ifError('error'); // AssertionError [ERR\_ASSERTION]: ifError got unwanted exception: 'error' assert.ifError(new Error()); // AssertionError [ERR\_ASSERTION...
https://github.com/nodejs/node/blob/main/doc/api/assert.md
main
nodejs
[ -0.07940606772899628, 0.03697412088513374, 0.023070402443408966, 0.038869135081768036, 0.10544309765100479, -0.03642731159925461, 0.030345618724822998, -0.01875314861536026, 0.017996564507484436, -0.04895063489675522, 0.03191134333610535, -0.011295469477772713, 0.019527709111571312, 0.0650...
0.045019
assert.notDeepStrictEqual({ a: 1 }, { a: '1' }); // OK ``` If the values are deeply and strictly equal, an [`AssertionError`][] is thrown with a `message` property set equal to the value of the `message` parameter. If the `message` parameter is undefined, a default error message is assigned. If the `message` parameter ...
https://github.com/nodejs/node/blob/main/doc/api/assert.md
main
nodejs
[ -0.0496126264333725, 0.035262126475572586, 0.041154880076646805, 0.008581873029470444, -0.0029935918282717466, -0.06434448808431625, 0.030247528105974197, 0.00871219951659441, -0.06833214312791824, -0.01622362993657589, 0.009156308136880398, -0.07669191807508469, 0.11238683015108109, 0.053...
0.032963
// assert.ok(false) assert.ok(0); // AssertionError: The expression evaluated to a falsy value: // // assert.ok(0) ``` ```cjs const assert = require('node:assert/strict'); assert.ok(true); // OK assert.ok(1); // OK assert.ok(); // AssertionError: No value argument passed to `assert.ok()` assert.ok(false, 'it\'s false')...
https://github.com/nodejs/node/blob/main/doc/api/assert.md
main
nodejs
[ -0.13548187911510468, 0.06753186881542206, 0.010360630229115486, 0.04759962484240532, 0.04105133190751076, -0.011697775684297085, 0.015803705900907516, 0.02726326324045658, 0.025110462680459023, -0.0045223236083984375, -0.02362004853785038, -0.02454826422035694, -0.03053070418536663, 0.049...
0.035067
`message` {string|Error|Function} Postfix `printf`-like arguments in case it's used as format string. If message is a function, it is called in case of a comparison failure. The function receives the `actual` and `expected` arguments and has to return a string that is going to be used as error message. `printf`-like fo...
https://github.com/nodejs/node/blob/main/doc/api/assert.md
main
nodejs
[ -0.025444133207201958, 0.07459086179733276, 0.04184379801154137, 0.03963146731257439, -0.0029782652854919434, -0.06761663407087326, -0.005199054256081581, 0.030472714453935623, -0.021976977586746216, -0.03709433972835541, -0.015950437635183334, -0.029147416353225708, 0.08388878405094147, 0...
0.091056
= 'bar'; err.info = { nested: true, baz: 'text', }; err.reg = /abc/i; assert.throws( () => { throw err; }, { name: 'TypeError', message: 'Wrong value', info: { nested: true, baz: 'text', }, // Only properties on the validation object will be tested for. // Using nested objects requires all properties to be present. Oth...
https://github.com/nodejs/node/blob/main/doc/api/assert.md
main
nodejs
[ -0.03657836839556694, 0.14123980700969696, 0.0971410796046257, 0.0663779079914093, 0.00997986365109682, -0.03359198570251465, 0.02936812862753868, -0.011327886022627354, 0.015117944218218327, -0.006643474567681551, -0.044131800532341, -0.05896296352148056, 0.02649059146642685, 0.0970693081...
0.000133
``` ```cjs const assert = require('node:assert/strict'); assert.throws( () => { throw new Error('Wrong value'); }, /^Error: Wrong value$/, ); ``` Custom error validation: The function must return `true` to indicate all internal validations passed. It will otherwise fail with an [`AssertionError`][]. ```mjs import asser...
https://github.com/nodejs/node/blob/main/doc/api/assert.md
main
nodejs
[ -0.05191668123006821, 0.0728180930018425, 0.07437644153833389, 0.06111364811658859, 0.04754263907670975, -0.03726969659328461, 0.007631555199623108, 0.04268598556518555, -0.029934274032711983, -0.030910607427358627, -0.003841801080852747, -0.047188833355903625, 0.06519291549921036, 0.01813...
0.044617
(as message) in case the function does not throw: assert.throws(notThrowing, 'Second'); // AssertionError [ERR\_ASSERTION]: Missing expected exception: Second // If it was intended to match for the error message do this instead: // It does not throw because the error messages match. assert.throws(throwingSecond, /Secon...
https://github.com/nodejs/node/blob/main/doc/api/assert.md
main
nodejs
[ -0.0370369553565979, 0.04071494936943054, 0.07270529866218567, 0.05377385765314102, 0.0546984039247036, -0.036919087171554565, 0.006383241154253483, 0.009924749843776226, 0.0018101498717442155, -0.03256935626268387, -0.004143684636801481, -0.059818871319293976, 0.08237678557634354, 0.03376...
0.020969
); // OK assert.partialDeepStrictEqual(123n, 123n); // OK assert.partialDeepStrictEqual( [1, 2, 3, 4, 5, 6, 7, 8, 9], [5, 4, 8], ); // AssertionError assert.partialDeepStrictEqual( { a: 1 }, { a: 1, b: 2 }, ); // AssertionError assert.partialDeepStrictEqual( { a: { b: 2 } }, { a: { b: '2' } }, ); // AssertionError ``` ...
https://github.com/nodejs/node/blob/main/doc/api/assert.md
main
nodejs
[ -0.07054631412029266, 0.09550713747739792, 0.06796392053365707, 0.021612675860524178, -0.030096527189016342, 0.0167288389056921, -0.03649488463997841, -0.025156186893582344, -0.011246934533119202, -0.007621750235557556, -0.07332409918308258, -0.03930448368191719, 0.010702087543904781, 0.05...
0.011508
# REPL > Stability: 2 - Stable The `node:repl` module provides a Read-Eval-Print-Loop (REPL) implementation that is available both as a standalone program or includible in other applications. It can be accessed using: ```mjs import repl from 'node:repl'; ``` ```cjs const repl = require('node:repl'); ``` ## Design and f...
https://github.com/nodejs/node/blob/main/doc/api/repl.md
main
nodejs
[ -0.13750645518302917, 0.002248306293040514, -0.06426481902599335, 0.06610836088657379, 0.019181715324521065, -0.040903009474277496, -0.01867767609655857, 0.017265863716602325, 0.025397446006536484, -0.026093875989317894, -0.04236967861652374, 0.04603302851319313, 0.021245116367936134, -0.0...
0.08138
repl.start('> ').context.m = msg; ``` Properties in the `context` object appear as local within the REPL: ```console $ node repl\_test.js > m 'message' ``` Context properties are not read-only by default. To specify read-only globals, context properties must be defined using `Object.defineProperty()`: ```mjs import rep...
https://github.com/nodejs/node/blob/main/doc/api/repl.md
main
nodejs
[ -0.022503025829792023, 0.0317227728664875, -0.04545355215668678, 0.10125661641359329, 0.02272292599081993, 0.002853013575077057, 0.04514840617775917, 0.0375039242208004, 0.03868705406785011, 0.0012708354042842984, 0.017247790470719337, -0.029156433418393135, 0.02144012041389942, 0.02614569...
0.017469
provided. This can be used, for instance, to implement fully customized REPL applications. An evaluation function accepts the following four arguments: \* `code` {string} The code to be executed (e.g. `1 + 1`). \* `context` {Object} The context in which the code is executed. This can either be the JavaScript `global` c...
https://github.com/nodejs/node/blob/main/doc/api/repl.md
main
nodejs
[ -0.1872682422399521, -0.015639038756489754, -0.10344389081001282, 0.05975411459803581, -0.0911884605884552, -0.04271501302719116, 0.04001498222351074, 0.020117932930588722, 0.050519976764917374, -0.05836404487490654, -0.03238639608025551, 0.017728177830576897, 0.05046496167778969, 0.001429...
0.139134
myEval(cmd, context, filename, callback) { callback(null, cmd); } function myWriter(output) { return output.toUpperCase(); } ``` ## Class: `REPLServer` \* `options` {Object|string} See [`repl.start()`][] \* Extends: {readline.Interface} Instances of `repl.REPLServer` are created using the [`repl.start()`][] method or d...
https://github.com/nodejs/node/blob/main/doc/api/repl.md
main
nodejs
[ -0.11032167822122574, 0.020835917443037033, -0.02272828482091427, 0.079549141228199, -0.047906357795000076, -0.02436147630214691, -0.0006362560670822859, 0.05851877108216286, 0.03463537618517876, -0.0038426981773227453, 0.0011609563371166587, 0.007778682745993137, 0.04575721547007561, -0.0...
0.002678
input is being entered, a pipe `'|'` is printed rather than the 'prompt'. When `preserveCursor` is `true`, the cursor placement will not be reset to `0`. The `replServer.displayPrompt` method is primarily intended to be called from within the action function for commands registered using the `replServer.defineCommand()...
https://github.com/nodejs/node/blob/main/doc/api/repl.md
main
nodejs
[ -0.05755547806620598, -0.03277924284338951, -0.06313521414995193, 0.0020262659527361393, -0.06070489436388016, -0.00028867251239717007, 0.03855140879750252, 0.029941126704216003, 0.005711651407182217, 0.016408655792474747, 0.026994097977876663, 0.006987191271036863, 0.059689342975616455, -...
-0.033755
sets this value to `true`. \*\*Default:\*\* `false`. \* `ignoreUndefined` {boolean} If `true`, specifies that the default writer will not output the return value of a command if it evaluates to `undefined`. \*\*Default:\*\* `false`. \* `writer` {Function} The function to invoke to format the output of each command befo...
https://github.com/nodejs/node/blob/main/doc/api/repl.md
main
nodejs
[ -0.05575362592935562, 0.008599196560680866, 0.019491398707032204, 0.0814950093626976, -0.010070091113448143, -0.032039906829595566, 0.05725761130452156, -0.018898002803325653, -0.008708137087523937, 0.016754159703850746, 0.01501054223626852, -0.017600959166884422, -0.018762635067105293, 0....
0.074282
By default, the Node.js REPL will persist history between `node` REPL sessions by saving inputs to a `.node\_repl\_history` file located in the user's home directory. This can be disabled by setting the environment variable `NODE\_REPL\_HISTORY=''`. ### Using the Node.js REPL with advanced line-editors For advanced lin...
https://github.com/nodejs/node/blob/main/doc/api/repl.md
main
nodejs
[ -0.10722263902425766, -0.05068594217300415, -0.040186166763305664, 0.07625936716794968, 0.040020618587732315, -0.012353927828371525, -0.06237143278121948, 0.006663428619503975, 0.038784075528383255, -0.0021488170605152845, -0.07421211898326874, 0.0601741261780262, 0.017338819801807404, 0.0...
0.01404
`, input: socket, output: socket, terminal: true, useGlobal: false, }); r.on('exit', () => { socket.end(); }); r.context.socket = socket; }) .listen(1337); ``` While the following implements a client that can create a socket connection with the above defined server over port `1337`. ```mjs // repl-client.js import net ...
https://github.com/nodejs/node/blob/main/doc/api/repl.md
main
nodejs
[ -0.0631301999092102, -0.028075827285647392, -0.05228004604578018, -0.021205071359872818, -0.08233873546123505, -0.03320448473095894, -0.012186198495328426, 0.012040951289236546, 0.05118715018033981, 0.02054782770574093, -0.035171911120414734, 0.07921048998832703, 0.007649560924619436, -0.0...
0.111802
# Events > Stability: 2 - Stable Much of the Node.js core API is built around an idiomatic asynchronous event-driven architecture in which certain kinds of objects (called "emitters") emit named events that cause `Function` objects ("listeners") to be called. For instance: a [`net.Server`][] object emits an event each ...
https://github.com/nodejs/node/blob/main/doc/api/events.md
main
nodejs
[ -0.04668070003390312, -0.05048558861017227, 0.03122340701520443, 0.10821567475795746, 0.06232919171452522, -0.033050548285245895, 0.024643732234835625, 0.016222143545746803, 0.13800999522209167, 0.008111572824418545, -0.06321254372596741, 0.09061869233846664, -0.06459853053092957, -0.05196...
0.208408
of operation using the `setImmediate()` or `process.nextTick()` methods: ```mjs import { EventEmitter } from 'node:events'; class MyEmitter extends EventEmitter {} const myEmitter = new MyEmitter(); myEmitter.on('event', (a, b) => { setImmediate(() => { console.log('this happens asynchronously'); }); }); myEmitter.emit...
https://github.com/nodejs/node/blob/main/doc/api/events.md
main
nodejs
[ -0.01623016595840454, -0.017787819728255272, -0.005198770668357611, 0.03892350196838379, -0.016035065054893494, 0.00565071078017354, 0.046256471425294876, 0.06583037227392197, 0.09656588733196259, -0.0017623498570173979, -0.027975013479590416, -0.00917953159660101, -0.05214841291308403, -0...
0.104971
const myEmitter = new EventEmitter(); myEmitter.on(errorMonitor, (err) => { MyMonitoringTool.log(err); }); myEmitter.emit('error', new Error('whoops!')); // Still throws and crashes Node.js ``` ## Capture rejections of promises Using `async` functions with event handlers is problematic, because it can lead to an unhand...
https://github.com/nodejs/node/blob/main/doc/api/events.md
main
nodejs
[ -0.01974034681916237, 0.06558944284915924, 0.06530296802520752, 0.05442727357149124, 0.04719977080821991, -0.015455065295100212, 0.011709935963153839, 0.08466625213623047, 0.0941966325044632, -0.002467029495164752, -0.07766804844141006, -0.09366794675588608, -0.023412030190229416, -0.06758...
0.08043
myEmitter.emit('event'); // Prints: // B // A ``` ```cjs const EventEmitter = require('node:events'); class MyEmitter extends EventEmitter {} const myEmitter = new MyEmitter(); // Only do this once so we don't loop forever myEmitter.once('newListener', (event, listener) => { if (event === 'event') { // Insert a new lis...
https://github.com/nodejs/node/blob/main/doc/api/events.md
main
nodejs
[ 0.02144663967192173, 0.0241862665861845, 0.027686061337590218, 0.02330228127539158, -0.0024292697198688984, -0.0072415792383253574, 0.10355745255947113, 0.03307958319783211, 0.1049746423959732, -0.056196536868810654, -0.01920522004365921, 0.011008662171661854, -0.07196502387523651, -0.0238...
0.101742
Returns a copy of the array of listeners for the event named `eventName`. ```js server.on('connection', (stream) => { console.log('someone connected!'); }); console.log(util.inspect(server.listeners('connection'))); // Prints: [ [Function] ] ``` ### `emitter.off(eventName, listener)` \* `eventName` {string|symbol} \* `...
https://github.com/nodejs/node/blob/main/doc/api/events.md
main
nodejs
[ -0.030462030321359634, -0.011758982203900814, 0.030222419649362564, 0.050586309283971786, 0.02146398462355137, -0.0495150089263916, 0.141843780875206, -0.008910664357244968, 0.15343447029590607, -0.05842336639761925, -0.031843822449445724, 0.06074104458093643, -0.10204237699508667, 0.00889...
0.119209
Removes all listeners, or those of the specified `eventName`. It is bad practice to remove listeners added elsewhere in the code, particularly when the `EventEmitter` instance was created by some other component or module (e.g. sockets or file streams). Returns a reference to the `EventEmitter`, so that calls can be ch...
https://github.com/nodejs/node/blob/main/doc/api/events.md
main
nodejs
[ -0.0195869579911232, 0.023008588701486588, 0.05859212577342987, 0.04962584376335144, 0.0017940723337233067, -0.01711519993841648, 0.11764606088399887, -0.0446663461625576, 0.14666931331157684, -0.03761832416057587, -0.008292007260024548, 0.07659795880317688, -0.07623326033353806, -0.003205...
0.111378
specific `EventEmitter` instance. The value can be set to `Infinity` (or `0`) to indicate an unlimited number of listeners. Returns a reference to the `EventEmitter`, so that calls can be chained. ### `emitter.rawListeners(eventName)` \* `eventName` {string|symbol} \* Returns: {Function\[]} Returns a copy of the array ...
https://github.com/nodejs/node/blob/main/doc/api/events.md
main
nodejs
[ 0.00011107797035947442, -0.03786313161253929, 0.08212202787399292, 0.09262946993112564, -0.0036860082764178514, -0.02743685245513916, 0.0724223181605339, 0.019927602261304855, 0.11231039464473724, -0.020601969212293625, -0.03925912082195282, -0.02253558672964573, -0.03497952222824097, 0.01...
0.115549
use [`emitter.setMaxListeners(n)`][] to set a warning limit for individual `AbortSignal` instances, per default `AbortSignal` instances will not warn. ```mjs import { EventEmitter } from 'node:events'; const emitter = new EventEmitter(); emitter.setMaxListeners(emitter.getMaxListeners() + 1); emitter.once('event', () =...
https://github.com/nodejs/node/blob/main/doc/api/events.md
main
nodejs
[ 0.02623920701444149, 0.012972954660654068, 0.03893299400806427, 0.017583554610610008, -0.03411334007978439, 0.00350751681253314, 0.06517086923122406, 0.06944523751735687, 0.06163899600505829, -0.024495568126440048, -0.041482891887426376, -0.03639332577586174, -0.006757280323654413, -0.0257...
0.108942
event or that is rejected if the `EventEmitter` emits `'error'` while waiting. The `Promise` will resolve with an array of all the arguments emitted to the given event. This method is intentionally generic and works with the web platform [EventTarget][WHATWG-EventTarget] interface, which has no special `'error'` event ...
https://github.com/nodejs/node/blob/main/doc/api/events.md
main
nodejs
[ -0.04625409469008446, 0.06623591482639313, 0.04095448553562164, 0.017615536227822304, 0.022706689313054085, -0.010588805191218853, 0.051827412098646164, 0.09058137983083725, 0.1035056859254837, 0.014932062476873398, -0.04235187545418739, -0.09204667061567307, -0.02951565384864807, -0.02842...
0.093563
where more than one event is emitted during the same phase of the event loop. (The same is true when using `process.nextTick()` to emit events, because the tasks queued by `process.nextTick()` are executed before Promise tasks.) ```mjs import { EventEmitter, once } from 'node:events'; import process from 'node:process'...
https://github.com/nodejs/node/blob/main/doc/api/events.md
main
nodejs
[ -0.051325906068086624, -0.045982297509908676, 0.03291734680533409, 0.019195102155208588, -0.009454591199755669, -0.012495892122387886, 0.022603528574109077, 0.03158789500594139, 0.16913941502571106, 0.0072322203777730465, -0.057053808122873306, -0.007502369116991758, -0.02899421565234661, ...
0.057892
that iterates `eventName` events emitted by the `emitter` ```mjs import { on, EventEmitter } from 'node:events'; import process from 'node:process'; const ee = new EventEmitter(); // Emit later on process.nextTick(() => { ee.emit('foo', 'bar'); ee.emit('foo', 42); }); for await (const event of on(ee, 'foo')) { // The e...
https://github.com/nodejs/node/blob/main/doc/api/events.md
main
nodejs
[ -0.035064928233623505, 0.007275884505361319, 0.03306763619184494, 0.029124192893505096, 0.03671345114707947, -0.04884054884314537, 0.03287988156080246, 0.04499366506934166, 0.09812485426664352, -0.03179478645324707, -0.006131263449788094, -0.03903459012508392, -0.04635433107614517, -0.0457...
0.090814
web standard. Additionally, the original API makes it easy to forget to remove listeners. This API allows safely using `AbortSignal`s in Node.js APIs by solving these two issues by listening to the event such that `stopImmediatePropagation` does not prevent the listener from running. Returns a disposable so that it may...
https://github.com/nodejs/node/blob/main/doc/api/events.md
main
nodejs
[ -0.06382700800895691, -0.0034038492012768984, 0.10028649121522903, 0.0373416468501091, 0.06679941713809967, 0.01353025995194912, 0.05470658093690872, -0.0001173703494714573, 0.06546012312173843, -0.0066382973454892635, -0.03102867305278778, 0.05821578949689865, -0.03644099459052086, -0.026...
0.145139
`eventEmitter` property that provides a reference to this `EventEmitterAsyncResource`. ### `eventemitterasyncresource.emitDestroy()` Call all `destroy` hooks. This should only ever be called once. An error will be thrown if it is called more than once. This \*\*must\*\* be manually called. If the resource is left to be...
https://github.com/nodejs/node/blob/main/doc/api/events.md
main
nodejs
[ -0.047478627413511276, 0.00891670398414135, 0.020257050171494484, 0.06861567497253418, 0.0321941152215004, -0.02895824983716011, 0.09349177032709122, -0.009880694560706615, 0.11955215781927109, -0.010581117123365402, -0.0859353095293045, 0.0032479281071573496, -0.048343729227781296, -0.040...
0.152744
returns a Promise that rejects), by default the error is treated as an uncaught exception on `process.nextTick()`. This means uncaught exceptions in `EventTarget`s will terminate the Node.js process by default. Throwing within an event listener will \_not\_ stop the other registered handlers from being invoked. The `Ev...
https://github.com/nodejs/node/blob/main/doc/api/events.md
main
nodejs
[ -0.0719970241189003, -0.006148833781480789, 0.08194702863693237, 0.04362080246210098, 0.08054813742637634, -0.03158566355705261, 0.053549107164144516, 0.030365660786628723, 0.038226258009672165, 0.00934347789734602, -0.04123365506529808, 0.03948326036334038, -0.035908084362745285, -0.02913...
0.031104
\*\*Default:\*\* `false`. \* `passive` {boolean} When `true`, serves as a hint that the listener will not call the `Event` object's `preventDefault()` method. \*\*Default:\*\* `false`. \* `capture` {boolean} Not directly used by Node.js. Added for API completeness. \*\*Default:\*\* `false`. \* `signal` {AbortSignal} Th...
https://github.com/nodejs/node/blob/main/doc/api/events.md
main
nodejs
[ -0.03519622981548309, 0.04067312553524971, 0.0772169679403305, 0.05953133478760719, 0.1040273904800415, -0.016885288059711456, 0.08064164966344833, -0.0399305634200573, 0.11066598445177078, 0.030217193067073822, -0.008780592121183872, 0.026102226227521896, -0.04956856369972229, -0.03764751...
0.148253
\* `listener` {Function|EventListener} \* Returns: {EventTarget} this Node.js-specific extension to the `EventTarget` class that adds a `once` listener for the given event `type`. This is equivalent to calling `on` with the `once` option set to `true`. #### `nodeEventTarget.removeAllListeners([type])` \* `type` {string...
https://github.com/nodejs/node/blob/main/doc/api/events.md
main
nodejs
[ -0.02701106294989586, 0.03699016198515892, 0.07701893895864487, 0.05966120585799217, 0.0787746012210846, -0.02940925769507885, 0.1581738144159317, -0.02175920084118843, 0.0293035376816988, -0.04811670631170273, -0.03573508933186531, 0.04181913658976555, -0.0889240950345993, 0.0051128324121...
0.076234
# UDP/datagram sockets > Stability: 2 - Stable The `node:dgram` module provides an implementation of UDP datagram sockets. ```mjs import dgram from 'node:dgram'; const server = dgram.createSocket('udp4'); server.on('error', (err) => { console.error(`server error:\n${err.stack}`); server.close(); }); server.on('message'...
https://github.com/nodejs/node/blob/main/doc/api/dgram.md
main
nodejs
[ -0.026368029415607452, -0.015509873628616333, 0.04123610258102417, -0.02257792465388775, -0.04245954751968384, -0.06240127235651016, -0.045369330793619156, 0.014168388210237026, 0.004772023297846317, -0.019043490290641785, -0.018786964938044548, 0.043559618294239044, 0.0074112978763878345, ...
0.090809
else { const s = dgram.createSocket('udp4'); s.bind(1234, () => { s.addMembership('224.0.0.114'); }); } ``` ### `socket.addSourceSpecificMembership(sourceAddress, groupAddress[, multicastInterface])` \* `sourceAddress` {string} \* `groupAddress` {string} \* `multicastInterface` {string} Tells the kernel to join a sourc...
https://github.com/nodejs/node/blob/main/doc/api/dgram.md
main
nodejs
[ -0.035120561718940735, -0.08966349810361862, -0.020348360762000084, -0.031483571976423264, -0.011396567337214947, 0.030124260112643242, 0.02917429432272911, 0.004613000899553299, -0.045034121721982956, -0.008097822777926922, -0.02933637611567974, -0.03894117474555969, 0.08217036724090576, ...
0.087621
`socket.bind()` method is not harmful but not very useful. The `options` object may contain an additional `exclusive` property that is used when using `dgram.Socket` objects with the [`cluster`][] module. When `exclusive` is set to `false` (the default), cluster workers will use the same underlying socket handle allowi...
https://github.com/nodejs/node/blob/main/doc/api/dgram.md
main
nodejs
[ -0.08070927113294601, -0.03249223157763481, 0.013657492585480213, 0.06852295249700546, -0.051985178142786026, -0.03474757820367813, -0.016875745728611946, -0.025338878855109215, 0.030906209722161293, 0.00003205369284842163, -0.0056024943478405476, 0.10979574918746948, 0.00047392802662216127,...
0.122729
Number of bytes queued for sending. ### `socket.getSendQueueCount()` \* Returns: {number} Number of send requests currently in the queue awaiting to be processed. ### `socket.ref()` \* Returns: {dgram.Socket} By default, binding a socket will cause it to block the Node.js process from exiting as long as the socket is o...
https://github.com/nodejs/node/blob/main/doc/api/dgram.md
main
nodejs
[ -0.07925929129123688, -0.044274572283029556, 0.03077874518930912, 0.07786253839731216, 0.002180875279009342, -0.037712011486291885, 0.02065517194569111, -0.041750818490982056, 0.11085326969623566, 0.045214150100946426, -0.07434934377670288, 0.09844924509525299, 0.004051432944834232, -0.079...
0.068781
a `DataView`. This method throws [`ERR\_SOCKET\_BAD\_PORT`][] if called on an unbound socket. Example of sending a UDP packet to a port on `localhost`; ```mjs import dgram from 'node:dgram'; import { Buffer } from 'node:buffer'; const message = Buffer.from('Some bytes'); const client = dgram.createSocket('udp4'); clien...
https://github.com/nodejs/node/blob/main/doc/api/dgram.md
main
nodejs
[ -0.01518190000206232, 0.007887736894190311, 0.07292404770851135, -0.05889328569173813, -0.056543655693531036, -0.07884317636489868, 0.005491509567946196, 0.05319695174694061, -0.003483997192233801, -0.009527250193059444, -0.03520682826638222, -0.004868536721915007, -0.023701753467321396, -...
0.079092
in this section are referring to [IPv6 Zone Indexes][], which are defined by [RFC 4007][]. In string form, an IP with a scope index is written as `'IP%scope'` where scope is an interface name or interface number.\_ Sets the default outgoing multicast interface of the socket to a chosen interface or back to system inter...
https://github.com/nodejs/node/blob/main/doc/api/dgram.md
main
nodejs
[ -0.0037247459404170513, -0.03845720365643501, 0.006342888344079256, -0.07210472971200943, -0.006644891574978828, 0.05296776443719864, 0.002029901370406151, -0.012684401124715805, -0.013504117727279663, -0.010387540794909, -0.04342825338244438, -0.003428412601351738, 0.0017978959949687123, ...
0.101199
maximum socket send buffer in bytes. This method throws [`ERR\_SOCKET\_BUFFER\_SIZE`][] if called on an unbound socket. ### `socket.setTTL(ttl)` \* `ttl` {integer} Sets the `IP\_TTL` socket option. While TTL generally stands for "Time to Live", in this context it specifies the number of IP hops that a packet is allowed...
https://github.com/nodejs/node/blob/main/doc/api/dgram.md
main
nodejs
[ -0.020784134045243263, -0.034139588475227356, -0.01973031461238861, -0.0037395877297967672, -0.05815745145082474, -0.06847840547561646, -0.0516529455780983, 0.010279509238898754, 0.08552706241607666, 0.0038242570590227842, -0.05038173124194145, 0.09363143146038055, -0.036207713186740875, -...
0.110852
to calling `.close()` on the socket: ```js const controller = new AbortController(); const { signal } = controller; const server = dgram.createSocket({ type: 'udp4', signal }); server.on('message', (msg, rinfo) => { console.log(`server got: ${msg} from ${rinfo.address}:${rinfo.port}`); }); // Later, when you want to cl...
https://github.com/nodejs/node/blob/main/doc/api/dgram.md
main
nodejs
[ -0.0405026450753212, -0.05032927170395851, 0.02131558023393154, 0.025607990100979805, -0.02099025808274746, -0.03028908744454384, 0.017910417169332504, 0.02139960043132305, 0.09574799239635468, 0.006455346941947937, -0.024172315374016762, 0.07417481392621994, -0.12388083338737488, -0.04150...
0.080554
# VM (executing JavaScript) > Stability: 2 - Stable The `node:vm` module enables compiling and running code within V8 Virtual Machine contexts. **The `node:vm` module is not a security mechanism. Do not use it to run untrusted code.** JavaScript code can be compiled and run immediately or compiled, saved, and run later...
https://github.com/nodejs/node/blob/main/doc/api/vm.md
main
nodejs
[ -0.027526935562491417, 0.027096111327409744, -0.02641500160098076, 0.05338738113641739, 0.08069952577352524, -0.0505274161696434, 0.0025950302369892597, 0.022002087906003, -0.01950341835618019, -0.052252430468797684, 0.00830735545605421, 0.00923252385109663, 0.016847524791955948, -0.062202...
0.114958
multiple times. The `code` is not bound to any global object; rather, it is bound before each run, just for that run. ### `script.cachedDataRejected` \* Type: {boolean|undefined} When `cachedData` is supplied to create the `vm.Script`, this value will be set to either `true` or `false` depending on acceptance of the da...
https://github.com/nodejs/node/blob/main/doc/api/vm.md
main
nodejs
[ -0.048994068056344986, 0.0013806833885610104, -0.034797534346580505, 0.03981352224946022, -0.0379580557346344, -0.04524902626872063, 0.00993574783205986, -0.019471172243356705, 0.03070664592087269, 0.006161843426525593, 0.0013187533477321267, 0.05797816812992096, -0.06523136794567108, -0.0...
0.050773
### `script.runInNewContext([contextObject[, options]])` \* `contextObject` {Object|vm.constants.DONT\\_CONTEXTIFY|undefined} Either [`vm.constants.DONT\_CONTEXTIFY`][] or an object that will be [contextified][]. If `undefined`, an empty contextified object will be created for backwards compatibility. \* `options` {Obj...
https://github.com/nodejs/node/blob/main/doc/api/vm.md
main
nodejs
[ -0.0323612354695797, 0.033462315797805786, -0.04057668149471283, 0.08391264826059341, 0.04057828709483147, -0.04991453140974045, 0.08437002450227737, 0.0517255999147892, -0.051455020904541016, -0.02433762140572071, 0.03585808351635933, -0.09969183802604675, 0.017179766669869423, -0.0075799...
0.10535
contextified object. // constants.DONT\_CONTEXTIFY allows creating contexts with ordinary // global objects that can be frozen. const freezeScript = new Script('Object.freeze(globalThis); globalThis;'); const frozenContext = freezeScript.runInNewContext(constants.DONT\_CONTEXTIFY); ``` ### `script.runInThisContext([opt...
https://github.com/nodejs/node/blob/main/doc/api/vm.md
main
nodejs
[ -0.05721749737858772, 0.022080518305301666, -0.02831110917031765, 0.09370236098766327, 0.04823717474937439, -0.04648733139038086, 0.0911940261721611, 0.08858637511730194, -0.040236327797174454, -0.04870580509305, 0.0065437923185527325, -0.08405245095491409, 0.03157246112823486, -0.03107483...
0.125831
s from 'foo'; s; print(s); `, { context: contextifiedObject }); // Step 2 // // "Link" the imported dependencies of this Module to it. // // Obtain the requested dependencies of a SourceTextModule by // `sourceTextModule.moduleRequests` and resolve them. // // Even top-level Modules without dependencies must be explici...
https://github.com/nodejs/node/blob/main/doc/api/vm.md
main
nodejs
[ -0.08290883153676987, 0.0022524769883602858, 0.015091173350811005, 0.06520292162895203, 0.031730540096759796, -0.01908283121883869, 0.050258710980415344, 0.03429330885410309, 0.017105761915445328, -0.049957774579524994, 0.02497652731835842, 0.03688732162117958, 0.015083860605955124, -0.003...
0.088237
module.linkRequests(requestedModules); } resolveAndLinkDependencies(rootModule); rootModule.instantiate(); // Step 3 // // Evaluate the Module. The evaluate() method returns a promise which will // resolve after the module has finished evaluating. // Prints 42. await rootModule.evaluate(); })(); ``` ### `module.error` ...
https://github.com/nodejs/node/blob/main/doc/api/vm.md
main
nodejs
[ -0.07046069204807281, 0.11726083606481552, -0.06539864093065262, 0.11206823587417603, 0.05588672682642937, -0.03588911145925522, -0.031152699142694473, 0.0942709669470787, -0.008091631345450878, -0.0516883060336113, 0.01282076071947813, -0.01430575456470251, 0.0386275015771389, 0.019179200...
0.095881
is `'errored'`), it will re-reject the exception that the initial evaluation resulted in. This method cannot be called while the module is being evaluated (`module.status` is `'evaluating'`). ### `module.identifier` \* Type: {string} The identifier of the current module, as set in the constructor. ### `module.link(link...
https://github.com/nodejs/node/blob/main/doc/api/vm.md
main
nodejs
[ -0.06147002428770065, 0.07322639971971512, 0.01038630586117506, 0.08077728003263474, 0.04494844377040863, -0.02293206751346588, 0.030009053647518158, 0.06324587762355804, -0.07990797609090805, -0.00978688895702362, 0.025465095415711403, -0.04793927073478699, 0.06790189445018768, -0.0106355...
0.057039
vm.SourceTextModule(code[, options])` \* `code` {string} JavaScript Module code to parse \* `options` \* `identifier` {string} String used in stack traces. \*\*Default:\*\* `'vm:module(i)'` where `i` is a context-specific ascending index. \* `cachedData` {Buffer|TypedArray|DataView} Provides an optional `Buffer` or `Ty...
https://github.com/nodejs/node/blob/main/doc/api/vm.md
main
nodejs
[ -0.05355853959918022, -0.014360294677317142, -0.048089586198329926, 0.03954007104039192, -0.05943441390991211, -0.029174616560339928, 0.088191919028759, 0.048329707235097885, -0.03330539911985397, -0.06930951774120331, 0.005887465551495552, -0.018720444291830063, -0.0682109147310257, -0.07...
0.069637
the first time. The code cache serializes the metadata that V8 currently knows about the `SourceTextModule` that it can use to speed up future compilations. ```js // Create an initial module const module = new vm.SourceTextModule('const a = 1;'); // Create cached data from this module const cachedData = module.createCa...
https://github.com/nodejs/node/blob/main/doc/api/vm.md
main
nodejs
[ -0.08131549507379532, 0.03976312279701233, -0.03219883143901825, 0.041718464344739914, -0.00991690345108509, -0.05194559320807457, 0.003427582560107112, 0.01791100762784481, -0.00897708348929882, -0.03824526444077492, 0.004827335011214018, 0.00846909824758768, -0.027001764625310898, -0.059...
0.078384
will be: ```js [ { specifier: 'foo', attributes: {}, phase: 'evaluation', }, { specifier: 'foo', attributes: {}, phase: 'evaluation', }, { specifier: './bar.js', attributes: {}, phase: 'evaluation', }, { specifier: '../with-attrs.ts', attributes: { arbitraryAttr: 'attr-val' }, phase: 'evaluation', }, { specifier: 'wasm...
https://github.com/nodejs/node/blob/main/doc/api/vm.md
main
nodejs
[ -0.1274404227733612, 0.06647779792547226, -0.01359693706035614, 0.0786525085568428, 0.09036650508642197, -0.005200535990297794, -0.007017327472567558, 0.006305573508143425, -0.08220700174570084, -0.023869814351201057, 0.0047019780613482, -0.06004849448800087, 0.016164962202310562, 0.033227...
0.13829
supplied source. This must be produced by a prior call to [`vm.compileFunction()`][] with the same `code` and `params`. \* `produceCachedData` {boolean} Specifies whether to produce new cache data. \*\*Default:\*\* `false`. \* `parsingContext` {Object} The [contextified][] object in which the said function should be co...
https://github.com/nodejs/node/blob/main/doc/api/vm.md
main
nodejs
[ -0.03980540111660957, 0.056390028446912766, -0.06709359586238861, 0.06349275261163712, -0.007086711470037699, -0.07453588396310806, 0.085494764149189, 0.013792695477604866, -0.05892271548509598, -0.0208611860871315, 0.0052003152668476105, -0.043586257845163345, -0.02901141345500946, -0.012...
0.091573
remain unchanged. ```mjs import { createContext, runInContext } from 'node:vm'; global.globalVar = 3; const context = { globalVar: 1 }; createContext(context); runInContext('globalVar \*= 2;', context); console.log(context); // Prints: { globalVar: 2 } console.log(global.globalVar); // Prints: 3 ``` ```cjs const { crea...
https://github.com/nodejs/node/blob/main/doc/api/vm.md
main
nodejs
[ -0.0035971796605736017, 0.017665989696979523, 0.0054955920204520226, 0.11153671145439148, 0.06182096526026726, -0.020821986719965935, 0.04864757880568504, -0.02629443258047104, 0.02066989615559578, -0.047151606529951096, 0.04220593720674515, -0.0506465770304203, 0.007058830000460148, -0.00...
0.033959
}).then((result) => { // Reference the context here so that it won't be GC'ed // until the measurement is complete. console.log('Context:', context.a); // { // total: { jsMemoryEstimate: 1767100, jsMemoryRange: [1767100, 5440560] }, // WebAssembly: { code: 0, metadata: 33962 }, // current: { jsMemoryEstimate: 1601828, ...
https://github.com/nodejs/node/blob/main/doc/api/vm.md
main
nodejs
[ -0.031136654317378998, 0.10071272403001785, -0.029923580586910248, 0.06256353855133057, -0.028922272846102715, -0.002144566737115383, 0.06461495906114578, 0.06050654128193855, 0.04969220235943794, -0.005545375403016806, -0.012143537402153015, -0.03797262907028198, -0.03853077441453934, -0....
0.068977
If `options` is a string, then it specifies the filename. The following example compiles and executes different scripts using a single [contextified][] object: ```mjs import { createContext, runInContext } from 'node:vm'; const contextObject = { globalVar: 1 }; createContext(contextObject); for (let i = 0; i < 10; ++i)...
https://github.com/nodejs/node/blob/main/doc/api/vm.md
main
nodejs
[ -0.024339398369193077, 0.030155468732118607, -0.032304517924785614, 0.057200103998184204, 0.03347019478678703, -0.01604892499744892, 0.0610610693693161, 0.09939660876989365, -0.007193558383733034, -0.057697854936122894, 0.006615190766751766, -0.028775865212082863, -0.029883379116654396, 0....
0.066403
of this script when `import()` is called. This option is part of the experimental modules API. We do not recommend using it in a production environment. For detailed information, see [Support of dynamic `import()` in compilation APIs][]. \* `microtaskMode` {string} If set to `afterEvaluate`, microtasks (tasks scheduled...
https://github.com/nodejs/node/blob/main/doc/api/vm.md
main
nodejs
[ -0.0973169356584549, 0.040411144495010376, -0.05850223824381828, 0.1081269159913063, 0.06777773797512054, -0.02712489292025566, 0.01088563073426485, 0.03940534591674805, -0.028529206290841103, -0.013560038059949875, 0.040388576686382294, -0.010729565285146236, -0.017094604671001434, -0.002...
0.146518
that have been attached via `process.on('SIGINT')` are disabled during script execution, but continue to work after that. \*\*Default:\*\* `false`. \* `cachedData` {Buffer|TypedArray|DataView} Provides an optional `Buffer` or `TypedArray`, or `DataView` with V8's code cache data for the supplied source. \* `importModul...
https://github.com/nodejs/node/blob/main/doc/api/vm.md
main
nodejs
[ -0.047421593219041824, -0.01193139236420393, -0.03706766664981842, 0.05519956722855568, 0.013525345362722874, -0.03559955954551697, 0.06265130639076233, 0.05635490640997887, -0.049747172743082047, -0.071144700050354, 0.0404386930167675, -0.00842262338846922, -0.03480573743581772, 0.0012125...
0.090299
> JavaScript applications to run in a single instance of V8. You must explicitly > specify the context in which you want any JavaScript code to be run. When the method `vm.createContext()` is called with an object, the `contextObject` argument will be used to wrap the global object of a new instance of a V8 Context (if...
https://github.com/nodejs/node/blob/main/doc/api/vm.md
main
nodejs
[ -0.0429544635117054, -0.04083654657006264, 0.002279717708006501, 0.03541437163949013, 0.05410146340727806, -0.025573356077075005, -0.009923980571329594, 0.06489045172929764, -0.04566236585378647, -0.09606514871120453, -0.02487536519765854, -0.03586355224251747, -0.006258567329496145, -0.04...
0.071123
console.log(context.foo); // 1 context.bar = 1; console.log(runInContext('bar;', context)); // 1 // Can be frozen and it affects the inner context. Object.freeze(context); try { runInContext('baz = 1; baz;', context); } catch (e) { console.log(`${e.constructor.name}: ${e.message}`); // ReferenceError: baz is not define...
https://github.com/nodejs/node/blob/main/doc/api/vm.md
main
nodejs
[ -0.025257570669054985, 0.01866994798183441, -0.011991525068879128, 0.07465241104364395, 0.05117310956120491, -0.018132155761122704, 0.08721429854631424, 0.015876000747084618, 0.02723468653857708, -0.06145457923412323, 0.016363661736249924, -0.07088232040405273, -0.0224258154630661, -0.0108...
0.041894
outer (main) context. While this mode is necessary to enforce `timeout` and enable `breakOnSigint` with asynchronous tasks, it also makes sharing promises between contexts challenging. In the example below, a promise is created in the inner context and shared with the outer context. When the outer context `await` on th...
https://github.com/nodejs/node/blob/main/doc/api/vm.md
main
nodejs
[ -0.07979319989681244, 0.008626068942248821, 0.05133001133799553, 0.10096176713705063, 0.06845829635858536, -0.058277830481529236, -0.014138108119368553, 0.03436344861984253, 0.06675071269273758, -0.011852895841002464, -0.014903719536960125, -0.037105124443769455, 0.02144930325448513, -0.01...
0.06166
and it actually calls `import()`, the result will reject with [`ERR\_VM\_DYNAMIC\_IMPORT\_CALLBACK\_MISSING`][]. ### When `importModuleDynamically` is `vm.constants.USE\_MAIN\_CONTEXT\_DEFAULT\_LOADER` This option is currently not supported for `vm.SourceTextModule`. With this option, when an `import()` is initiated in...
https://github.com/nodejs/node/blob/main/doc/api/vm.md
main
nodejs
[ -0.061707381159067154, 0.026842741295695305, -0.011559533886611462, 0.086652472615242, 0.09766153246164322, -0.017049644142389297, -0.003524485742673278, 0.04209738224744797, -0.018371624872088432, -0.04852360859513283, 0.00611082324758172, -0.003283220110461116, 0.027806270867586136, -0.0...
0.086126
given `filename` that resolves to a specific path, once the process manages to load a particular module from that path, the result may be cached, and subsequent load of the same module from the same path would return the same thing. If the `filename` is a URL string, the cache would not be hit if it has different searc...
https://github.com/nodejs/node/blob/main/doc/api/vm.md
main
nodejs
[ -0.09980829805135727, 0.007952183485031128, -0.0010880549671128392, 0.0663607120513916, 0.05602792650461197, -0.0800372064113617, -0.004047552589327097, -0.002028234302997589, 0.014698975719511509, -0.04521198198199272, -0.009066480211913586, 0.09422563016414642, -0.0022178778890520334, -0...
0.034419
# C++ addons \_Addons\_ are dynamically-linked shared objects that can be loaded via the [`require()`][] function as ordinary Node.js modules. Addons provide a foreign function interface between JavaScript and native code. There are three options for implementing addons: \* [Node-API][] (recommended) \* `nan` ([Native ...
https://github.com/nodejs/node/blob/main/doc/api/addons.md
main
nodejs
[ -0.14453549683094025, -0.04389285668730736, 0.009620770812034607, 0.020394496619701385, 0.056827496737241745, 0.008760122582316399, -0.04062400013208389, 0.04734287038445473, 0.016873488202691078, -0.07511835545301437, 0.010915244929492474, 0.018536237999796867, -0.06514161825180054, -0.03...
0.164143
to behave correctly when loaded via `require()`. This means that the addon must support multiple initializations. A context-aware addon can be constructed by using the macro `NODE\_MODULE\_INITIALIZER`, which expands to the name of a function which Node.js will expect to find when it loads an addon. An addon can thus b...
https://github.com/nodejs/node/blob/main/doc/api/addons.md
main
nodejs
[ -0.10179249942302704, -0.029771706089377403, 0.012523389421403408, 0.05965067818760872, 0.005701662972569466, -0.00519953016191721, 0.005673792213201523, 0.06282299757003784, -0.028002502396702766, -0.06959057599306107, 0.04837505519390106, -0.04375569894909859, -0.0574580654501915, 0.0085...
0.041003
in a `v8::External` so we can pass it to the method we // expose. Local external = External::New(isolate, data); // Expose the method `Method` to JavaScript, and make sure it receives the // per-addon-instance data we created above by passing `external` as the // third parameter to the `FunctionTemplate` constructor. e...
https://github.com/nodejs/node/blob/main/doc/api/addons.md
main
nodejs
[ -0.08906516432762146, -0.028179099783301353, 0.022670840844511986, 0.042627301067113876, 0.06886041164398193, -0.004584722686558962, 0.0011037421645596623, 0.08151034265756607, -0.029027890413999557, -0.005265287589281797, -0.030077293515205383, -0.013477259315550327, -0.10605749487876892, ...
0.06786
`addon.node` file. This will be put into the `build/Release/` directory. When using `npm install` to install a Node.js addon, npm uses its own bundled version of `node-gyp` to perform this same set of actions, generating a compiled version of the addon for the user's platform on demand. Once built, the binary addon can...
https://github.com/nodejs/node/blob/main/doc/api/addons.md
main
nodejs
[ -0.08676555007696152, -0.006390284281224012, 0.00470361253246665, 0.04062603414058685, 0.06780044734477997, -0.05329814553260803, -0.0229289960116148, 0.06129445508122444, 0.023376455530524254, 0.006239537615329027, 0.036817263811826706, 0.035634804517030716, -0.0943143218755722, -0.011197...
0.102727
to continue functioning. The Node.js release schedule is designed to minimize the frequency and impact of such changes but there is little that Node.js can do to ensure stability of the V8 APIs. The [Native Abstractions for Node.js][] (or `nan`) provide a set of tools that addon developers are recommended to use to kee...
https://github.com/nodejs/node/blob/main/doc/api/addons.md
main
nodejs
[ -0.13238726556301117, -0.031706396490335464, 0.04720558598637581, 0.022061992436647415, 0.061829645186662674, -0.04620148241519928, -0.09324488043785095, 0.028836257755756378, 0.001141875283792615, -0.03249641880393028, -0.044404350221157074, 0.09184171259403229, -0.07579293847084045, -0.0...
0.107189
`Init()` that receives the full `module` object as the second argument. This allows the addon to completely overwrite `exports` with a single function instead of adding the function as a property of `exports`. To test it, run the following JavaScript: ```js // test.js const addon = require('./build/Release/addon'); add...
https://github.com/nodejs/node/blob/main/doc/api/addons.md
main
nodejs
[ -0.1434781849384308, -0.0033093674574047327, -0.03439931571483612, 0.0968509241938591, 0.007060015108436346, -0.022204076871275902, 0.01493681687861681, 0.004284923430532217, 0.03302169591188431, -0.041067808866500854, 0.0821407288312912, -0.024457640945911407, -0.08665961772203445, -0.056...
0.082244
exports->Set(context, String::NewFromUtf8( isolate, "MyObject").ToLocalChecked(), constructor).FromJust(); } void MyObject::New(const FunctionCallbackInfo& args) { Isolate\* isolate = args.GetIsolate(); Local context = isolate->GetCurrentContext(); if (args.IsConstructCall()) { // Invoked as constructor: `new MyObject(...
https://github.com/nodejs/node/blob/main/doc/api/addons.md
main
nodejs
[ 0.013627320528030396, 0.030970118939876556, -0.08164035528898239, 0.0470292791724205, -0.07326558232307434, 0.024483177810907364, 0.09795060753822327, 0.10372313112020493, 0.010919935069978237, -0.027239985764026642, -0.030683808028697968, -0.13331151008605957, -0.08261103928089142, 0.0120...
0.091493
Isolate\* isolate = args.GetIsolate(); Local context = isolate->GetCurrentContext(); if (args.IsConstructCall()) { // Invoked as constructor: `new MyObject(...)` double value = args[0]->IsUndefined() ? 0 : args[0]->NumberValue(context).FromMaybe(0); MyObject\* obj = new MyObject(value); obj->Wrap(args.This()); args.Get...
https://github.com/nodejs/node/blob/main/doc/api/addons.md
main
nodejs
[ -0.03374219313263893, 0.04407629743218422, -0.09536124765872955, 0.05666504427790642, -0.08321158587932587, 0.015810944139957428, 0.08805479109287262, 0.0608464777469635, -0.026284130290150642, -0.06075600907206535, -0.021853694692254066, -0.144239142537117, -0.058260176330804825, 0.045818...
0.118346
{ // Invoked as plain function `MyObject(...)`, turn into construct call. const int argc = 1; Local argv[argc] = { args[0] }; Local cons = Local::New(isolate, constructor); Local instance = cons->NewInstance(context, argc, argv).ToLocalChecked(); args.GetReturnValue().Set(instance); } } void MyObject::NewInstance(const...
https://github.com/nodejs/node/blob/main/doc/api/addons.md
main
nodejs
[ -0.04213332012295723, 0.005269458517432213, -0.09934021532535553, 0.04196513071656227, -0.0805591344833374, -0.03798292577266693, 0.08416642993688583, 0.05558761581778526, -0.040250591933727264, -0.03484030440449715, -0.024753674864768982, -0.11890721321105957, -0.06020735949277878, 0.0162...
0.124439
# Environment Variables Environment variables are variables associated to the environment the Node.js process runs in. ## CLI Environment Variables There is a set of environment variables that can be defined to customize the behavior of Node.js, for more details refer to the [CLI Environment Variables documentation][]....
https://github.com/nodejs/node/blob/main/doc/api/environment_variables.md
main
nodejs
[ -0.03657970577478409, -0.02729162573814392, 0.001722391345538199, -0.0076792677864432335, 0.076112300157547, -0.061063140630722046, 0.023248659446835518, 0.042744945734739304, 0.004173061344772577, -0.010709020309150219, -0.08286454528570175, 0.053951337933540344, 0.0361793227493763, -0.02...
0.131139
my variable b ' ``` #### Comments Hash-tag (`#`) characters denote the beginning of a comment, meaning that the rest of the line will be completely ignored. Hash-tags found within quotes are however treated as any other standard character. For example: ```text # This is a comment MY\_VAR = my variable # This is also a ...
https://github.com/nodejs/node/blob/main/doc/api/environment_variables.md
main
nodejs
[ -0.06446859240531921, 0.002104638610035181, -0.006805269978940487, 0.027829362079501152, 0.008773407898843288, -0.03385654091835022, 0.0831775888800621, 0.011295502074062824, 0.020526478067040443, 0.03400496393442154, -0.026910144835710526, 0.031221896409988403, 0.08481091260910034, -0.016...
-0.040302
# Modules: TypeScript > Stability: 2 - Stable ## Enabling There are two ways to enable runtime TypeScript support in Node.js: 1. For [full support][] of all of TypeScript's syntax and features, including using any version of TypeScript, use a third-party package. 2. For lightweight support, you can use the built-in sup...
https://github.com/nodejs/node/blob/main/doc/api/typescript.md
main
nodejs
[ -0.0503762848675251, -0.022519217804074287, 0.04245443269610405, 0.057039178907871246, 0.0018786946311593056, 0.03522789105772972, 0.022780917584896088, 0.08906993269920349, -0.07892551273107529, 0.043421849608421326, -0.11969243735074997, 0.08099853992462158, -0.05950210615992546, 0.06414...
0.152274
require transformation are: \* `Enum` declarations \* `namespace` with runtime code \* parameter properties \* import aliases `namespace`s that do not contain runtime code are supported. This example will work correctly: ```ts // This namespace is exporting a type namespace TypeOnly { export type A = string; } ``` This...
https://github.com/nodejs/node/blob/main/doc/api/typescript.md
main
nodejs
[ -0.11596409976482391, -0.011695854365825653, 0.05972849577665329, 0.038619447499513626, 0.013422715477645397, -0.037226758897304535, 0.00534824188798666, 0.0032773835118860006, -0.04795236513018608, 0.040722910314798355, -0.06319993734359741, -0.036376893520355225, -0.001316503738053143, 0...
0.084584
# Util > Stability: 2 - Stable The `node:util` module supports the needs of Node.js internal APIs. Many of the utilities are useful for application and module developers as well. To access it: ```mjs import util from 'node:util'; ``` ```cjs const util = require('node:util'); ``` ## `util.callbackify(original)` \* `orig...
https://github.com/nodejs/node/blob/main/doc/api/util.md
main
nodejs
[ -0.1623135656118393, 0.025991573929786682, 0.0009367865277454257, 0.10116611421108246, 0.0015637228498235345, -0.039341963827610016, -0.03337523713707924, 0.06296228617429733, 0.05172570049762726, -0.05702706798911095, -0.057515423744916916, 0.051146410405635834, 0.007485106587409973, -0.0...
0.155261
{Function} The logging function The `util.debuglog()` method is used to create a function that conditionally writes debug messages to `stderr` based on the existence of the `NODE\_DEBUG` environment variable. If the `section` name appears within the value of that environment variable, then the returned function operate...
https://github.com/nodejs/node/blob/main/doc/api/util.md
main
nodejs
[ -0.027849679812788963, 0.04202824458479881, 0.08768773823976517, 0.04522907733917236, 0.03558282554149628, -0.10922408849000931, 0.027504418045282364, 0.030433159321546555, 0.02926529571413994, -0.011663755401968956, -0.042434122413396835, -0.049611590802669525, 0.011324443854391575, -0.00...
0.042896
import { deprecate } from 'node:util'; export const obsoleteFunction = deprecate(() => { // Do something here. }, 'obsoleteFunction() is deprecated. Use newShinyFunction() instead.'); ``` ```cjs const { deprecate } = require('node:util'); exports.obsoleteFunction = deprecate(() => { // Do something here. }, 'obsoleteFu...
https://github.com/nodejs/node/blob/main/doc/api/util.md
main
nodejs
[ -0.06230679526925087, 0.0731310024857521, 0.07145023345947266, 0.057246189564466476, 0.04398084431886673, -0.010087285190820694, -0.02559264563024044, 0.049524348229169846, 0.053137876093387604, -0.022620661184191704, 0.016553090885281563, 0.008536407724022865, -0.033804990351200104, -0.04...
0.105171
Comparing arrays const actualArray = ['1', '2', '3']; const expectedArray = ['1', '3', '4']; console.log(diff(actualArray, expectedArray)); // [ // [0, '1'], // [1, '2'], // [0, '3'], // [-1, '4'], // ] // Equal values return empty array console.log(diff('same', 'same')); // [] ``` ## `util.format(format[, ...args])` \...
https://github.com/nodejs/node/blob/main/doc/api/util.md
main
nodejs
[ 0.029977288097143173, 0.04949174076318741, -0.025933511555194855, -0.025823548436164856, -0.050290077924728394, -0.08131615817546844, 0.056347500532865524, 0.021933190524578094, -0.00312790647149086, -0.02811286598443985, -0.11605916172266006, 0.01806935854256153, -0.0036723685916513205, 0...
0.055453
to capture as call site objects. \*\*Default:\*\* `10`. Allowable range is between 1 and 200. \* `options` {Object} Optional \* `sourceMap` {boolean} Reconstruct the original location in the stacktrace from the source-map. Enabled by default with the flag `--enable-source-maps`. \* Returns: {Object\[]} An array of call...
https://github.com/nodejs/node/blob/main/doc/api/util.md
main
nodejs
[ -0.0633467435836792, -0.02310854010283947, -0.04172952473163605, 0.04483548924326897, 0.06684934347867966, -0.06387066841125488, 0.018212461844086647, 0.04089662432670593, 0.048141222447156906, -0.06592944264411926, -0.041297610849142075, -0.05923917144536972, -0.0525190494954586, -0.09283...
0.056715
{Map} Returns a Map of all system error codes available from the Node.js API. The mapping between error codes and error names is platform-dependent. See [Common System Errors][] for the names of common errors. ```js fs.access('file/that/does/not/exist', (err) => { const errorMap = util.getSystemErrorMap(); const name =...
https://github.com/nodejs/node/blob/main/doc/api/util.md
main
nodejs
[ -0.012420720420777798, 0.03935651853680611, -0.0006681916420347989, -0.0035299493465572596, 0.07776682823896408, -0.045919325202703476, -0.002906858455389738, 0.13417039811611176, 0.044393911957740784, -0.023429561406373978, 0.0037241082172840834, 0.019328059628605843, 0.030191393569111824, ...
0.181604
or negative to show no characters. \*\*Default:\*\* `10000`. \* `breakLength` {integer} The length at which input values are split across multiple lines. Set to `Infinity` to format the input as a single line (in combination with `compact` set to `true` or any number >= `1`). \*\*Default:\*\* `80`. \* `compact` {boolea...
https://github.com/nodejs/node/blob/main/doc/api/util.md
main
nodejs
[ 0.00492068799212575, 0.05294179916381836, -0.008118442259728909, 0.025917595252394676, -0.11252802610397339, 0.004483894445002079, 0.01236808579415083, 0.005749689415097237, -0.0466955192387104, -0.016946861520409584, -0.018923133611679077, -0.008390798233449459, 0.07740660756826401, -0.05...
0.128728
[ 'Lorem ipsum dolor sit amet,\nconsectetur [...]', // A long line // 'test', // 'foo' ] ], // 4 ], // b: Map(2) { 'za' => 1, 'zb' => 'test' } } // Setting `compact` to false or an integer creates more reader friendly output. console.log(inspect(o, { compact: false, depth: 5, breakLength: 80 })); // { // a: [ // 1, // ...
https://github.com/nodejs/node/blob/main/doc/api/util.md
main
nodejs
[ 0.02459138073027134, 0.13493165373802185, 0.005777080077677965, -0.050174519419670105, -0.06920508295297623, -0.05016579106450081, 0.036653123795986176, 0.05658397823572159, -0.0023028040304780006, 0.008659090846776962, 0.008749756030738354, -0.019637949764728546, 0.034149616956710815, -0....
0.140505
{ 1, 2, 3 } } console.log(inspect(o1, { sorted: (a, b) => b.localeCompare(a) })); // { c: Set(3) { 3, 2, 1 }, b: [ 2, 3, 1 ], a: '`a` comes before `b`' } const o2 = { c: new Set([2, 1, 3]), a: '`a` comes before `b`', b: [2, 3, 1], }; assert.strict.equal( inspect(o1, { sorted: true }), inspect(o2, { sorted: true }), ); ...
https://github.com/nodejs/node/blob/main/doc/api/util.md
main
nodejs
[ -0.06016672030091286, 0.04670589789748192, 0.04595823213458061, 0.014054007828235626, 0.022737154737114906, -0.061528440564870834, 0.0014941724948585033, -0.03550050035119057, -0.0002480770635884255, -0.03000554069876671, -0.04027300700545311, 0.012150130234658718, 0.0008733288268558681, -...
0.044697
be ignored, if not supported. \* `reset` - Resets all (color) modifiers to their defaults \* \*\*bold\*\* - Make text bold \* \_italic\_ - Make text italic \* underline - Make text underlined \* ~~strikethrough~~ - Puts a horizontal line through the center of the text (Alias: `strikeThrough`, `crossedout`, `crossedOut`...
https://github.com/nodejs/node/blob/main/doc/api/util.md
main
nodejs
[ -0.07494660466909409, 0.02721262164413929, -0.008890349417924881, 0.1014927327632904, 0.03796908259391785, 0.02529178373515606, 0.09042850136756897, 0.004262963775545359, 0.003210747381672263, -0.07530152052640915, 0.005886100232601166, 0.032404374331235886, 0.05011815205216408, -0.0622855...
0.07568
custom inspect function is used in an Node.js environment and ignored in the browser. The `util.inspect()` function itself is passed as third argument to the custom inspect function to allow further portability. ```js const customInspectSymbol = Symbol.for('nodejs.util.inspect.custom'); class Password { constructor(val...
https://github.com/nodejs/node/blob/main/doc/api/util.md
main
nodejs
[ -0.048414718359708786, 0.07649309188127518, -0.022675635293126106, 0.017554491758346558, 0.027961930260062218, -0.02247852459549904, 0.02460993267595768, 0.03614502772688866, 0.04569758102297783, 0.029146336019039154, -0.03004024736583233, 0.045364804565906525, -0.03291952610015869, -0.042...
0.084925
} = require('node:util'); const myMIME = new MIMEType('text/javascript'); console.log(myMIME.type); // Prints: text myMIME.type = 'application'; console.log(myMIME.type); // Prints: application console.log(String(myMIME)); // Prints: application/javascript ``` ### `mime.subtype` \* Type: {string} Gets and sets the subt...
https://github.com/nodejs/node/blob/main/doc/api/util.md
main
nodejs
[ -0.05548132583498955, 0.009549577720463276, 0.09345968067646027, 0.05419961363077164, 0.02931268699467182, -0.08064841479063034, 0.06146952137351036, 0.1646299809217453, 0.0015672319568693638, -0.10985203087329865, -0.03468797355890274, -0.012537640519440174, 0.00035527037107385695, 0.0811...
0.142928
bar ``` ### `mimeParams.set(name, value)` \* `name` {string} \* `value` {string} Sets the value in the `MIMEParams` object associated with `name` to `value`. If there are any pre-existing name-value pairs whose names are `name`, set the first such pair's value to `value`. ```mjs import { MIMEType } from 'node:util'; co...
https://github.com/nodejs/node/blob/main/doc/api/util.md
main
nodejs
[ -0.05949430167675018, 0.02132701873779297, 0.003871271852403879, 0.07110638916492462, -0.11230101436376572, -0.02465951070189476, 0.11006804555654526, 0.10889118909835815, -0.028470410034060478, -0.08548207581043243, -0.029707171022892, 0.015441382303833961, 0.09692752361297607, 0.04270258...
0.056845
const options = { foo: { type: 'boolean', short: 'f', }, bar: { type: 'string', }, }; const { values, positionals, } = parseArgs({ args, options }); console.log(values, positionals); // Prints: [Object: null prototype] { foo: true, bar: 'b' } [] ``` ```cjs const { parseArgs } = require('node:util'); const args = ['-f',...
https://github.com/nodejs/node/blob/main/doc/api/util.md
main
nodejs
[ -0.009351935237646103, 0.041012153029441833, 0.048193663358688354, 0.012958966195583344, -0.04244857653975487, 0.004198855254799128, 0.04016230255365372, 0.02535868249833584, 0.010347513481974602, -0.05146586894989014, -0.02538726106286049, -0.00031698407838121057, -0.06585510820150375, 0....
-0.014889