content large_stringlengths 3 20.5k | url large_stringlengths 54 193 | branch large_stringclasses 4
values | source large_stringclasses 42
values | embeddings listlengths 384 384 | score float64 -0.21 0.65 |
|---|---|---|---|---|---|
```cjs const { Buffer } = require('node:buffer'); Buffer.isBuffer(Buffer.alloc(10)); // true Buffer.isBuffer(Buffer.from('foo')); // true Buffer.isBuffer('a string'); // false Buffer.isBuffer([]); // false Buffer.isBuffer(new Uint8Array(1024)); // false ``` ### Static method: `Buffer.isEncoding(encoding)` \* `encoding`... | https://github.com/nodejs/node/blob/main//doc/api/buffer.md | main | nodejs | [
0.04868766665458679,
0.007369087543338537,
-0.02847638912498951,
-0.022313760593533516,
-0.05388377606868744,
-0.028448237106204033,
0.040288295596838,
0.013337052427232265,
0.009458938613533974,
-0.04719369113445282,
-0.041725315153598785,
-0.03562844172120094,
0.0008323188521899283,
0.03... | 0.085892 |
2, 3, 4, 5, 6, 7, 8, 9]); // When casting the Node.js Buffer to an Int8Array, use the byteOffset // to refer only to the part of `nodeBuffer.buffer` that contains the memory // for `nodeBuffer`. new Int8Array(nodeBuffer.buffer, nodeBuffer.byteOffset, nodeBuffer.length); ``` ```cjs const { Buffer } = require('node:buffe... | https://github.com/nodejs/node/blob/main//doc/api/buffer.md | main | nodejs | [
0.03755964711308479,
0.03675057366490364,
-0.0038883814122527838,
-0.03591778501868248,
-0.04053405672311783,
-0.003738719504326582,
0.05599503591656685,
0.0867205560207367,
-0.007308810018002987,
-0.0729801282286644,
-0.1681147813796997,
0.008979937061667442,
-0.06359553337097168,
-0.0383... | 0.080023 |
within `buf` from which to begin copying. \*\*Default:\*\* `0`. \* `sourceEnd` {integer} The offset within `buf` at which to stop copying (not inclusive). \*\*Default:\*\* [`buf.length`][]. \* Returns: {integer} The number of bytes copied. Copies data from a region of `buf` to a region in `target`, even if the `target`... | https://github.com/nodejs/node/blob/main//doc/api/buffer.md | main | nodejs | [
0.0285232774913311,
0.006145319901406765,
-0.024373216554522514,
-0.014440475963056087,
-0.05887604504823685,
-0.020473264157772064,
0.06089170649647713,
-0.04502243548631668,
0.009431665763258934,
-0.0834982767701149,
-0.08401035517454147,
0.01988024264574051,
0.0016542513621971011,
-0.06... | 0.133928 |
buf1 = Buffer.from('ABC'); const buf2 = Buffer.from('414243', 'hex'); const buf3 = Buffer.from('ABCD'); console.log(buf1.equals(buf2)); // Prints: true console.log(buf1.equals(buf3)); // Prints: false ``` ### `buf.fill(value[, offset[, end]][, encoding])` \* `value` {string|Buffer|Uint8Array|integer} The value with whi... | https://github.com/nodejs/node/blob/main//doc/api/buffer.md | main | nodejs | [
0.06937795877456665,
0.03828395530581474,
-0.05330377444624901,
-0.04743829742074013,
-0.125514417886734,
-0.016082853078842163,
0.07999890297651291,
0.03663863614201546,
0.013121330179274082,
-0.11086844652891159,
-0.10042978078126907,
-0.0540139302611351,
0.00849161110818386,
-0.02545796... | 0.066654 |
\* `value` {string|Buffer|Uint8Array|integer} What to search for. \* `byteOffset` {integer} Where to begin searching in `buf`. If negative, then offset is calculated from the end of `buf`. \*\*Default:\*\* `0`. \* `encoding` {string} If `value` is a string, this is the encoding used to determine the binary representati... | https://github.com/nodejs/node/blob/main//doc/api/buffer.md | main | nodejs | [
0.024600833654403687,
0.05123703554272652,
-0.05460584908723831,
-0.048293065279722214,
-0.08983836323022842,
-0.026935184374451637,
0.08776134997606277,
0.02808757685124874,
-0.0044743954204022884,
-0.11577882617712021,
-0.07731182128190994,
-0.035109955817461014,
0.032188743352890015,
-0... | 0.073682 |
Buffer } = require('node:buffer'); const buf = Buffer.from('buffer'); for (const key of buf.keys()) { console.log(key); } // Prints: // 0 // 1 // 2 // 3 // 4 // 5 ``` ### `buf.lastIndexOf(value[, byteOffset][, encoding])` \* `value` {string|Buffer|Uint8Array|integer} What to search for. \* `byteOffset` {integer} Where ... | https://github.com/nodejs/node/blob/main//doc/api/buffer.md | main | nodejs | [
0.045303113758563995,
0.07128848135471344,
-0.044750943779945374,
-0.0036289661657065153,
-0.033969033509492874,
0.00392446992918849,
0.0872262716293335,
0.04556899517774582,
-0.008194971829652786,
-0.10333988815546036,
-0.06448356062173843,
-0.008956247009336948,
0.0028141841758042574,
-0... | 0.088908 |
'utf8'); console.log(buf.length); // Prints: 1234 ``` ```cjs const { Buffer } = require('node:buffer'); // Create a `Buffer` and write a shorter string to it using UTF-8. const buf = Buffer.alloc(1234); console.log(buf.length); // Prints: 1234 buf.write('some string', 0, 'utf8'); console.log(buf.length); // Prints: 123... | https://github.com/nodejs/node/blob/main//doc/api/buffer.md | main | nodejs | [
0.03965606912970543,
0.01829862780869007,
-0.01415934693068266,
-0.01849093660712242,
-0.05545350909233093,
0.03286955505609512,
0.0061503504402935505,
0.08588617295026779,
0.03009004332125187,
-0.06007545441389084,
-0.03925403207540512,
-0.028233136981725693,
-0.03697686269879341,
-0.0384... | 0.030838 |
`0 <= offset <= buf.length - 4`. \*\*Default:\*\* `0`. \* Returns: {number} Reads a 32-bit, big-endian float from `buf` at the specified `offset`. ```mjs import { Buffer } from 'node:buffer'; const buf = Buffer.from([1, 2, 3, 4]); console.log(buf.readFloatBE(0)); // Prints: 2.387939260590663e-38 ``` ```cjs const { Buff... | https://github.com/nodejs/node/blob/main//doc/api/buffer.md | main | nodejs | [
0.052872490137815475,
0.010531388223171234,
-0.04189331457018852,
-0.027686215937137604,
-0.019671428948640823,
-0.03549276292324066,
0.023261385038495064,
0.04153188318014145,
0.005041321739554405,
-0.04977553337812424,
-0.07961103320121765,
-0.04225712642073631,
-0.01289327908307314,
-0.... | 0.039433 |
integer from `buf` at the specified `offset`. Integers read from a `Buffer` are interpreted as two's complement signed values. ```mjs import { Buffer } from 'node:buffer'; const buf = Buffer.from([0, 0, 0, 5]); console.log(buf.readInt32LE(0)); // Prints: 83886080 console.log(buf.readInt32LE(1)); // Throws ERR\_OUT\_OF\... | https://github.com/nodejs/node/blob/main//doc/api/buffer.md | main | nodejs | [
0.05655625835061073,
0.03350547328591347,
-0.020878836512565613,
-0.024794962257146835,
0.0008483132114633918,
-0.030513620004057884,
0.04232444241642952,
0.092891626060009,
0.00035170683986507356,
-0.06867718696594238,
-0.08624137938022614,
-0.013373012654483318,
0.01470138505101204,
-0.0... | 0.077573 |
available under the `readUint16LE` alias. ```mjs import { Buffer } from 'node:buffer'; const buf = Buffer.from([0x12, 0x34, 0x56]); console.log(buf.readUInt16LE(0).toString(16)); // Prints: 3412 console.log(buf.readUInt16LE(1).toString(16)); // Prints: 5634 console.log(buf.readUInt16LE(2).toString(16)); // Throws ERR\_... | https://github.com/nodejs/node/blob/main//doc/api/buffer.md | main | nodejs | [
0.05641717091202736,
0.03511558473110199,
-0.034611474722623825,
-0.03251919150352478,
-0.026354720816016197,
-0.0020150281488895416,
0.0010794623522087932,
0.11838601529598236,
0.013858631253242493,
-0.07139209657907486,
-0.02716187573969364,
0.02999744936823845,
-0.013720397837460041,
-0... | 0.055543 |
will return the same result as that of `end` equal to [`buf.length`][]. This method is inherited from [`TypedArray.prototype.subarray()`][]. Modifying the new `Buffer` slice will modify the memory in the original `Buffer` because the allocated memory of the two objects overlap. ```mjs import { Buffer } from 'node:buffe... | https://github.com/nodejs/node/blob/main//doc/api/buffer.md | main | nodejs | [
0.06735848635435104,
0.016156941652297974,
-0.03767681494355202,
-0.020063169300556183,
-0.08397094160318375,
-0.05539049953222275,
0.023616308346390724,
0.016249828040599823,
-0.018177660182118416,
-0.08389873057603836,
-0.07920283824205399,
0.02485564909875393,
-0.028865741565823555,
-0.... | 0.096419 |
const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]); console.log(buf1); // Prints: buf1.swap16(); console.log(buf1); // Prints: const buf2 = Buffer.from([0x1, 0x2, 0x3]); buf2.swap16(); // Throws ERR\_INVALID\_BUFFER\_SIZE. ``` One convenient use of `buf.swap16()` is to perform a fast in-place conversion... | https://github.com/nodejs/node/blob/main//doc/api/buffer.md | main | nodejs | [
0.046047888696193695,
0.02643267996609211,
-0.01812925562262535,
-0.06752846390008926,
-0.048201438039541245,
-0.07522689551115036,
-0.01474716141819954,
0.041171178221702576,
-0.0018838028190657496,
-0.046413667500019073,
-0.0020024990662932396,
0.01411090511828661,
-0.02074252814054489,
... | 0.044524 |
buf1 = Buffer.allocUnsafe(26); for (let i = 0; i < 26; i++) { // 97 is the decimal ASCII value for 'a'. buf1[i] = i + 97; } console.log(buf1.toString('utf8')); // Prints: abcdefghijklmnopqrstuvwxyz console.log(buf1.toString('utf8', 0, 5)); // Prints: abcde const buf2 = Buffer.from('tést'); console.log(buf2.toString('he... | https://github.com/nodejs/node/blob/main//doc/api/buffer.md | main | nodejs | [
0.05243720859289169,
0.022095821797847748,
-0.08782225102186203,
-0.05358613282442093,
-0.07323065400123596,
-0.001769651542417705,
0.039002425968647,
0.04909447953104973,
0.010995841585099697,
-0.07458218187093735,
-0.026616204530000687,
-0.09024054557085037,
-0.009658120572566986,
-0.027... | 0.062452 |
and written as a two's complement signed integer. ```mjs import { Buffer } from 'node:buffer'; const buf = Buffer.allocUnsafe(8); buf.writeBigInt64BE(0x0102030405060708n, 0); console.log(buf); // Prints: ``` ```cjs const { Buffer } = require('node:buffer'); const buf = Buffer.allocUnsafe(8); buf.writeBigInt64BE(0x01020... | https://github.com/nodejs/node/blob/main//doc/api/buffer.md | main | nodejs | [
0.04770716279745102,
0.05407300218939781,
-0.0028006911743432283,
0.014282215386629105,
-0.04347020387649536,
-0.03445802256464958,
0.01817011646926403,
0.09229312092065811,
-0.016488760709762573,
-0.03484315797686577,
-0.06337545812129974,
-0.00913905818015337,
-0.014859146438539028,
-0.0... | 0.09765 |
console.log(buf); // Prints: ``` ### `buf.writeFloatBE(value[, offset])` \* `value` {number} Number to be written to `buf`. \* `offset` {integer} Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`. \*\*Default:\*\* `0`. \* Returns: {integer} `offset` plus the number of bytes ... | https://github.com/nodejs/node/blob/main//doc/api/buffer.md | main | nodejs | [
0.06909559667110443,
0.016710026189684868,
-0.022640977054834366,
0.010245897807180882,
-0.04252905398607254,
-0.015448648482561111,
0.019533244892954826,
0.047385264188051224,
0.03871983662247658,
-0.0511968769133091,
-0.04402545839548111,
-0.04562100023031235,
-0.015657030045986176,
-0.0... | 0.08286 |
= Buffer.allocUnsafe(2); buf.writeInt16LE(0x0304, 0); console.log(buf); // Prints: ``` ```cjs const { Buffer } = require('node:buffer'); const buf = Buffer.allocUnsafe(2); buf.writeInt16LE(0x0304, 0); console.log(buf); // Prints: ``` ### `buf.writeInt32BE(value[, offset])` \* `value` {integer} Number to be written to `... | https://github.com/nodejs/node/blob/main//doc/api/buffer.md | main | nodejs | [
0.06705468147993088,
0.04310430958867073,
-0.044539403170347214,
-0.014204762876033783,
-0.037499941885471344,
-0.01953435130417347,
-0.025318056344985962,
0.08024797588586807,
-0.022499719634652138,
-0.027662398293614388,
-0.04679577052593231,
-0.03857496380805969,
-0.0579882375895977,
-0... | 0.100136 |
satisfy `0 <= offset <= buf.length - 1`. \*\*Default:\*\* `0`. \* Returns: {integer} `offset` plus the number of bytes written. Writes `value` to `buf` at the specified `offset`. `value` must be a valid unsigned 8-bit integer. Behavior is undefined when `value` is anything other than an unsigned 8-bit integer. This fun... | https://github.com/nodejs/node/blob/main//doc/api/buffer.md | main | nodejs | [
0.05586496368050575,
0.03639595955610275,
-0.022638680413365364,
-0.0015947369392961264,
-0.06608210504055023,
-0.0151588199660182,
0.026136010885238647,
0.08439420908689499,
0.00040997291216626763,
-0.02812778763473034,
-0.04869851469993591,
-0.029386041685938835,
0.009933465160429478,
-0... | 0.063291 |
function is also available under the `writeUint32LE` alias. ```mjs import { Buffer } from 'node:buffer'; const buf = Buffer.allocUnsafe(4); buf.writeUInt32LE(0xfeedface, 0); console.log(buf); // Prints: ``` ```cjs const { Buffer } = require('node:buffer'); const buf = Buffer.allocUnsafe(4); buf.writeUInt32LE(0xfeedface... | https://github.com/nodejs/node/blob/main//doc/api/buffer.md | main | nodejs | [
0.02459651045501232,
0.0007532120798714459,
-0.03536253422498703,
0.0239572636783123,
-0.05769301578402519,
-0.018931854516267776,
-0.004919396713376045,
0.09276553243398666,
0.004062043968588114,
-0.011674498207867146,
-0.07387685775756836,
-0.026280052959918976,
0.0010262146824970841,
-0... | 0.103841 |
either `'transparent'` or `'native'`. When set to `'native'`, line endings in string source parts will be converted to the platform native line-ending as specified by `require('node:os').EOL`. \* `type` {string} The File content-type. \* `lastModified` {number} The last modified date of the file. \*\*Default:\*\* `Date... | https://github.com/nodejs/node/blob/main//doc/api/buffer.md | main | nodejs | [
-0.007816017605364323,
0.042295362800359726,
-0.05388513579964638,
0.01623108983039856,
-0.0027974972035735846,
-0.059292569756507874,
-0.033165156841278076,
0.08141237497329712,
-0.009852539747953415,
0.022207019850611687,
-0.007590955588966608,
-0.0045454534702003,
-0.0806594267487526,
-... | 0.076389 |
the given `Buffer` or `Uint8Array` instance from one character encoding to another. Returns a new `Buffer` instance. Throws if the `fromEnc` or `toEnc` specify invalid character encodings or if conversion from `fromEnc` to `toEnc` is not permitted. Encodings supported by `buffer.transcode()` are: `'ascii'`, `'utf8'`, `... | https://github.com/nodejs/node/blob/main//doc/api/buffer.md | main | nodejs | [
0.0017675101989880204,
-0.06503736972808838,
-0.0372924841940403,
-0.008038551546633244,
-0.10910660028457642,
-0.019130747765302658,
0.04210398346185684,
0.0287921242415905,
0.010462558828294277,
-0.07718261331319809,
-0.04811764508485794,
-0.04800151661038399,
0.011314029805362225,
0.047... | 0.071307 |
remote attacker. Since Node.js 8.0.0, exposure of memory cannot occur because the data is zero-filled. However, other attacks are still possible, such as causing very large buffers to be allocated by the server, leading to performance degradation or crashing on memory exhaustion. To make the creation of `Buffer` instan... | https://github.com/nodejs/node/blob/main//doc/api/buffer.md | main | nodejs | [
0.005229267757385969,
0.019473610445857048,
-0.01810527592897415,
0.038212940096855164,
-0.012475375086069107,
-0.04732009768486023,
0.005019794218242168,
0.059956055134534836,
0.018617046996951103,
0.02380765788257122,
-0.04151449352502823,
0.06993476301431656,
-0.03203165531158447,
-0.04... | 0.071506 |
# HTTP > Stability: 2 - Stable This module, containing both a client and server, can be imported via `require('node:http')` (CommonJS) or `import \* as http from 'node:http'` (ES module). The HTTP interfaces in Node.js are designed to support many features of the protocol which have been traditionally difficult to use.... | https://github.com/nodejs/node/blob/main//doc/api/http.md | main | nodejs | [
-0.04970283433794975,
0.06934317201375961,
0.02681959606707096,
0.0010236892849206924,
0.030541621148586273,
-0.09825940430164337,
-0.06421869248151779,
0.0010951642179861665,
0.03424397483468056,
0.013715174049139023,
-0.044572461396455765,
0.04068464785814285,
-0.024663709104061127,
-0.0... | 0.153587 |
`agent:false`: ```js http.get({ hostname: 'localhost', port: 80, path: '/', agent: false, // Create a new agent just for this one request }, (res) => { // Do stuff with response }); ``` ### `new Agent([options])` \* `options` {Object} Set of configurable options to set on the agent. Can have the following fields: \* `k... | https://github.com/nodejs/node/blob/main//doc/api/http.md | main | nodejs | [
-0.11515548825263977,
0.04959804564714432,
-0.05662740021944046,
0.040152911096811295,
-0.004501853603869677,
-0.06898890435695648,
-0.017346017062664032,
-0.07672002166509628,
0.015751108527183533,
0.000061017261032247916,
0.0036611363757401705,
0.060508206486701965,
-0.04294667765498161,
... | 0.106133 |
a proxy. \* `http\_proxy` {string|undefined} Same as `HTTP\_PROXY`. If both are set, `http\_proxy` takes precedence. \* `https\_proxy` {string|undefined} Same as `HTTPS\_PROXY`. If both are set, `https\_proxy` takes precedence. \* `no\_proxy` {string|undefined} Same as `NO\_PROXY`. If both are set, `no\_proxy` takes pr... | https://github.com/nodejs/node/blob/main//doc/api/http.md | main | nodejs | [
-0.05873691663146019,
0.05396053194999695,
-0.037988122552633286,
-0.02067222073674202,
-0.07150011509656906,
-0.06803010404109955,
-0.033752474933862686,
-0.009120091795921326,
-0.016141587868332863,
-0.015537234023213387,
0.0016258034156635404,
0.061599764972925186,
0.004244300536811352,
... | 0.031516 |
agent when it is no longer needed. Otherwise, sockets might stay open for quite a long time before the server terminates them. ### `agent.freeSockets` \* Type: {Object} An object which contains arrays of sockets currently awaiting use by the agent when `keepAlive` is enabled. Do not modify. Sockets in the `freeSockets`... | https://github.com/nodejs/node/blob/main//doc/api/http.md | main | nodejs | [
-0.07282788306474686,
0.011057127267122269,
-0.07263530045747757,
0.03687566891312599,
-0.011517076753079891,
-0.037038881331682205,
-0.012114890851080418,
-0.07758446037769318,
0.05691729113459587,
0.003788500325754285,
0.013626315630972385,
0.05673656240105629,
-0.018452320247888565,
-0.... | 0.127766 |
thrown, identified by `code:` [`'ERR\_HTTP\_CONTENT\_LENGTH\_MISMATCH'`][]. `Content-Length` value should be in bytes, not characters. Use [`Buffer.byteLength()`][] to determine the length of the body in bytes. ### Event: `'abort'` > Stability: 0 - Deprecated. Listen for the `'close'` event instead. Emitted when the re... | https://github.com/nodejs/node/blob/main//doc/api/http.md | main | nodejs | [
-0.0493033267557621,
0.033049844205379486,
0.0019479437032714486,
0.007647703401744366,
-0.02228691801428795,
-0.11655990779399872,
0.023279840126633644,
0.009152643382549286,
0.05028251186013222,
0.01509373914450407,
-0.018396621569991112,
0.04664439707994461,
-0.0040617333725094795,
-0.0... | 0.098404 |
transmission over the network. It does not imply that the server has received anything yet. ### Event: `'information'` \* `info` {Object} \* `httpVersion` {string} \* `httpVersionMajor` {integer} \* `httpVersionMinor` {integer} \* `statusCode` {integer} \* `statusMessage` {string} \* `headers` {Object} \* `rawHeaders` ... | https://github.com/nodejs/node/blob/main//doc/api/http.md | main | nodejs | [
-0.010613144375383854,
0.11017804592847824,
0.04822598770260811,
0.014274084009230137,
0.03787943348288536,
-0.08748658746480942,
-0.01311260275542736,
-0.028382964432239532,
0.07400552928447723,
0.04069969058036804,
-0.017366943880915642,
0.009417190216481686,
0.004391341470181942,
-0.023... | 0.073943 |
1337, host: '127.0.0.1', headers: { 'Connection': 'Upgrade', 'Upgrade': 'websocket', }, }; const req = http.request(options); req.end(); req.on('upgrade', (res, stream, upgradeHead) => { console.log('got upgraded!'); stream.end(); process.exit(0); }); }); ``` ### `request.abort()` > Stability: 0 - Deprecated: Use [`req... | https://github.com/nodejs/node/blob/main//doc/api/http.md | main | nodejs | [
-0.07332562655210495,
0.07402986288070679,
-0.004611031152307987,
-0.002926026936620474,
0.00008529706974513829,
-0.08352895081043243,
-0.06544134765863419,
0.014465205371379852,
-0.004628104157745838,
-0.013857312500476837,
-0.04281154274940491,
0.06387650221586227,
-0.06370903551578522,
... | 0.061611 |
\_will not work\_. ```js request.setHeader('Foo', 'bar'); request.setHeader('Cookie', ['foo=bar', 'bar=baz']); const headers = request.getHeaders(); // headers === { foo: 'bar', 'cookie': ['foo=bar', 'bar=baz'] } ``` ### `request.getRawHeaderNames()` \* Returns: {string\[]} Returns an array containing the unique names ... | https://github.com/nodejs/node/blob/main//doc/api/http.md | main | nodejs | [
-0.11407145857810974,
0.07207569479942322,
0.0199221670627594,
-0.03983641788363457,
-0.02373097650706768,
-0.05539395287632942,
0.06122642382979393,
0.020452601835131645,
0.017138298600912094,
-0.047588687390089035,
-0.058049727231264114,
-0.050800543278455734,
-0.01885862834751606,
0.000... | -0.023289 |
to strings for network transmission. ```js request.setHeader('Content-Type', 'application/json'); ``` or ```js request.setHeader('Cookie', ['type=ninja', 'language=javascript']); ``` When the value is a string an exception will be thrown if it contains characters outside the `latin1` encoding. If you need to pass UTF-8... | https://github.com/nodejs/node/blob/main//doc/api/http.md | main | nodejs | [
-0.010936086997389793,
0.028203854337334633,
-0.032903242856264114,
-0.01802241802215576,
-0.0584852360188961,
-0.003434751182794571,
0.05012810602784157,
0.05274142697453499,
0.032649267464876175,
-0.044054705649614334,
-0.045945215970277786,
-0.010434734635055065,
-0.0008083685534074903,
... | 0.040676 |
an HTTP `Expect: 100-continue` is received. If this event is not listened for, the server will automatically respond with a `100 Continue` as appropriate. Handling this event involves calling [`response.writeContinue()`][] if the client should continue to send the request body, or generating an appropriate HTTP respons... | https://github.com/nodejs/node/blob/main//doc/api/http.md | main | nodejs | [
-0.07145173102617264,
0.03524671494960785,
0.016143186017870903,
0.020796187222003937,
-0.02385338395833969,
-0.12266597896814346,
0.008140827529132366,
-0.015033505856990814,
0.07038015872240067,
0.05785829946398735,
-0.031148472800850868,
0.013639162294566631,
0.023627083748579025,
0.032... | 0.099074 |
method will have their connections closed. This event is guaranteed to be passed an instance of the {net.Socket} class, a subclass of {stream.Duplex}, unless the user specifies a socket type other than {net.Socket}. After this event is emitted, the request's socket will not have a `'data'` event listener, meaning it wi... | https://github.com/nodejs/node/blob/main//doc/api/http.md | main | nodejs | [
-0.07979297637939453,
0.03066437691450119,
-0.029123853892087936,
0.02942594699561596,
-0.0589771643280983,
-0.03743715584278107,
0.04474511370062828,
0.00396703789010644,
0.06332509964704514,
0.0017563675064593554,
-0.004966932814568281,
0.10175907611846924,
-0.03534667193889618,
-0.01414... | 0.132778 |
the request, but in some cases (such as with a request body) it may be a duplex stream. If required, you can access the raw connection underlying the request via [`request.socket`][], which is guaranteed to be an instance of {net.Socket} unless the user specified another socket type. ### `server.close([callback])` \* `... | https://github.com/nodejs/node/blob/main//doc/api/http.md | main | nodejs | [
-0.09950169920921326,
0.03166797012090683,
0.0063164494931697845,
0.034570734947919846,
-0.02599731832742691,
-0.06995286047458649,
-0.03603838011622429,
-0.010637909173965454,
0.0671464130282402,
0.00949303712695837,
-0.06814954429864883,
0.08257094025611877,
-0.06933722645044327,
-0.0332... | 0.078084 |
listening for connections. This method is identical to [`server.listen()`][] from [`net.Server`][]. ### `server.listening` \* Type: {boolean} Indicates whether or not the server is listening for connections. ### `server.maxHeadersCount` \* Type: {number} \*\*Default:\*\* `2000` Limits maximum incoming headers count. If... | https://github.com/nodejs/node/blob/main//doc/api/http.md | main | nodejs | [
-0.06164109706878662,
0.03495290130376816,
-0.05172357335686684,
0.016891084611415863,
-0.07449203729629517,
-0.07118003070354462,
-0.0021077257115393877,
0.003661121940240264,
0.031026694923639297,
0.011979431845247746,
-0.06516434252262115,
0.06280403584241867,
0.016706399619579315,
-0.0... | 0.087617 |
server has closed. ## Class: `http.ServerResponse` \* Extends: {http.OutgoingMessage} This object is created internally by an HTTP server, not by the user. It is passed as the second parameter to the [`'request'`][] event. ### Event: `'close'` Indicates that the response is completed, or its underlying connection was t... | https://github.com/nodejs/node/blob/main//doc/api/http.md | main | nodejs | [
-0.07819896191358566,
0.026306696236133575,
0.05793606489896774,
0.02372489497065544,
0.06813618540763855,
-0.0839061588048935,
0.0290977880358696,
-0.02348453924059868,
0.10607592761516571,
0.03575529903173447,
-0.02851182594895363,
0.04050597548484802,
-0.057807475328445435,
-0.026204755... | 0.117772 |
\_will not work\_. ```js response.setHeader('Foo', 'bar'); response.setHeader('Set-Cookie', ['foo=bar', 'bar=baz']); const headers = response.getHeaders(); // headers === { foo: 'bar', 'set-cookie': ['foo=bar', 'bar=baz'] } ``` ### `response.hasHeader(name)` \* `name` {string} \* Returns: {boolean} Returns `true` if th... | https://github.com/nodejs/node/blob/main//doc/api/http.md | main | nodejs | [
-0.10841227322816849,
0.09595014899969101,
0.032061267644166946,
0.0037553906440734863,
0.0018337987130507827,
-0.04332446679472923,
0.07628507912158966,
0.036843255162239075,
0.01133811566978693,
-0.02777807042002678,
-0.05404653400182724,
-0.046904925256967545,
-0.0000342610219377093,
0.... | -0.003533 |
const ip = res.socket.remoteAddress; const port = res.socket.remotePort; res.end(`Your IP address is ${ip} and your source port is ${port}.`); }).listen(3000); ``` This property is guaranteed to be an instance of the {net.Socket} class, a subclass of {stream.Duplex}, unless the user specified a socket type other than {... | https://github.com/nodejs/node/blob/main//doc/api/http.md | main | nodejs | [
-0.0895513966679573,
0.07353836297988892,
0.010532708838582039,
0.018555888906121254,
-0.011344240047037601,
-0.02010672353208065,
-0.0030754483304917812,
0.007017000112682581,
0.0605645477771759,
0.019493218511343002,
-0.04907814785838127,
0.0652339830994606,
-0.03669726476073265,
0.02462... | 0.097919 |
100 Continue message to the client, indicating that the request body should be sent. See the [`'checkContinue'`][] event on `Server`. ### `response.writeEarlyHints(hints[, callback])` \* `hints` {Object} \* `callback` {Function} Sends an HTTP/1.1 103 Early Hints message to the client with a Link header, indicating that... | https://github.com/nodejs/node/blob/main//doc/api/http.md | main | nodejs | [
-0.08002807945013046,
0.05844775214791298,
0.060069113969802856,
0.08617547899484634,
-0.0029469269793480635,
-0.03612576052546501,
0.03868984803557396,
0.029566969722509384,
0.07137428969144821,
-0.04770779237151146,
-0.034179266542196274,
0.06469467282295227,
-0.03248743712902069,
-0.031... | 0.062596 |
reused multiple times in case of keep-alive. ### Event: `'aborted'` > Stability: 0 - Deprecated. Listen for `'close'` event instead. Emitted when the request has been aborted. ### Event: `'close'` Emitted when the request has been completed. ### `message.aborted` > Stability: 0 - Deprecated. Check `message.destroyed` f... | https://github.com/nodejs/node/blob/main//doc/api/http.md | main | nodejs | [
-0.06272564083337784,
0.06722141802310944,
0.029778558760881424,
0.05490460246801376,
0.07109693437814713,
-0.06903401017189026,
0.0013578914804384112,
-0.058491334319114685,
0.10803249478340149,
0.006761112716048956,
-0.013378134928643703,
0.07975183427333832,
-0.03972216695547104,
0.0307... | 0.083741 |
### `message.rawTrailers` \* Type: {string\[]} The raw request/response trailer keys and values exactly as they were received. Only populated at the `'end'` event. ### `message.setTimeout(msecs[, callback])` \* `msecs` {number} \* `callback` {Function} \* Returns: {http.IncomingMessage} Calls `message.socket.setTimeout... | https://github.com/nodejs/node/blob/main//doc/api/http.md | main | nodejs | [
-0.08952448517084122,
0.039483580738306046,
-0.024522805586457253,
0.05582057684659958,
-0.02143007144331932,
-0.08731497079133987,
0.011487885378301144,
0.02765471301972866,
0.10853616893291473,
-0.022745918482542038,
-0.018467310816049576,
0.022056782618165016,
-0.015239975415170193,
0.0... | 0.02476 |
value of `options.uniqueHeaders` when the client request or the server were created, this will end up in the header being sent multiple times or a single time with values joined using `; `. ### `outgoingMessage.connection` > Stability: 0 - Deprecated: Use [`outgoingMessage.socket`][] instead. Alias of [`outgoingMessage... | https://github.com/nodejs/node/blob/main//doc/api/http.md | main | nodejs | [
-0.07901723682880402,
0.01786295510828495,
0.003367044497281313,
0.03251553326845169,
-0.03140406683087349,
-0.0960800051689148,
0.08795768022537231,
0.023458430543541908,
0.034415509551763535,
-0.04077078402042389,
0.0018593281274661422,
-0.00449779536575079,
-0.0037181228399276733,
0.047... | 0.04116 |
the header already exists in the to-be-sent headers, its value will be replaced. Use an array of strings to send multiple headers with the same name. ### `outgoingMessage.setHeaders(headers)` \* `headers` {Headers|Map} \* Returns: {this} Sets multiple header values for implicit headers. `headers` must be an instance of... | https://github.com/nodejs/node/blob/main//doc/api/http.md | main | nodejs | [
-0.037573594599962234,
0.07197439670562744,
0.08738599717617035,
0.02455773763358593,
0.007710481993854046,
-0.03058500774204731,
0.07672344893217087,
0.03206142038106918,
-0.011200976558029652,
-0.01282249204814434,
-0.06628872454166412,
-0.06896265596151352,
0.032067298889160156,
0.01572... | 0.061894 |
with leniency flags enabled. Using the insecure parser should be avoided. See [`--insecure-http-parser`][] for more information. \*\*Default:\*\* `false`. \* `IncomingMessage` {http.IncomingMessage} Specifies the `IncomingMessage` class to be used. Useful for extending the original `IncomingMessage`. \*\*Default:\*\* `... | https://github.com/nodejs/node/blob/main//doc/api/http.md | main | nodejs | [
-0.06502724438905716,
0.05707081779837608,
-0.01641516387462616,
0.015810947865247726,
-0.013518202118575573,
-0.0686262920498848,
0.056777555495500565,
-0.058161813765764236,
0.0379265621304512,
-0.006640219129621983,
-0.016578305512666702,
-0.018336942419409752,
0.07276971638202667,
0.01... | -0.007929 |
data: 'Hello World!', })); }); server.listen(8000); ``` ```mjs import http from 'node:http'; // Create a local server to receive data from const server = http.createServer(); // Listen to the request event server.on('request', (request, res) => { res.writeHead(200, { 'Content-Type': 'application/json' }); res.end(JSON.... | https://github.com/nodejs/node/blob/main//doc/api/http.md | main | nodejs | [
-0.025879984721541405,
0.06000233069062233,
0.009983363561332226,
-0.03341624140739441,
-0.056936152279376984,
-0.09714991599321365,
-0.06395027041435242,
0.06519007682800293,
0.035529110580682755,
-0.016867224127054214,
-0.023857347667217255,
-0.02878112718462944,
-0.027194378897547722,
-... | 0.04872 |
`Agent` is used, else `undefined`. \* `family` {number} IP address family to use when resolving `host` or `hostname`. Valid values are `4` or `6`. When unspecified, both IP v4 and v6 will be used. \* `headers` {Object|Array} An object or an array of strings containing request headers. The array is in the same format as... | https://github.com/nodejs/node/blob/main//doc/api/http.md | main | nodejs | [
-0.053959690034389496,
0.05684254691004753,
-0.035657353699207306,
-0.045545544475317,
-0.045701056718826294,
-0.09495113044977188,
-0.026552913710474968,
-0.020825976505875587,
-0.015925854444503784,
-0.04351024702191353,
-0.02751701883971691,
-0.04888898506760597,
0.04299357905983925,
-0... | 0.054527 |
a POST request, then write to the `ClientRequest` object. ```mjs import http from 'node:http'; import { Buffer } from 'node:buffer'; const postData = JSON.stringify({ 'msg': 'Hello World!', }); const options = { hostname: 'www.google.com', port: 80, path: '/upload', method: 'POST', headers: { 'Content-Type': 'applicati... | https://github.com/nodejs/node/blob/main//doc/api/http.md | main | nodejs | [
-0.039562445133924484,
0.05934811010956764,
0.013661990873515606,
-0.00960452202707529,
-0.04119473323225975,
-0.09106060117483139,
-0.07072456181049347,
0.0711643174290657,
0.0041894991882145405,
0.05436104163527489,
-0.03367387130856514,
0.03918299078941345,
0.00457236310467124,
-0.02278... | 0.012502 |
code `'ECONNRESET'` \* `'close'` on the `res` object If `req.destroy()` is called before a socket is assigned, the following events will be emitted in the following order: \* (`req.destroy()` called here) \* `'error'` with an error with message `'Error: socket hang up'` and code `'ECONNRESET'`, or the error with which ... | https://github.com/nodejs/node/blob/main//doc/api/http.md | main | nodejs | [
-0.07541520148515701,
0.003622199408710003,
0.007341453339904547,
0.05325992405414581,
-0.02123754657804966,
-0.06106157228350639,
0.021833287551999092,
-0.009026702493429184,
0.11857949197292328,
0.02639152482151985,
0.01006031408905983,
-0.002227058866992593,
-0.043436188250780106,
0.022... | 0.109991 |
validations on the provided `value` that are done when `res.setHeader(name, value)` is called. Passing illegal value as `value` will result in a [`TypeError`][] being thrown. \* Undefined value error is identified by `code: 'ERR\_HTTP\_INVALID\_HEADER\_VALUE'`. \* Invalid value character error is identified by `code: '... | https://github.com/nodejs/node/blob/main//doc/api/http.md | main | nodejs | [
-0.09003995358943939,
0.13565047085285187,
0.02096158266067505,
-0.02850329503417015,
0.026540735736489296,
-0.02636636234819889,
-0.015550854615867138,
0.07713967561721802,
0.028539929538965225,
-0.010663798078894615,
-0.06330537050962448,
-0.06706901639699936,
0.0644676610827446,
0.04014... | 0.032297 |
be ignored. ### Proxy URL Format Proxy URLs can use either HTTP or HTTPS protocols: \* HTTP proxy: `http://proxy.example.com:8080` \* HTTPS proxy: `https://proxy.example.com:8080` \* Proxy with authentication: `http://username:password@proxy.example.com:8080` ### `NO\_PROXY` Format The `NO\_PROXY` environment variable ... | https://github.com/nodejs/node/blob/main//doc/api/http.md | main | nodejs | [
-0.06141340732574463,
0.041854213923215866,
0.026151718571782112,
-0.06707572937011719,
-0.03264071047306061,
-0.09750188887119293,
-0.03352542221546173,
-0.01451609656214714,
-0.019276270642876625,
0.04362490400671959,
-0.07859257608652115,
0.04127925634384155,
0.030605990439653397,
0.028... | -0.052487 |
[`'request'`]: #event-request [`'response'`]: #event-response [`'upgrade'`]: #event-upgrade [`--insecure-http-parser`]: cli.md#--insecure-http-parser [`--max-http-header-size`]: cli.md#--max-http-header-sizesize [`Agent`]: #class-httpagent [`Buffer.byteLength()`]: buffer.md#static-method-bufferbytelengthstring-encoding... | https://github.com/nodejs/node/blob/main//doc/api/http.md | main | nodejs | [
-0.006177391856908798,
0.08713795989751816,
-0.06537745893001556,
-0.0952792689204216,
-0.011615725234150887,
-0.10587483644485474,
-0.06755749881267548,
0.01718883588910103,
-0.04120954871177673,
-0.001211198978126049,
-0.01812298223376274,
-0.03865402191877365,
-0.02124895714223385,
-0.0... | -0.038023 |
# File system > Stability: 2 - Stable The `node:fs` module enables interacting with the file system in a way modeled on standard POSIX functions. To use the promise-based APIs: ```mjs import \* as fs from 'node:fs/promises'; ``` ```cjs const fs = require('node:fs/promises'); ``` To use the callback and sync APIs: ```mj... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.15448524057865143,
0.025174366310238838,
-0.03009718470275402,
0.058856893330812454,
0.05172360688447952,
-0.06640716642141342,
-0.04353522136807442,
0.11084537953138351,
0.08615563809871674,
0.022520318627357483,
-0.00513014430180192,
0.1023981049656868,
-0.01369669009000063,
-0.028897... | 0.207335 |
`signal` {AbortSignal|undefined} allows aborting an in-progress writeFile. \*\*Default:\*\* `undefined` \* Returns: {Promise} Fulfills with `undefined` upon success. Alias of [`filehandle.writeFile()`][]. When operating on file handles, the mode cannot be changed from what it was set to with [`fsPromises.open()`][]. Th... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.07021939009428024,
0.02681177854537964,
-0.0067336964420974255,
0.04724578559398651,
0.029670536518096924,
-0.06783460825681686,
0.029100388288497925,
0.06669870764017105,
0.0549548864364624,
0.010445459745824337,
0.05509376525878906,
0.07472683489322662,
-0.06094291806221008,
-0.006974... | 0.144234 |
`false`. \* Returns: {fs.WriteStream} `options` may also include a `start` option to allow writing data at some position past the beginning of the file, allowed values are in the \[0, [`Number.MAX\_SAFE\_INTEGER`][]] range. Modifying a file rather than replacing it may require the `flags` `open` option to be set to `r+... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.025757109746336937,
0.04321364313364029,
-0.06814727187156677,
0.04336577281355858,
0.016103997826576233,
-0.014549074694514275,
0.002184309996664524,
0.0653756707906723,
0.03272107243537903,
0.060652077198028564,
-0.04478298872709274,
0.0468355193734169,
-0.04204094782471657,
0.0028904... | 0.085619 |
`length` {integer} The number of bytes to read. \*\*Default:\*\* `buffer.byteLength - offset` \* `position` {integer|bigint|null} The location where to begin reading data from the file. If `null` or `-1`, data will be read from the current file position, and the position will be updated. If `position` is a non-negative... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.04588748887181282,
0.02309797704219818,
-0.06186661124229431,
0.019334053620696068,
-0.0627562627196312,
-0.03988807648420334,
0.0575818233191967,
0.07220199704170227,
0.024523934349417686,
0.014890161342918873,
-0.012010050006210804,
0.07957080006599426,
-0.01578455977141857,
-0.051703... | 0.099131 |
\* `buffers` {Buffer\[]|TypedArray\[]|DataView\[]} property containing a reference to the `buffers` input. Read from a file and write to an array of {ArrayBufferView}s #### `filehandle.stat([options])` \* `options` {Object} \* `bigint` {boolean} Whether the numeric values in the returned {fs.Stats} object should be `bi... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.009000729769468307,
0.056242331862449646,
-0.06529513746500015,
0.04122548922896385,
-0.047993194311857224,
-0.08144321292638779,
0.0661262571811676,
0.0897597000002861,
0.04140762984752655,
-0.0062387725338339806,
-0.04280438646674156,
0.046864695847034454,
-0.07292044907808304,
-0.015... | 0.110317 |
rejected with an error. The promise is fulfilled with an object containing two properties: \* `bytesWritten` {integer} the number of bytes written \* `buffer` {string} a reference to the `string` written. It is unsafe to use `filehandle.write()` multiple times on the same file without waiting for the promise to be fulf... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.032028887420892715,
-0.012521956115961075,
0.018077492713928223,
0.0710444226861,
-0.0641215443611145,
-0.05607061833143234,
0.013715280219912529,
0.08714139461517334,
0.06567172706127167,
0.026378115639090538,
-0.019679633900523186,
0.061917923390865326,
-0.008762641809880733,
-0.04101... | 0.004914 |
a file before calling `fsPromises.open()` is not recommended. Doing so introduces a race condition, since other processes may change the file's state between the two calls. Instead, user code should open/read/write the file directly and handle the error raised if the file is not accessible. ### `fsPromises.appendFile(p... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.00593023793771863,
0.01741291768848896,
-0.08262238651514053,
0.027673859149217606,
-0.01852419413626194,
-0.06728993356227875,
0.016023078933358192,
0.16372990608215332,
-0.02315376326441765,
0.02827056124806404,
0.0008022210677154362,
0.040978867560625076,
-0.054263513535261154,
-0.02... | 0.045211 |
`dest` {string} destination path to copy to. \* Returns: {boolean|Promise} A value that is coercible to `boolean` or a `Promise` that fulfils with such value. \* `force` {boolean} overwrite existing file or directory. The copy operation will ignore errors if you set this to false and the destination exists. Use the `er... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.07293364405632019,
-0.0306519977748394,
-0.003521036822348833,
0.051674846559762955,
0.05223778635263443,
-0.07115233689546585,
0.06113043799996376,
0.052123818546533585,
0.034627605229616165,
0.03664343059062958,
0.04993539676070213,
-0.02527177706360817,
0.008888574317097664,
0.020769... | 0.047953 |
See [File modes][] for more details. \*\*Default:\*\* `0o777`. \* Returns: {Promise} Upon success, fulfills with `undefined` if `recursive` is `false`, or the first directory path created if `recursive` is `true`. Asynchronously creates a directory. The optional `options` argument can be an integer specifying `mode` (p... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.06615982204675674,
0.01381671242415905,
-0.004241532646119595,
0.08360745012760162,
0.057448167353868484,
-0.07763510197401047,
-0.002524890238419175,
0.10937343537807465,
0.06352361291646957,
0.0015172904822975397,
0.04211350157856941,
0.020234255120158195,
-0.026511918753385544,
0.081... | 0.072743 |
details. \*\*Default:\*\* `0o666` (readable and writable) \* Returns: {Promise} Fulfills with a {FileHandle} object. Opens a {FileHandle}. Refer to the POSIX open(2) documentation for more detail. Some characters (`< > : " / \ | ? \*`) are reserved under Windows as documented by [Naming Files, Paths, and Namespaces][].... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.030673731118440628,
-0.002921045757830143,
-0.03336241468787193,
0.0641319677233696,
0.04199367016553879,
-0.04775887355208397,
-0.012010556645691395,
0.13255655765533447,
0.09721529483795166,
0.02689622901380062,
-0.050355348736047745,
0.06624724715948105,
-0.09512806683778763,
0.01411... | 0.149762 |
catch (err) { console.error(err.message); } ``` ```cjs const { readFile } = require('node:fs/promises'); const { resolve } = require('node:path'); async function logFile() { try { const filePath = resolve('./package.json'); const contents = await readFile(filePath, { encoding: 'utf8' }); console.log(contents); } catch ... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.09077340364456177,
0.04989590123295784,
0.03485608845949173,
0.030387867242097855,
0.04413618519902229,
-0.034829795360565186,
-0.017452917993068695,
0.10628944635391235,
0.07964780926704407,
0.023598436266183853,
-0.021983318030834198,
0.05248687043786049,
-0.009581396356225014,
0.0002... | 0.096032 |
wait of `retryDelay` milliseconds longer on each try. This option represents the number of retries. This option is ignored if the `recursive` option is not `true`. \*\*Default:\*\* `0`. \* `recursive` {boolean} If `true`, perform a recursive directory removal. In recursive mode operations are retried on failure. \*\*De... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.07452392578125,
0.0417320691049099,
-0.008784161880612373,
0.03838822618126869,
0.0030982960015535355,
-0.09900802373886108,
0.03082062304019928,
0.05685251206159592,
0.04922089725732803,
0.008621410466730595,
0.04189391806721687,
0.007237370125949383,
-0.03121228516101837,
0.0379219800... | 0.063081 |
iterations of the {AsyncIterator} returned. \*\*Default:\*\* `2048`. \* `overflow` {string} Either `'ignore'` or `'throw'` when there are more events to be queued than `maxQueue` allows. `'ignore'` means overflow events are dropped and a warning is emitted, while `'throw'` means to throw an exception. \*\*Default:\*\* ... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.10596445202827454,
0.08671995252370834,
-0.03318031504750252,
0.07835793495178223,
-0.03186347335577011,
-0.059372298419475555,
0.04078087955713272,
0.01857161335647106,
0.03222593292593956,
-0.028110187500715256,
-0.022062668576836586,
0.06145457923412323,
-0.004732123576104641,
-0.068... | 0.114159 |
event loop, then invoke a callback function upon completion or error. The callback APIs use the underlying Node.js threadpool to perform file system operations off the event loop thread. These operations are not synchronized or threadsafe. Care must be taken when performing multiple concurrent modifications on the same... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.056698236614465714,
0.014186779037117958,
-0.054487444460392,
0.056103941053152084,
0.050947993993759155,
-0.10753613710403442,
0.032613810151815414,
0.062163688242435455,
0.0708019956946373,
-0.027587907388806343,
-0.024897277355194092,
0.1053265705704689,
-0.03306387737393379,
-0.0221... | 0.114058 |
if (err) throw err; }); } }); ``` The "not recommended" examples above check for accessibility and then use the file; the "recommended" examples are better because they use the file directly and handle the error, if any. In general, check for the accessibility of a file only if the file will not be used directly, for e... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.06815412640571594,
0.006569125689566135,
-0.11879821866750717,
0.05795028805732727,
0.024817850440740585,
-0.06185300275683403,
0.06370411813259125,
0.11040503531694412,
-0.005984250921756029,
0.0005116386455483735,
0.02462606318295002,
0.059675756841897964,
-0.0006961706676520407,
-0.0... | 0.043531 |
is to use a sequence of three octal digits (e.g. `765`). The left-most digit (`7` in the example), specifies the permissions for the file owner. The middle digit (`6` in the example), specifies permissions for the group. The right-most digit (`5` in the example), specifies the permissions for others. | Number | Descrip... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.009461532346904278,
-0.009493323042988777,
-0.11063522100448608,
-0.03645731881260872,
-0.030560359358787537,
-0.019053775817155838,
0.011060829274356365,
0.05860988423228264,
-0.04130179435014725,
0.007142720744013786,
0.03728051856160164,
0.017413314431905746,
0.008875424973666668,
-0... | 0.127805 |
'destination.txt', constants.COPYFILE\_EXCL, callback); ``` ### `fs.cp(src, dest[, options], callback)` \* `src` {string|URL} source path to copy. \* `dest` {string|URL} destination path to copy to. \* `options` {Object} \* `dereference` {boolean} dereference symlinks. \*\*Default:\*\* `false`. \* `errorOnExist` {boole... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.1328686624765396,
-0.004003711044788361,
0.02158961072564125,
0.08936778455972672,
0.05105117708444595,
-0.07823200523853302,
0.04256921261548996,
0.022501589730381966,
0.058423224836587906,
-0.027646804228425026,
0.03604191914200783,
-0.00196496257558465,
-0.02127741649746895,
0.028493... | 0.055991 |
from 'node:fs'; // Create a stream from some character device. const stream = createReadStream('/dev/input/event0'); setTimeout(() => { stream.close(); // This may not close the stream. // Artificially marking end-of-stream, as if the underlying resource had // indicated end-of-file by itself, allows the stream to clos... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.0558076910674572,
0.02400798164308071,
-0.016805263236165047,
0.021847333759069443,
0.023715779185295105,
-0.021915629506111145,
-0.030765753239393234,
0.0892055332660675,
0.07368690520524979,
0.02283533848822117,
-0.029232600703835487,
0.04234001040458679,
-0.07106691598892212,
-0.0088... | 0.162189 |
`exists` {boolean} Test whether or not the element at the given `path` exists by checking with the file system. Then call the `callback` argument with either true or false: ```mjs import { exists } from 'node:fs'; exists('/etc/passwd', (e) => { console.log(e ? 'it exists' : 'no passwd!'); }); ``` \*\*The parameters for... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.08140747994184494,
-0.003221806138753891,
-0.028663188219070435,
0.07548768073320389,
0.11851882934570312,
-0.06459270417690277,
-0.011618069373071194,
0.03076154924929142,
0.10217040777206421,
-0.009447556920349598,
0.022974489256739616,
0.07837462425231934,
0.03416862338781357,
-0.033... | 0.103784 |
Forces all currently queued I/O operations associated with the file to the operating system's synchronized I/O completion state. Refer to the POSIX fdatasync(2) documentation for details. No arguments other than a possible exception are given to the completion callback. ### `fs.fstat(fd[, options], callback)` \* `fd` {... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.10019446909427643,
0.048134300857782364,
-0.08425699174404144,
0.027243269607424736,
0.022881044074892998,
-0.11335421353578568,
0.045059580355882645,
0.0868658497929573,
0.07208849489688873,
0.006780246272683144,
-0.012586943805217743,
0.06199540197849274,
-0.06018458679318428,
-0.0258... | 0.163694 |
\* `err` {Error} Set the owner of the symbolic link. No arguments other than a possible exception are given to the completion callback. See the POSIX lchown(2) documentation for more detail. ### `fs.lutimes(path, atime, mtime, callback)` \* `path` {string|Buffer|URL} \* `atime` {number|string|Date} \* `mtime` {number|s... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.06371422857046127,
0.014517591334879398,
-0.030235910788178444,
0.04646753519773483,
0.01742997020483017,
-0.06504366546869278,
0.009102537296712399,
0.14599090814590454,
0.017313919961452484,
0.0003146010567434132,
-0.0027812898624688387,
0.06065751612186432,
-0.01090881135314703,
-0.0... | 0.031347 |
more than six random characters, and replace trailing `X` characters in `prefix` with random characters. The created directory path is passed as a string to the callback's second parameter. The optional `options` argument can be a string specifying an encoding, or an object with an `encoding` property specifying the ch... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
0.0013122892705723643,
-0.025553708896040916,
0.01281044166535139,
0.045816820114851,
-0.005609764251857996,
-0.043576210737228394,
0.014586595818400383,
0.07059700042009354,
0.06967131048440933,
0.012749587185680866,
0.057518552988767624,
-0.02378040738403797,
0.03356713429093361,
-0.0201... | 0.070563 |
better performance but higher memory usage. \*\*Default:\*\* `32` \* `recursive` {boolean} \*\*Default:\*\* `false` \* `callback` {Function} \* `err` {Error} \* `dir` {fs.Dir} Asynchronously open a directory. See the POSIX opendir(3) documentation for more details. Creates an {fs.Dir}, which contains all further functi... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.016347631812095642,
0.005416745785623789,
-0.076925128698349,
0.019248222932219505,
-0.049197107553482056,
-0.10864047706127167,
0.029375309124588966,
0.13370653986930847,
0.06529717892408371,
-0.023259349167346954,
0.013984344899654388,
0.09745404124259949,
0.002207433804869652,
-0.012... | 0.070483 |
\* `callback` {Function} \* `err` {Error} \* `bytesRead` {integer} \* `buffer` {Buffer} Similar to the [`fs.read()`][] function, this version takes an optional `options` object. If no `options` object is specified, it will default with the above values. ### `fs.readdir(path[, options], callback)` \* `path` {string|Buff... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.051725130528211594,
-0.0015966234495863318,
-0.07137305289506912,
0.030358348041772842,
-0.04303300008177757,
-0.09446736425161362,
0.060925502330064774,
0.11198212206363678,
0.04564734920859337,
-0.010324540548026562,
0.012635421007871628,
0.039522916078567505,
-0.011824208311736584,
0... | 0.08427 |
`'World'`, rather than `'Hello World'`. #### Performance Considerations The `fs.readFile()` method asynchronously reads the contents of a file into memory one chunk at a time, allowing the event loop to turn between each chunk. This allows the read operation to have less impact on other activity that may be using the u... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.0028304425068199635,
0.007932957261800766,
-0.033186182379722595,
0.04128639027476311,
0.09927982091903687,
-0.0905543640255928,
-0.031169552356004715,
0.10999546945095062,
0.07488773763179779,
0.02359795942902565,
-0.061115093529224396,
0.1307455599308014,
-0.08930868655443192,
-0.0624... | 0.078752 |
passed to the callback. If the `encoding` is set to `'buffer'`, the path returned will be passed as a {Buffer} object. If `path` resolves to a socket or a pipe, the function will return a system dependent name for that object. A path that does not exist results in an ENOENT error. `error.path` is the absolute file path... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.06519141048192978,
-0.028805460780858994,
-0.09406978636980057,
0.05321982130408287,
-0.063890241086483,
-0.056847382336854935,
0.0017042983090505004,
0.08959425985813141,
0.06299670785665512,
-0.05780617147684097,
-0.03321011736989021,
0.020779261365532875,
-0.05243458226323128,
0.0556... | 0.07783 |
{fs.Stats} object should be `bigint`. \*\*Default:\*\* `false`. \* `callback` {Function} \* `err` {Error} \* `stats` {fs.Stats} Asynchronous stat(2). The callback gets two arguments `(err, stats)` where `stats` is an {fs.Stats} object. In case of an error, the `err.code` will be one of [Common System Errors][]. [`fs.st... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.08283668011426926,
0.047332990914583206,
-0.1299934685230255,
0.08403085172176361,
0.08499569445848465,
-0.09306126832962036,
-0.011638656258583069,
0.18170680105686188,
0.0036873132921755314,
0.0186702162027359,
-0.03355879709124565,
0.05107925459742546,
0.01559293083846569,
-0.0503344... | 0.107602 |
as the first argument. In this case, `fs.ftruncate()` is called. ```mjs import { truncate } from 'node:fs'; // Assuming that 'path/file.txt' is a regular file. truncate('path/file.txt', (err) => { if (err) throw err; console.log('path/file.txt was truncated'); }); ``` ```cjs const { truncate } = require('node:fs'); // ... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.04227515310049057,
0.10417000949382782,
-0.000620214850641787,
0.05167094245553017,
0.05698126181960106,
-0.06672003120183945,
0.02074342593550682,
0.13744792342185974,
0.04135478660464287,
0.019538793712854385,
0.012514762580394745,
0.13056634366512299,
-0.06086684390902519,
-0.0185414... | 0.143372 |
is attached to the `'change'` event fired by {fs.FSWatcher}, but it is not the same thing as the `'change'` value of `eventType`. If a `signal` is passed, aborting the corresponding AbortController will close the returned {fs.FSWatcher}. #### Caveats The `fs.watch` API is not 100% consistent across platforms, and is un... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.05737937241792679,
-0.027639271691441536,
-0.07528458535671234,
0.028377259150147438,
0.19013933837413788,
0.03658216446638107,
0.03913111612200737,
0.06698747724294662,
0.13375575840473175,
0.07524804770946503,
0.010481465607881546,
0.057407964020967484,
-0.01832984946668148,
-0.051220... | 0.163166 |
indicates whether the process should continue to run as long as files are being watched. The `options` object may specify an `interval` property indicating how often the target should be polled in milliseconds. The `listener` gets two arguments the current stat object and the previous stat object: ```mjs import { watch... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.02383933775126934,
0.011341116391122341,
-0.020600592717528343,
0.07326880842447281,
0.1330866515636444,
-0.022103795781731606,
0.04382271319627762,
0.08598598092794418,
0.11962784081697464,
0.03992224112153053,
-0.04683701694011688,
0.04790226370096207,
-0.026266105473041534,
-0.067397... | 0.159143 |
`'utf8'` \* `callback` {Function} \* `err` {Error} \* `written` {integer} \* `string` {string} Write `string` to the file specified by `fd`. If `string` is not a string, an exception is thrown. `position` refers to the offset from the beginning of the file where this data should be written. If `typeof position !== 'num... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.028480863198637962,
0.012077093124389648,
-0.0708724856376648,
-0.01725415140390396,
-0.06949075311422348,
-0.06844735145568848,
-0.0015110507374629378,
0.1242697462439537,
0.057474445551633835,
0.01194633450359106,
-0.027287324890494347,
0.11477995663881302,
0.027594011276960373,
-0.05... | 0.023176 |
When a request is aborted - the callback is called with an AbortError }); // When the request should be aborted controller.abort(); ``` Aborting an ongoing request does not abort individual operating system requests but rather the internal buffering `fs.writeFile` performs. #### Using `fs.writeFile()` with file descrip... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.02834681235253811,
0.026391703635454178,
-0.017469439655542374,
0.06185884028673172,
0.057495396584272385,
-0.09928806126117706,
-0.022117601707577705,
0.11084476113319397,
0.09822214394807816,
0.07678651809692383,
-0.027489012107253075,
0.12332818657159805,
-0.0025261705741286278,
-0.0... | 0.12969 |
file descriptor \* `data` {string|Buffer} \* `options` {Object|string} \* `encoding` {string|null} \*\*Default:\*\* `'utf8'` \* `mode` {integer} \*\*Default:\*\* `0o666` \* `flag` {string} See [support of file system `flags`][]. \*\*Default:\*\* `'a'`. \* `flush` {boolean} If `true`, the underlying file descriptor is f... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.01909468322992325,
0.05116172134876251,
-0.052629582583904266,
0.061621349304914474,
-0.0009092616965062916,
-0.07400079071521759,
0.01777171716094017,
0.0751853957772255,
0.04570777341723442,
0.035558123141527176,
0.025137633085250854,
0.03794843703508377,
0.006864313967525959,
-0.0122... | 0.08114 |
`dereference` {boolean} dereference symlinks. \*\*Default:\*\* `false`. \* `errorOnExist` {boolean} when `force` is `false`, and the destination exists, throw an error. \*\*Default:\*\* `false`. \* `filter` {Function} Function to filter copied files/directories. Return `true` to copy the item, `false` to ignore it. Whe... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.06672873347997665,
-0.013722418807446957,
0.04252097010612488,
0.05956094712018967,
0.065125972032547,
-0.055739667266607285,
0.03406226262450218,
-0.018393240869045258,
0.03557002171874046,
0.024388419464230537,
0.0784500390291214,
-0.02219424396753311,
0.013085491955280304,
0.01898821... | 0.05461 |
`undefined`. \* `withFileTypes` {boolean} `true` if the glob should return paths as Dirents, `false` otherwise. \*\*Default:\*\* `false`. \* Returns: {string\[]} paths of files that match the pattern. ```mjs import { globSync } from 'node:fs'; console.log(globSync('\*\*/\*.js')); ``` ```cjs const { globSync } = require... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.057581521570682526,
0.011845345608890057,
-0.024455083534121513,
0.008197984658181667,
0.06461324542760849,
-0.04385614022612572,
0.015382859855890274,
0.05018960312008858,
-0.007059434428811073,
-0.03272392973303795,
0.0006257392233237624,
0.055011067539453506,
-0.0055138240568339825,
... | 0.047642 |
Number of directory entries that are buffered internally when reading from the directory. Higher values lead to better performance but higher memory usage. \*\*Default:\*\* `32` \* `recursive` {boolean} \*\*Default:\*\* `false` \* Returns: {fs.Dir} Synchronously open a directory. See opendir(3). Creates an {fs.Dir}, wh... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
0.0030757721979171038,
0.009016918949782848,
-0.11986096948385239,
0.04559972882270813,
0.037889208644628525,
-0.0770227238535881,
-0.015785546973347664,
0.09036460518836975,
0.09073427319526672,
-0.037004683166742325,
-0.019966118037700653,
0.09761933237314224,
-0.027846792712807655,
0.01... | 0.076393 |
API: [`fs.read()`][]. ### `fs.readvSync(fd, buffers[, position])` \* `fd` {integer} \* `buffers` {ArrayBufferView\[]} \* `position` {integer|null} \*\*Default:\*\* `null` \* Returns: {number} The number of bytes read. For detailed information, see the documentation of the asynchronous version of this API: [`fs.readv()`... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.011018987745046616,
-0.017163636162877083,
-0.1735934615135193,
0.02635389380156994,
-0.03377887234091759,
-0.06979923695325851,
-0.011803139001131058,
0.07766846567392349,
0.04257912188768387,
-0.05517297610640526,
-0.0713832899928093,
0.03356640040874481,
-0.05165763944387436,
-0.0089... | 0.081773 |
{string|Buffer|URL} \* `path` {string|Buffer|URL} \* `type` {string|null} \*\*Default:\*\* `null` \* Returns: `undefined`. For detailed information, see the documentation of the asynchronous version of this API: [`fs.symlink()`][]. ### `fs.truncateSync(path[, len])` \* `path` {string|Buffer|URL} \* `len` {integer} \*\*... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.04053020477294922,
0.02652408927679062,
-0.07221967726945877,
0.09039293974637985,
0.008609640412032604,
-0.08187245577573776,
-0.030882377177476883,
0.10901578515768051,
0.033116552978754044,
-0.01860930770635605,
0.0017763461219146848,
0.10883655399084091,
-0.04805084690451622,
-0.000... | 0.107861 |
in errors. #### `dir.path` \* Type: {string} The read-only path of this directory as was provided to [`fs.opendir()`][], [`fs.opendirSync()`][], or [`fsPromises.opendir()`][]. #### `dir.read()` \* Returns: {Promise} Fulfills with a {fs.Dirent|null} Asynchronously read the next directory entry via readdir(3) as an {fs.D... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.11628064513206482,
0.0072518824599683285,
-0.05224931612610817,
0.09729799628257751,
0.08892377465963364,
-0.10388953238725662,
-0.02793726697564125,
0.12407175451517105,
0.09981519728899002,
-0.060312382876873016,
0.043518759310245514,
0.09926681965589523,
-0.016078272834420204,
0.0029... | 0.054286 |
link. #### `dirent.name` \* Type: {string|Buffer} The file name that this {fs.Dirent} object refers to. The type of this value is determined by the `options.encoding` passed to [`fs.readdir()`][] or [`fs.readdirSync()`][]. #### `dirent.parentPath` \* Type: {string} The path to the parent directory of the file this {fs.... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.06444602459669113,
0.033875543624162674,
-0.0868578553199768,
0.03713066503405571,
0.06197405233979225,
-0.045359183102846146,
0.056223876774311066,
0.18013626337051392,
0.07456913590431213,
0.01391853392124176,
-0.042636025696992874,
0.001318282214924693,
-0.07297329604625702,
0.050660... | 0.173438 |
`readStream.bytesRead` \* Type: {number} The number of bytes that have been read so far. #### `readStream.path` \* Type: {string|Buffer} The path to the file the stream is reading from as specified in the first argument to `fs.createReadStream()`. If `path` is passed as a string, then `readStream.path` will be a string... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.04253866523504257,
-0.009950928390026093,
-0.098615862429142,
0.06113665550947189,
-0.002564248163253069,
-0.06908498704433441,
0.022275343537330627,
0.1314704418182373,
0.07308485358953476,
0.01856238953769207,
-0.05801425501704216,
0.10886283963918686,
-0.042170554399490356,
0.0310521... | 0.128142 |
if the file represents a device. #### `stats.size` \* Type: {number|bigint} The size of the file in bytes. If the underlying file system does not support getting the size of the file, this will be `0`. #### `stats.blksize` \* Type: {number|bigint} The file system block size for i/o operations. #### `stats.blocks` \* Ty... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.06319369375705719,
0.06919024139642715,
-0.04906132072210312,
0.023328520357608795,
0.004600484389811754,
-0.11959859728813171,
-0.0431540310382843,
0.13402336835861206,
0.042757462710142136,
0.05659954249858856,
-0.003616094123572111,
0.05090523138642311,
-0.04629414528608322,
-0.04503... | 0.107019 |
read(2), and write(2) system calls. \* `birthtime` "Birth Time": Time of file creation. Set once when the file is created. On file systems where birthtime is not available, this field may instead hold either the `ctime` or `1970-01-01T00:00Z` (ie, Unix epoch timestamp `0`). This value may be greater than `atime` or `mt... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.08744477480649948,
0.02987709827721119,
-0.057180602103471756,
0.0562436543405056,
0.10563507676124573,
-0.015736788511276245,
-0.0396164245903492,
0.09965778887271881,
0.08467429131269455,
0.057379353791475296,
0.017747709527611732,
-0.008485612459480762,
-0.0072979796677827835,
-0.063... | 0.077286 |
of the stream. \* `fsync`: {boolean} Perform a `fs.fsyncSync()` every time a write is completed. \* `maxLength`: {number} The maximum length of the internal buffer. If a write operation would cause the buffer to exceed `maxLength`, the data written is dropped and a drop event is emitted with the dropped data \* `maxWri... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.014007999561727047,
-0.0019259705441072583,
-0.03881753608584404,
0.03093898668885231,
0.00047672484652139246,
-0.11648767441511154,
-0.04276474937796593,
0.10319940000772476,
0.05238441377878189,
0.027188695967197418,
-0.04578966647386551,
0.033427853137254715,
-0.027274318039417267,
-... | 0.12586 |
argument must be a string. If the `contentMode` is set to `'buffer'`, the `data` argument must be a {Buffer}. #### `utf8Stream.writing` \* {boolean} Whether the stream is currently writing data to the file. #### `utf8Stream[Symbol.dispose]()` Calls `utf8Stream.destroy()`. ### Class: `fs.WriteStream` \* Extends {stream.... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.0005722132045775652,
0.04595237597823143,
-0.045507535338401794,
0.04745768383145332,
0.04968131706118584,
-0.07587795704603195,
0.01779651641845703,
0.12174596637487411,
0.0625929981470108,
0.029728855937719345,
-0.07271251827478409,
0.05426185205578804,
-0.02087903395295143,
0.0246109... | 0.104658 |
platform does not support copy-on-write, then the operation will fail with an error. | The definitions are also available on Windows. ##### File open constants The following constants are meant for use with `fs.open()`. | Constant | Description | | --- | --- | | `O_RDONLY` | Flag indicating to open a file for read-only... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.042779263108968735,
-0.0528806708753109,
-0.0731196403503418,
0.05789949372410774,
0.028662951663136482,
-0.06457138806581497,
0.007788362447172403,
0.10275744646787643,
0.022366443648934364,
0.023956725373864174,
0.052687112241983414,
0.0038362545892596245,
-0.03570587933063507,
-0.033... | 0.076238 |
and `S\_IFREG`, are available. ##### File mode constants The following constants are meant for use with the {fs.Stats} object's `mode` property for determining the access permissions for a file. | Constant | Description | | --- | --- | | `S_IRWXU` | File mode indicating readable, writable, and executable by owner. | | ... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.02213973179459572,
0.03404217213392258,
-0.13677909970283508,
0.036536797881126404,
0.0539761483669281,
-0.006733662914484739,
0.02623976767063141,
0.10291536897420883,
-0.06359785795211792,
0.0016582681564614177,
0.10486911982297897,
-0.0411541610956192,
0.004651276860386133,
-0.006541... | 0.170331 |
await open('file.txt', 'r'); // Do something with the file } finally { await fd?.close(); } ``` #### File URL paths For most `node:fs` module functions, the `path` or `filename` argument may be passed as a {URL} object using the `file:` protocol. ```mjs import { readFileSync } from 'node:fs'; readFileSync(new URL('file... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.04635511338710785,
0.05611000210046768,
-0.03869996592402458,
0.07482852786779404,
0.014365830458700657,
-0.02696978859603405,
-0.07711312174797058,
0.125924751162529,
0.016241297125816345,
0.04158945381641388,
-0.04142739251255989,
0.056745097041130066,
0.003147432580590248,
0.01975193... | 0.056545 |
use these file descriptors to identify and track each specific file. Windows systems use a different but conceptually similar mechanism for tracking resources. To simplify things for users, Node.js abstracts away the differences between operating systems and assigns all open files a numeric file descriptor. The callbac... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.04599897190928459,
0.02149282768368721,
-0.07986567914485931,
0.07573185861110687,
0.1036345586180687,
-0.05678226053714752,
-0.031403910368680954,
0.09609080851078033,
0.11396347731351852,
0.02286604233086109,
-0.04568786174058914,
0.1063603088259697,
-0.07950527220964432,
-0.044150326... | 0.180459 |
not exist) or truncated (if it exists). \* `'wx'`: Like `'w'` but fails if the path exists. \* `'w+'`: Open file for reading and writing. The file is created (if it does not exist) or truncated (if it exists). \* `'wx+'`: Like `'w+'` but fails if the path exists. `flag` can also be a number as documented by open(2); co... | https://github.com/nodejs/node/blob/main//doc/api/fs.md | main | nodejs | [
-0.08237000554800034,
-0.019513921812176704,
-0.05529586225748062,
0.07654809206724167,
0.01407939475029707,
-0.08968087285757065,
0.054587095975875854,
0.07083144038915634,
0.04436826705932617,
0.012311429716646671,
0.05852873995900154,
-0.0035598056856542826,
0.02447189949452877,
0.00811... | 0.126909 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.