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
bytes. ### `crypto.setEngine(engine[, flags])` \* `engine` {string} \* `flags` {crypto.constants} \*\*Default:\*\* `crypto.constants.ENGINE\_METHOD\_ALL` Load and set the `engine` for some or all OpenSSL functions (selected by flags). Support for custom engines in OpenSSL is deprecated from OpenSSL 3. `engine` could be...
https://github.com/nodejs/node/blob/main//doc/api/crypto.md
main
nodejs
[ -0.044911161065101624, 0.04448285326361656, -0.12023083120584488, 0.020771320909261703, 0.026134466752409935, -0.08543102443218231, -0.031941093504428864, -0.029477788135409355, -0.004866141825914383, -0.12171011418104172, -0.04184535890817642, -0.0453060045838356, -0.028635552152991295, -...
0.078019
`x === y` nor `Object.is(x, y)` implies that the byte representations of two floating-point numbers `x` and `y` are equal.** Use of `crypto.timingSafeEqual` does not guarantee that the \_surrounding\_ code is timing-safe. Care should be taken to ensure that the surrounding code does not introduce timing vulnerabilities...
https://github.com/nodejs/node/blob/main//doc/api/crypto.md
main
nodejs
[ -0.016456127166748047, 0.04208379611372948, -0.08208783715963364, -0.010143316350877285, -0.04733753576874733, -0.10760889202356339, 0.030443763360381126, -0.0076716067269444466, -0.030346347019076347, -0.08474062383174896, -0.057438697665929794, -0.01931885816156864, 0.03631966561079025, ...
0.018431
const bytesAsString = Buffer.from(original).toString('utf8'); const stringAsBytes = Buffer.from(bytesAsString, 'utf8'); console.log(stringAsBytes); // Prints ''. ``` The outputs of ciphers, hash functions, signature algorithms, and key derivation functions are pseudorandom byte sequences and should not be used as Unico...
https://github.com/nodejs/node/blob/main//doc/api/crypto.md
main
nodejs
[ -0.006109669338911772, 0.0019050483824685216, -0.019923372194170952, -0.018877141177654266, -0.010573322884738445, -0.030793307349085808, 0.05248289555311203, 0.07598043233156204, 0.04730017110705376, -0.035446275025606155, -0.10491198301315308, 0.02564513124525547, 0.026236526668071747, -...
0.021741
actual message in bytes must be passed to `setAAD()` via the `plaintextLength` option. Many crypto libraries include the authentication tag in the ciphertext, which means that they produce ciphertexts of the length `plaintextLength + authTagLength`. Node.js does not include the authentication tag, so the ciphertext len...
https://github.com/nodejs/node/blob/main//doc/api/crypto.md
main
nodejs
[ -0.012764030136168003, 0.04385697841644287, -0.030316844582557678, 0.048406727612018585, -0.07721461355686188, -0.043450068682432175, 0.022290248423814774, 0.04821476340293884, 0.09217752516269684, 0.04220322147011757, -0.0035026015248149633, -0.054759614169597626, 0.021374735981225967, -0...
0.022164
The fips section name should match the section name inside the # included fipsmodule.cnf. fips = fips\_sect [default\_sect] activate = 1 [algorithm\_sect] default\_properties = fips=yes ``` ## Crypto constants The following constants exported by `crypto.constants` apply to various uses of the `node:crypto`, `node:tls`,...
https://github.com/nodejs/node/blob/main//doc/api/crypto.md
main
nodejs
[ -0.06688792258501053, 0.0456506684422493, 0.0007980790687724948, 0.05501781031489372, 0.03302432969212532, -0.06607860326766968, -0.0456295870244503, -0.003128095529973507, 0.02058039978146553, -0.02840171381831169, 0.039190392941236496, -0.041397519409656525, -0.04664751514792442, 0.04306...
0.005828
the digest size when signing or verifying. | | `RSA_PSS_SALTLEN_MAX_SIGN` | Sets the salt length for `RSA_PKCS1_PSS_PADDING` to the maximum permissible value when signing data. | | `RSA_PSS_SALTLEN_AUTO` | Causes the salt length for `RSA_PKCS1_PSS_PADDING` to be determined automatically when verifying a signature. | | ...
https://github.com/nodejs/node/blob/main//doc/api/crypto.md
main
nodejs
[ -0.042831841856241226, 0.048298127949237823, -0.04432542249560356, 0.019179996103048325, 0.10688503086566925, -0.08438645303249359, -0.047860052436590195, 0.09992047399282455, 0.03445368632674217, -0.051355425268411636, -0.04871063679456711, 0.055087871849536896, 0.016682010143995285, -0.0...
0.02045
# Node-API > Stability: 2 - Stable Node-API (formerly N-API) is an API for building native Addons. It is independent from the underlying JavaScript runtime (for example, V8) and is maintained as part of Node.js itself. This API will be Application Binary Interface (ABI) stable across versions of Node.js. It is intended...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.13428811728954315, -0.0264495350420475, 0.007969599217176437, 0.051989417523145676, 0.05359925702214241, -0.03102431818842888, -0.08810510486364365, 0.05266978219151497, -0.024949070066213608, -0.048557158559560776, -0.03906380385160446, 0.03258558362722397, -0.037895940244197845, -0.09...
0.222575
APIs available via any of ```cpp #include #include #include #include ``` \* the libuv APIs which are also included with Node.js and available via ```cpp #include ``` \* the V8 API available via ```cpp #include ``` Thus, for an addon to remain ABI-compatible across Node.js major versions, it must use Node-API exclusivel...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.1141900047659874, -0.03585013747215271, -0.007975681684911251, -0.008890215307474136, 0.04502960294485092, -0.0315520241856575, -0.048448897898197174, 0.0392719991505146, -0.06512417644262314, -0.022701632231473923, -0.019296692684292793, -0.02518421970307827, -0.019591443240642548, -0....
0.185509
therefore node-gyp, requires that Python be installed. Historically, node-gyp has been the tool of choice for building native addons. It has widespread adoption and documentation. However, some developers have run into limitations in node-gyp. #### CMake.js [CMake.js][] is an alternative build system based on [CMake][]...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.08785824477672577, -0.0058396123349666595, 0.030289359390735626, 0.023363549262285233, 0.042565278708934784, -0.062289539724588394, -0.06960634142160416, 0.09316767007112503, 0.002668763045221567, -0.006986997090280056, -0.019548386335372925, -0.015966251492500305, -0.01603642851114273, ...
0.050348
versions between 8 and the highest version they support and will default to providing the version 8 APIs unless an add-on opts into a higher Node-API version. This approach provides the flexibility of better optimizing existing Node-API functions while maintaining ABI stability. Existing add-ons can continue to run wit...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.05465133115649223, -0.004587302915751934, 0.060682062059640884, 0.009193713776767254, 0.0585765540599823, -0.006452204193919897, -0.10687774419784546, -0.004768014885485172, -0.025558406487107277, -0.024970170110464096, -0.017544692382216454, 0.05773366615176201, -0.07766963541507721, -...
0.102005
the Node.js implementation of Node-API or any implementation of Node-API outside of Node.js. `addon\_node.c` is a separate file that contains the Node.js specific entry point to the addon and which instantiates the addon by calling into `addon.c` when the addon is loaded into a Node.js environment. ```c // addon.h #ifn...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.08466111123561859, 0.0705641508102417, -0.03556257113814354, 0.027898726984858513, 0.010056414641439915, -0.012774053029716015, -0.03162774816155434, 0.06414474546909332, 0.024295324459671974, -0.050580162554979324, -0.015279721468687057, -0.01334711816161871, -0.03951811045408249, -0.0...
0.191931
running Node.js environment. `data` can later be retrieved using `napi\_get\_instance\_data()`. Any existing data associated with the currently running Node.js environment which was set by means of a previous call to `napi\_set\_instance\_data()` will be overwritten. If a `finalize\_cb` was provided by the previous cal...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.010103804990649223, 0.07465887069702148, -0.002235738094896078, 0.05613764375448227, 0.036409225314855576, -0.07754881680011749, -0.027864471077919006, 0.0063463011756539345, 0.03361586481332779, -0.01209478359669447, -0.016482410952448845, 0.027381982654333115, 0.0008494138019159436, -...
0.134431
a function. Calling such APIs from a synchronous finalizer will ultimately result in the termination of the application. ### `napi\_value` This is an opaque pointer that is used to represent a JavaScript value. ### `napi\_threadsafe\_function` This is an opaque pointer that represents a JavaScript function which can be...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.09412378072738647, 0.014644086360931396, -0.018118642270565033, -0.046922631561756134, -0.03445873409509659, -0.01668073609471321, 0.04182668775320053, -0.005726618226617575, 0.04906576871871948, -0.019661949947476387, 0.016722068190574646, -0.01586149074137211, -0.06633397191762924, -0...
0.319465
``` Unless for reasons discussed in [Object Lifetime Management][], creating a handle and/or callback scope inside a `napi\_callback` is not necessary. #### `node\_api\_basic\_finalize` > Stability: 1 - Experimental Function pointer type for add-on provided functions that allow the user to be notified when externally-o...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.06549221277236938, 0.06861481815576553, -0.024195605888962746, 0.05663979426026344, 0.019369175657629967, -0.09469598531723022, 0.0380294993519783, 0.04377960413694382, 0.015303543768823147, 0.007304861675947905, -0.04500042647123337, 0.0013464413350448012, -0.07095345109701157, -0.0349...
0.218809
so it is sufficient to call the JavaScript function via `napi\_call\_function` rather than via `napi\_make\_callback`. Callback functions must satisfy the following signature: ```c typedef void (\*napi\_threadsafe\_function\_call\_js)(napi\_env env, napi\_value js\_callback, void\* context, void\* data); ``` \* `[in] e...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.1121799647808075, 0.030806981027126312, -0.038649190217256546, -0.017393728718161583, -0.045600540935993195, -0.04229326546192169, 0.012792844325304031, -0.01558882836252451, 0.030878989025950432, -0.06049947440624237, -0.01347519364207983, -0.026347987353801727, -0.028897633776068687, ...
0.170457
VM specific error code. \* `error\_code`: Node-API status code for the last error. [`napi\_get\_last\_error\_info`][] returns the information for the last Node-API call that was made. Do not rely on the content or format of any of the extended information as it is not subject to SemVer and may change at any time. It is...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ 0.021562889218330383, 0.11380654573440552, -0.013727911747992039, 0.02253233641386032, 0.056688107550144196, -0.04979275166988373, -0.030227702111005783, 0.059605974704027176, -0.03866162896156311, 0.0012572072446346283, 0.008759874850511551, -0.056856974959373474, 0.010948900133371353, -0...
0.189219
known that the exception can be safely handled. In these cases [`napi\_get\_and\_clear\_last\_exception`][] can be used to get and clear the exception. On success, result will contain the handle to the last JavaScript `Object` thrown. If it is determined, after retrieving the exception, the exception cannot be handled ...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.03428228944540024, 0.11722787469625473, 0.01689343899488449, 0.029336251318454742, 0.00882340781390667, -0.0033079986460506916, 0.021174311637878418, 0.019546041265130043, -0.004901915788650513, -0.07571747153997421, -0.02739619091153145, -0.01639418676495552, 0.009678197093307972, -0.0...
0.163582
JavaScript `RangeError` with the text provided. #### `node\_api\_throw\_syntax\_error` ```c NAPI\_EXTERN napi\_status node\_api\_throw\_syntax\_error(napi\_env env, const char\* code, const char\* msg); ``` \* `[in] env`: The environment that the API is invoked under. \* `[in] code`: Optional error code to be set on th...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.022507822141051292, 0.10336222499608994, 0.013831653632223606, 0.014330293983221054, 0.009381204843521118, -0.004403502214699984, 0.042607225477695465, 0.0796755775809288, -0.046941760927438736, -0.09236537665128708, -0.02747334912419319, -0.06926190108060837, 0.07621864974498749, 0.012...
0.159746
\* `[out] result`: Boolean value that is set to true if an exception is pending. Returns `napi\_ok` if the API succeeded. This API can be called even if there is a pending JavaScript exception. #### `napi\_fatal\_exception` ```c napi\_status napi\_fatal\_exception(napi\_env env, napi\_value err); ``` \* `[in] env`: The...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.06448444724082947, 0.10399181395769119, -0.017484517768025398, 0.044139374047517776, 0.019132070243358612, -0.0028015687130391598, 0.0340949110686779, 0.05191684141755104, -0.002960186917334795, -0.0514821894466877, 0.007509813643991947, -0.015392687171697617, 0.012092151679098606, 0.00...
0.221266
and all new handles will be associated with that scope while it is active. Scopes must be closed in the reverse order from which they are opened. In addition, all scopes created within a native method must be closed before returning from that method. Taking the earlier example, adding calls to [`napi\_open\_handle\_sco...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ 0.021275341510772705, 0.07705707103013992, -0.04913349822163582, 0.01663612201809883, -0.0942552238702774, -0.06710422784090042, 0.0637572854757309, -0.016365543007850647, -0.039733320474624634, 0.001293642446398735, -0.02857605181634426, -0.01592188887298107, -0.05400075018405914, -0.0409...
0.143863
called more than once an error will be returned. This API can be called even if there is a pending JavaScript exception. ### References to values with a lifespan longer than that of the native method In some cases, an addon will need to be able to create and reference values with a lifespan longer than that of a single...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.10944294184446335, 0.052229270339012146, -0.02612912282347679, 0.10756006091833115, -0.05172443389892578, -0.05703900009393692, -0.011777136474847794, 0.0026629031635820866, 0.10064515471458435, -0.024186812341213226, -0.04802807420492172, -0.0030923422891646624, -0.010227062739431858, ...
0.15574
Version 10 (`NAPI\_VERSION` is defined as `10` or higher): References can be created for all value types. The new supported value types do not support weak reference semantic and the values of these types are released when the reference count becomes 0 and cannot be accessed from the reference anymore. #### `napi\_crea...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.058812275528907776, 0.02768278680741787, -0.08434447646141052, -0.01406378485262394, -0.04927736148238182, -0.0005101261776871979, 0.03551929444074631, 0.01236431859433651, -0.003494862699881196, -0.07163098454475403, -0.003027914557605982, -0.09013349562883377, 0.02341427467763424, 0.0...
0.2173
done by using [`napi\_remove\_env\_cleanup\_hook`][]. Typically, that happens when the resource for which this hook was added is being torn down anyway. For asynchronous cleanup, [`napi\_add\_async\_cleanup\_hook`][] is available. #### `napi\_remove\_env\_cleanup\_hook` ```c NAPI\_EXTERN napi\_status napi\_remove\_env\...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.017473580315709114, 0.08123753219842911, -0.015897236764431, 0.0390983484685421, 0.048996783792972565, -0.04717493802309036, 0.007722951006144285, -0.07469363510608673, -0.008015121333301067, 0.0034978105686604977, -0.048999108374118805, 0.0059239668771624565, -0.028910163789987564, 0.0...
0.12905
desc = { "hello", NULL, Method, NULL, NULL, NULL, napi\_writable | napi\_enumerable | napi\_configurable, NULL }; status = napi\_define\_properties(env, exports, 1, &desc); if (status != napi\_ok) return NULL; return exports; } ``` To set a function to be returned by the `require()` for the addon: ```c napi\_value Init...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.05313713476061821, 0.07938093692064285, -0.12044715136289597, 0.013010083697736263, -0.08300270885229111, -0.007940675131976604, 0.06151985377073288, 0.03635898977518082, -0.10682666301727295, -0.037615567445755005, 0.04449840262532234, -0.10012594610452652, -0.03853336349129677, -0.015...
0.185851
works with bit operators to build a composite filter. #### `napi\_key\_conversion` ```c typedef enum { napi\_key\_keep\_numbers, napi\_key\_numbers\_to\_strings } napi\_key\_conversion; ``` `napi\_key\_numbers\_to\_strings` will convert integer indexes to strings. `napi\_key\_keep\_numbers` will return numbers for inte...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ 0.03437366709113121, 0.0780986025929451, -0.033263612538576126, -0.017972078174352646, -0.07976804673671722, -0.007321896497160196, 0.09512454271316528, 0.01063533779233694, -0.03349880874156952, -0.07719049602746964, -0.022785628214478493, -0.12423248589038849, 0.005834008101373911, -0.02...
0.224571
`napi\_create\_buffer` ```c napi\_status napi\_create\_buffer(napi\_env env, size\_t size, void\*\* data, napi\_value\* result) ``` \* `[in] env`: The environment that the API is invoked under. \* `[in] size`: Size in bytes of the underlying buffer. \* `[out] data`: Raw pointer to the underlying buffer. `data` can opti...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ 0.00028061747434549034, 0.08068951964378357, -0.06958974897861481, 0.012315364554524422, -0.08645576238632202, -0.07337076216936111, 0.04217187687754631, -0.016799958422780037, -0.008238164708018303, -0.034510958939790726, -0.019624868407845497, -0.05490082502365112, -0.011492040939629078, ...
0.178885
JavaScript `ArrayBuffer`. Returns `napi\_ok` if the API succeeded. \*\*Some runtimes other than Node.js have dropped support for external buffers\*\*. On runtimes other than Node.js this method may return `napi\_no\_external\_buffers\_allowed` to indicate that external buffers are not supported. One such runtime is Ele...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.06857969611883163, 0.053608156740665436, -0.005678572226315737, 0.04512307792901993, -0.026993514969944954, -0.05799074470996857, -0.04350646212697029, 0.0364583320915699, -0.02899392880499363, -0.06743822991847992, -0.04113342985510826, -0.05234713479876518, -0.06556305289268494, 0.008...
0.090241
`null`, or a `nullptr` that will be converted to `null`. \* `[in] property\_names`: Array of `napi\_value` representing the property names. \* `[in] property\_values`: Array of `napi\_value` representing the property values. \* `[in] property\_count`: Number of properties in the arrays. \* `[out] result`: A `napi\_valu...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.05822683125734329, 0.0729823112487793, -0.022403964772820473, 0.043743494898080826, -0.11427272856235504, -0.01214747503399849, 0.02487947605550289, -0.035073913633823395, 0.017304738983511925, -0.08985202014446259, -0.02190718613564968, -0.10099226981401443, 0.0066045052371919155, -0.0...
0.146383
bytes of the buffer to be created from the `ArrayBuffer`. \* \*\*`[out] result`\*\*: A `napi\_value` representing the created JavaScript `Buffer` object. Returns `napi\_ok` if the API succeeded. This API creates a JavaScript `Buffer` object from an existing `ArrayBuffer`. The `Buffer` object is a Node.js-specific class...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ 0.0036726491525769234, 0.015447014942765236, -0.0238462146371603, -0.03942059725522995, -0.10823062807321548, -0.05245189741253853, 0.04281865060329437, 0.04444229602813721, -0.03622312471270561, -0.08194499462842941, -0.05459309741854668, -0.02275250479578972, 0.013429422862827778, -0.047...
0.098651
in JavaScript. \* `[out] result`: A `napi\_value` representing a JavaScript `number`. Returns `napi\_ok` if the API succeeded. This API is used to convert from the C `double` type to the JavaScript `number` type. The JavaScript `number` type is described in [Section number type][] of the ECMAScript Language Specificati...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.03334081918001175, 0.09580030292272568, 0.018031742423772812, 0.009693118743598461, -0.03239418566226959, -0.01380634680390358, 0.0072357612662017345, 0.08157986402511597, 0.027846235781908035, -0.09153448790311813, -0.06764862686395645, -0.031143654137849808, 0.002105267019942403, 0.02...
0.211503
A `napi\_value` representing a JavaScript `string`. \* `[out] copied`: Whether the string was copied. If it was, the finalizer will already have been invoked to destroy `str`. Returns `napi\_ok` if the API succeeded. This API creates a JavaScript `string` value from an ISO-8859-1-encoded C string. The native string may...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.03937707468867302, 0.1031414270401001, -0.0057846191339194775, -0.025288676843047142, -0.07762307673692703, -0.033980660140514374, 0.016597889363765717, 0.05569072812795639, 0.015508178621530533, -0.11245749890804291, -0.016621548682451248, -0.05667810142040253, -0.0242831502109766, 0.0...
0.194537
including V8 use internalized strings as keys to set and get property values. They typically use a hash table to create and lookup such strings. While it adds some cost per key creation, it improves the performance after that by enabling comparison of string pointers instead of the whole strings. If a new JavaScript st...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.03558674082159996, 0.04913724586367607, -0.000819711945950985, 0.005025568418204784, -0.07715753465890884, -0.003097074804827571, -0.0029054624028503895, 0.05372912436723709, 0.021623658016324043, -0.08701271563768387, -0.016110528260469437, -0.03363949805498123, -0.0052783372811973095, ...
0.069009
succeeded. This API returns the length of an array. `Array` length is described in [Section Array instance length][] of the ECMAScript Language Specification. #### `napi\_get\_arraybuffer\_info` ```c napi\_status napi\_get\_arraybuffer\_info(napi\_env env, napi\_value arraybuffer, void\*\* data, size\_t\* byte\_length)...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ 0.03906982019543648, 0.10601309686899185, -0.052140012383461, -0.010414277203381062, -0.046139538288116455, -0.031830161809921265, 0.013831579126417637, 0.044853080064058304, -0.03187539055943489, -0.09954682737588882, -0.06638089567422867, -0.05129513144493103, -0.02021024189889431, -0.01...
0.191051
the array. Therefore, the first byte of the native array would be at `data - byte\_offset`. Returns `napi\_ok` if the API succeeded. This API returns various properties of a typed array. Any of the out parameters may be `NULL` if that property is unneeded. \_Warning\_: Use caution while using this API since the underly...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ 0.06106945127248764, 0.06190337613224983, -0.06401555240154266, -0.03760169446468353, -0.09497170150279999, -0.052739351987838745, 0.08574279397726059, 0.010429403744637966, -0.03542178124189377, -0.0606810562312603, -0.009810819290578365, -0.08304805308580399, -0.005180777050554752, -0.06...
0.1275
primitive equivalent of the given JavaScript `BigInt`. \* `[out] lossless`: Indicates whether the `BigInt` value was converted losslessly. Returns `napi\_ok` if the API succeeded. If a non-`BigInt` is passed in it returns `napi\_bigint\_expected`. This API returns the C `uint64\_t` primitive equivalent of the given Jav...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ 0.017600003629922867, 0.129165381193161, -0.0006582419155165553, 0.023607909679412842, -0.041998911648988724, -0.09194520115852356, 0.023875156417489052, 0.05318713188171387, -0.015270222909748554, -0.040041450411081314, -0.0528712272644043, -0.014299068599939346, 0.0067464327439665794, -0...
0.178908
`[in] bufsize`: Size of the destination buffer. When this value is insufficient, the returned string is truncated and null-terminated. If this value is zero, then the string is not returned and no changes are done to the buffer. \* `[out] result`: Number of bytes copied into the buffer, excluding the null terminator. R...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ 0.03195776417851448, 0.07667919993400574, -0.07655485719442368, -0.023887701332569122, -0.09267959743738174, -0.06288541108369827, 0.05785517767071724, 0.048161737620830536, -0.01778385601937771, -0.07623365521430969, -0.020390259101986885, -0.09417581558227539, 0.02032851055264473, -0.002...
0.177236
returns the `global` object. #### `napi\_get\_null` ```c napi\_status napi\_get\_null(napi\_env env, napi\_value\* result) ``` \* `[in] env`: The environment that the API is invoked under. \* `[out] result`: `napi\_value` representing JavaScript `null` object. Returns `napi\_ok` if the API succeeded. This API returns t...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.05674240365624428, 0.1062656044960022, -0.019169382750988007, 0.013402458280324936, -0.016211897134780884, -0.07057294249534607, -0.015880219638347626, -0.0008803945383988321, 0.01840195618569851, -0.09299879521131516, 0.0023712997790426016, -0.07286619395017624, -0.029528265818953514, ...
0.165877
```c napi\_status napi\_instanceof(napi\_env env, napi\_value object, napi\_value constructor, bool\* result) ``` \* `[in] env`: The environment that the API is invoked under. \* `[in] object`: The JavaScript value to check. \* `[in] constructor`: The JavaScript function object of the constructor function to check agai...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ 0.0044042798690497875, 0.10878553241491318, -0.0009672304149717093, -0.0008300825138576329, -0.02517952024936676, -0.07104532420635223, 0.06349718570709229, -0.032837577164173126, -0.023680029436945915, -0.06526470184326172, -0.06215362995862961, -0.06815507262945175, -0.02299186773598194, ...
0.2042
to check. \* `[in] rhs`: The JavaScript value to check against. \* `[out] result`: Whether the two `napi\_value` objects are equal. Returns `napi\_ok` if the API succeeded. This API represents the invocation of the Strict Equality algorithm as defined in [Section IsStrctEqual][] of the ECMAScript Language Specification...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.01404173206537962, 0.059832122176885605, -0.02751888893544674, -0.011436370201408863, -0.0014614745741710067, -0.08755538612604141, 0.04993981122970581, -0.06098609045147896, -0.024794239550828934, -0.09413640201091766, -0.036400146782398224, -0.02507513202726841, 0.011968868784606457, ...
0.189094
a `napi\_value` representing a `string`, `number`, or `symbol`. Node-API values are represented by the type `napi\_value`. Any Node-API call that requires a JavaScript value takes in a `napi\_value`. However, it's the caller's responsibility to make sure that the `napi\_value` in question is of the JavaScript type expe...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.0640469342470169, 0.12102567404508591, 0.020117467269301414, 0.05235275253653526, -0.060448773205280304, -0.007620209828019142, 0.03593209758400917, 0.002723621902987361, 0.051260631531476974, -0.08766499161720276, -0.08479344844818115, -0.029016466811299324, -0.02357216365635395, -0.00...
0.167142
in JS obj[prop]. napi\_default\_jsproperty = napi\_writable | napi\_enumerable | napi\_configurable, } napi\_property\_attributes; ``` `napi\_property\_attributes` are bit flags used to control the behavior of properties set on a JavaScript object. Other than `napi\_static` they correspond to the attributes listed in [...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.01716817170381546, 0.09575891494750977, -0.03643302991986275, 0.058590278029441833, -0.0006376352393999696, 0.003306227270513773, 0.07432974874973297, -0.021697191521525383, -0.03561224043369293, -0.08725619316101074, 0.00041545138810761273, -0.012129038572311401, -0.037601251155138016, ...
0.207089
`napi\_value` representing an array of JavaScript values that represent the property names of the object. The API can be used to iterate over `result` using [`napi\_get\_array\_length`][] and [`napi\_get\_element`][]. Returns `napi\_ok` if the API succeeded. This API returns the names of the enumerable properties of `o...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ 0.02134229801595211, 0.14667320251464844, -0.015786049887537956, 0.06732936203479767, -0.05405557528138161, -0.026489919051527977, 0.035087935626506805, -0.010922564193606377, 0.019190208986401558, -0.09352090954780579, -0.04366337135434151, -0.07856860756874084, 0.011922075413167477, -0.0...
0.143195
be a `string` or a `symbol`, or an error will be thrown. Node-API will not perform any conversion between data types. #### `napi\_set\_named\_property` ```c napi\_status napi\_set\_named\_property(napi\_env env, napi\_value object, const char\* utf8Name, napi\_value value); ``` \* `[in] env`: The environment that the N...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ 0.008110316470265388, 0.1183064803481102, -0.01900859735906124, 0.07437733560800552, -0.11778369545936584, -0.03073623590171337, 0.017380695790052414, 0.01819191873073578, -0.03381805121898651, -0.039657726883888245, -0.06579608470201492, -0.09839324653148651, 0.027787357568740845, -0.0325...
0.134031
```c napi\_status napi\_define\_properties(napi\_env env, napi\_value object, size\_t property\_count, const napi\_property\_descriptor\* properties); ``` \* `[in] env`: The environment that the Node-API call is invoked under. \* `[in] object`: The object from which to retrieve the properties. \* `[in] property\_count`...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.00787839200347662, 0.12590207159519196, -0.03071495331823826, 0.08790425211191177, -0.051006291061639786, -0.03146262839436531, 0.028949102386832237, -0.03728337213397026, 0.014095845632255077, -0.04246632754802704, -0.045745428651571274, -0.10618377476930618, 0.030584534630179405, -0.0...
0.159661
to be invoked. \* `[in] argc`: The count of elements in the `argv` array. \* `[in] argv`: Array of `napi\_values` representing JavaScript values passed in as arguments to the function. \* `[out] result`: `napi\_value` representing the JavaScript object returned. Returns `napi\_ok` if the API succeeded. This method allo...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.12042956799268723, 0.031827669590711594, -0.05883850157260895, 0.09670863300561905, -0.0739329382777214, -0.034097474068403244, 0.07805748283863068, -0.002539976267144084, 0.05551091954112053, -0.10694827884435654, -0.03395787626504898, 0.030613373965024948, -0.05255092680454254, -0.039...
0.188897
the `data` parameter can be associated with the resulting JavaScript function (which is returned in the `result` parameter) and freed whenever the function is garbage-collected by passing both the JavaScript function and the data to [`napi\_add\_finalizer`][]. JavaScript `Function`s are described in [Section Function o...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.0068204146809875965, 0.14576222002506256, -0.03131196275353432, 0.043036602437496185, -0.032554544508457184, -0.06910881400108337, 0.04546694830060005, 0.07488109916448593, -0.016702700406312943, -0.09232637286186218, -0.0057043335400521755, -0.04087817296385765, -0.018456928431987762, ...
0.234336
C++ classes and instances so that the class constructor and methods can be called from JavaScript. 1. The [`napi\_define\_class`][] API defines a JavaScript class with constructor, static properties and methods, and instance properties and methods that correspond to the C++ class. 2. When JavaScript code invokes the co...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.15311883389949799, 0.0664457380771637, -0.023155078291893005, 0.044130828231573105, -0.012546476908028126, -0.017061909660696983, 0.039947301149368286, -0.03879626840353012, 0.03128692880272865, -0.059249147772789, -0.007875648327171803, 0.021755574271082878, -0.06748581677675247, -0.04...
0.143408
the prototype of the database handle instance can be set to the prototype of the constructor for query handle instances. In this case, the database handle instance can appear as a query handle instance, and it will pass the `napi\_instanceof()` test for a query handle instance, while still containing a pointer to a dat...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.07606640458106995, 0.023739034309983253, 0.012981213629245758, 0.11846797913312912, -0.00748168071731925, -0.0330561101436615, 0.07993026077747345, 0.014999622479081154, 0.045760948210954666, -0.07069501280784607, -0.07664678245782852, 0.007052074186503887, 0.00007122609531506896, -0.01...
0.191846
the class. When wrapping a C++ class, this method must be a static member with the [`napi\_callback`][] signature. A C++ class constructor cannot be used. [`napi\_callback`][] provides more details. \* `[in] data`: Optional data to be passed to the constructor callback as the `data` property of the callback info. \* `[...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.09719420224428177, 0.10890066623687744, -0.04663390293717384, 0.07165279984474182, -0.08455660194158554, -0.011282979510724545, 0.05396927893161774, 0.003265895415097475, -0.010656730271875858, -0.07299116998910904, 0.011649915017187595, 0.007313001900911331, -0.007687282282859087, -0.0...
0.149569
instance of the native class, the callback must then call `napi\_wrap()` to wrap the newly constructed instance in the already-created JavaScript object that is the `this` argument to the constructor callback. (That `this` object was created from the constructor function's `prototype`, so it already has definitions of ...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.10245900601148605, 0.044830307364463806, 0.011940197087824345, 0.04966483265161514, 0.02671017497777939, -0.032622553408145905, 0.06496245414018631, -0.017237866297364235, 0.04899591952562332, -0.059684548527002335, 0.016622763127088547, 0.0336998775601387, -0.0797232985496521, -0.02237...
0.124344
tag, this API will return `napi\_invalid\_arg`. ### `napi\_check\_object\_type\_tag` ```c napi\_status napi\_check\_object\_type\_tag(napi\_env env, napi\_value js\_object, const napi\_type\_tag\* type\_tag, bool\* result); ``` \* `[in] env`: The environment that the API is invoked under. \* `[in] js\_object`: The Java...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.06345817446708679, 0.10069551318883896, -0.023063359782099724, 0.027225328609347343, 0.04237726703286171, -0.0838681161403656, 0.07573691755533218, 0.025947220623493195, -0.01299439650028944, -0.08494611084461212, -0.0658479779958725, -0.04461243748664856, -0.03412964940071106, 0.056717...
0.232223
supporting functions which covers the most common asynchronous use cases. Node-API defines the `napi\_async\_work` structure which is used to manage asynchronous workers. Instances are created/deleted with [`napi\_create\_async\_work`][] and [`napi\_delete\_async\_work`][]. The `execute` and `complete` callbacks are fu...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.10420350730419159, 0.05744636431336403, -0.050270043313503265, 0.07739958167076111, -0.000892437354195863, -0.06256109476089478, -0.08899902552366257, -0.026359587907791138, 0.07818085700273514, -0.04259300231933594, -0.029631484299898148, 0.031076006591320038, -0.0681285485625267, -0.0...
0.196825
API is invoked under. \* `[in] work`: The handle returned by the call to `napi\_create\_async\_work`. Returns `napi\_ok` if the API succeeded. This API requests that the previously allocated work be scheduled for execution. Once it returns successfully, this API must not be called again with the same `napi\_async\_work...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.11583524197340012, 0.07726488262414932, -0.08245030045509338, 0.06944692134857178, -0.015833748504519463, -0.08552692085504532, -0.006974546704441309, -0.08708622306585312, 0.07883114367723465, -0.03668205440044403, -0.011968831531703472, 0.026052342727780342, -0.031114455312490463, -0....
0.205705
`[in] func`: `napi\_value` representing the JavaScript function to be invoked. \* `[in] argc`: The count of elements in the `argv` array. \* `[in] argv`: Array of JavaScript values as `napi\_value` representing the arguments to the function. If `argc` is zero this parameter may be omitted by passing in `NULL`. \* `[out...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.10668714344501495, 0.05267665535211563, -0.07754398882389069, 0.11100489646196365, -0.025699298828840256, -0.05697985738515854, 0.06257471442222595, -0.014657541178166866, 0.020364968106150627, -0.09410257637500763, -0.037718258798122406, -0.0326436348259449, -0.04045679420232773, -0.05...
0.173333
of Node.js that support it, while providing fallback behavior when running with Node.js versions that don't support it: \* Call `napi\_get\_version()` to determine if the API is available. \* If available, dynamically load a pointer to the function using `uv\_dlsym()`. \* Use the dynamically loaded pointer to invoke th...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.047771185636520386, 0.05721885338425636, -0.005271944683045149, 0.06494611501693726, 0.03372751921415329, -0.0274832621216774, -0.04751790687441826, 0.06182298809289932, -0.009456465020775795, -0.03132406622171402, -0.02530474029481411, 0.042318783700466156, -0.030715638771653175, -0.01...
0.159867
can later be passed to `napi\_resolve\_deferred()` or `napi\_reject\_deferred()` to resolve resp. reject the associated promise. \* `[out] promise`: The JavaScript promise associated with the deferred object. Returns `napi\_ok` if the API succeeded. This API creates a deferred object and a JavaScript promise. ### `napi...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.15766587853431702, 0.09301751852035522, 0.02630520798265934, 0.018948765471577644, -0.03103070706129074, -0.03384416550397873, -0.012589747086167336, -0.012809572741389275, 0.07769542932510376, -0.0660543367266655, -0.03326302021741867, 0.040088605135679245, 0.0063504064455628395, 0.004...
0.180746
libuv has been relatively stable over time, it does not provide an ABI stability guarantee. Use of this function should be avoided. Its use may result in an addon that does not work across Node.js versions. [asynchronous-thread-safe-function-calls](https://nodejs.org/docs/latest/api/n-api.html#asynchronous-thread-safe-...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.11951197683811188, -0.05435853824019432, 0.0016542782541364431, 0.01720684953033924, 0.06034720689058304, -0.02361915074288845, -0.05699015036225319, -0.03587529808282852, 0.04266444593667984, -0.03803245723247528, -0.056540317833423615, 0.04197420924901962, -0.05177551880478859, -0.065...
0.073929
are no longer possible, while items remain in the queue that may need to be freed. This normally occurs when the Node.js process exits while there is a thread-safe function still active. It is not necessary to call into JavaScript via `napi\_make\_callback()` because Node-API runs `call\_js\_cb` in a context appropriat...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.1094871386885643, 0.0018325929995626211, -0.051220882683992386, 0.05951390415430069, 0.004192919470369816, -0.008222565054893494, 0.024626504629850388, -0.07696754485368729, 0.11982984095811844, -0.023443561047315598, -0.04138697683811188, 0.07165170460939407, 0.00046506489161401987, -0...
0.193139
\* `[in] env`: The environment that the API is invoked under. \* `[in] func`: An optional JavaScript function to call from another thread. It must be provided if `NULL` is passed to `call\_js\_cb`. \* `[in] async\_resource`: An optional object associated with the async work that will be passed to possible `async\_hooks...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.11396938562393188, 0.026596583425998688, -0.08752653002738953, 0.04703536257147789, -0.01534861046820879, -0.09190904349088669, 0.11832159012556076, 0.01605854742228985, 0.003965109121054411, -0.0704970732331276, -0.018035097047686577, -0.029815498739480972, -0.0006271658930927515, -0.0...
0.201167
the current thread will make no further calls to the thread-safe function, or `napi\_tsfn\_abort` to indicate that in addition to the current thread, no other thread should make any further calls to the thread-safe function. If set to `napi\_tsfn\_abort`, further calls to `napi\_call\_threadsafe\_function()` will retur...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.08796589821577072, 0.003006434766575694, -0.06975054740905762, -0.0246894434094429, 0.001007726532407105, -0.04223468527197838, 0.05735572800040245, -0.0665651187300682, 0.02598220482468605, -0.006669447757303715, 0.018012966960668564, -0.04400583356618881, -0.051439329981803894, -0.019...
0.189674
[`napi\_close\_callback\_scope`]: #napi\_close\_callback\_scope [`napi\_close\_escapable\_handle\_scope`]: #napi\_close\_escapable\_handle\_scope [`napi\_close\_handle\_scope`]: #napi\_close\_handle\_scope [`napi\_create\_async\_work`]: #napi\_create\_async\_work [`napi\_create\_error`]: #napi\_create\_error [`napi\_cr...
https://github.com/nodejs/node/blob/main//doc/api/n-api.md
main
nodejs
[ -0.0470927469432354, 0.03785688057541847, -0.11318910121917725, 0.021302999928593636, -0.06382657587528229, -0.06934966892004013, 0.06299711018800735, -0.013099719770252705, -0.004737635143101215, -0.042790062725543976, -0.008200759999454021, -0.079280786216259, -0.03635607659816742, -0.00...
0.161662
# Diagnostic report > Stability: 2 - Stable Delivers a JSON-formatted diagnostic summary, written to a file. The report is intended for development, test, and production use, to capture and preserve information for problem determination. It includes JavaScript and native stack traces, heap statistics, platform informat...
https://github.com/nodejs/node/blob/main//doc/api/report.md
main
nodejs
[ -0.03155870735645294, 0.04952438548207283, -0.07357687503099442, 0.08114887028932571, 0.05973784625530243, -0.019237907603383064, -0.05317432060837746, 0.11818104237318039, -0.017385419458150864, -0.0009436236578039825, -0.010711691342294216, -0.00016617953951936215, 0.03630038723349571, 0...
0.163263
}, { "type": "idle", "is\_active": false, "is\_referenced": true, "address": "0x00007fff5fbfebc0" }, { "type": "prepare", "is\_active": false, "is\_referenced": false, "address": "0x00007fff5fbfec38" }, { "type": "check", "is\_active": false, "is\_referenced": false, "address": "0x00007fff5fbfecb0" }, { "type": "async"...
https://github.com/nodejs/node/blob/main//doc/api/report.md
main
nodejs
[ -0.027484282851219177, 0.021915489807724953, -0.08434611558914185, 0.11684130877256393, 0.001123656751587987, -0.05107993632555008, 0.06301713734865189, -0.03608906269073486, 0.019853761419653893, -0.011712317354977131, -0.028296707198023796, -0.049911774694919586, -0.0058882287703454494, ...
0.117825
consumption. \* `--report-directory` Location at which the report will be generated. \* `--report-filename` Name of the file to which the report will be written. \* `--report-signal` Sets or resets the signal for report generation (not supported on Windows). Default signal is `SIGUSR2`. \* `--report-exclude-network` Ex...
https://github.com/nodejs/node/blob/main//doc/api/report.md
main
nodejs
[ -0.007025266066193581, 0.0322473868727684, -0.07412528991699219, 0.08036143332719803, 0.03963159769773483, -0.0011150374775752425, -0.028946008533239365, 0.06007172539830208, 0.011727464385330677, -0.023135956376791, -0.00317776040174067, 0.006882910616695881, 0.03894837573170662, -0.01155...
0.044152
in the `userLimits` section, as these values are given in bytes. ```json { "userLimits": { // Skip some keys ... "data\_seg\_size\_bytes": { // replacing data\_seg\_size\_kbytes "soft": "unlimited", "hard": "unlimited" }, // ... "max\_memory\_size\_bytes": { // replacing max\_memory\_size\_kbytes "soft": "unlimited", "...
https://github.com/nodejs/node/blob/main//doc/api/report.md
main
nodejs
[ 0.005882115103304386, 0.0375773087143898, -0.05222398415207863, -0.02660983055830002, -0.0018934388644993305, -0.057658687233924866, 0.023724593222141266, 0.04622269794344902, -0.01289066206663847, -0.02386840432882309, 0.03506957367062569, 0.002004403155297041, 0.0027036836836487055, -0.0...
0.081623
in the standard report format. The thread which is generating the report will wait for the reports from Worker threads to finish. However, the latency for this will usually be low, as both running JavaScript and the event loop are interrupted to generate the report. [`Worker`]: worker\_threads.md [`process API document...
https://github.com/nodejs/node/blob/main//doc/api/report.md
main
nodejs
[ -0.07156629860401154, 0.016766440123319626, -0.11042369902133942, 0.054148491472005844, 0.04969143122434616, -0.029582468792796135, -0.08015350997447968, -0.025148574262857437, 0.0990012139081955, 0.0076461974531412125, -0.02223709225654602, 0.05994052812457085, -0.012864968739449978, -0.0...
0.132057
# String decoder > Stability: 2 - Stable The `node:string\_decoder` module provides an API for decoding `Buffer` objects into strings in a manner that preserves encoded multi-byte UTF-8 and UTF-16 characters. It can be accessed using: ```mjs import { StringDecoder } from 'node:string\_decoder'; ``` ```cjs const { Strin...
https://github.com/nodejs/node/blob/main//doc/api/string_decoder.md
main
nodejs
[ -0.005371804349124432, 0.020492132753133774, -0.0450509749352932, -0.0041944729164242744, -0.04104958847165108, -0.05159217119216919, -0.0035255944821983576, 0.06570645421743393, 0.027163216844201088, -0.027237996459007263, -0.030461231246590614, -0.03257817029953003, 0.0062808385118842125, ...
0.078785
# Path > Stability: 2 - Stable The `node:path` module provides utilities for working with file and directory paths. It can be accessed using: ```cjs const path = require('node:path'); ``` ```mjs import path from 'node:path'; ``` ## Windows vs. POSIX The default operation of the `node:path` module varies based on the op...
https://github.com/nodejs/node/blob/main//doc/api/path.md
main
nodejs
[ -0.06645947694778442, 0.0027339444495737553, -0.011095819063484669, 0.06097820773720741, 0.032893430441617966, -0.03668994829058647, -0.04029686376452446, 0.08627273887395859, 0.04849674925208092, -0.026423882693052292, -0.03516815975308418, 0.07636712491512299, -0.002616459270939231, 0.01...
0.060754
`ext` {string} \* Returns: {string} The `path.format()` method returns a path string from an object. This is the opposite of [`path.parse()`][]. When providing properties to the `pathObject` remember that there are combinations where one property has priority over another: \* `pathObject.root` is ignored if `pathObject...
https://github.com/nodejs/node/blob/main//doc/api/path.md
main
nodejs
[ -0.0377468466758728, 0.09821570664644241, -0.022017192095518112, 0.08443716168403625, -0.06842772662639618, -0.05106247216463089, 0.00459186639636755, 0.13474713265895844, 0.07237525284290314, -0.026568779721856117, 0.010649912990629673, 0.02813217043876648, -0.06350470334291458, 0.0375753...
0.07372
will replace two leading forward slashes with a single slash as if it was a regular absolute path, whereas a few POSIX systems assign special meaning to paths beginning with exactly two forward slashes. Similarly, other substitutions performed by this function, such as removing `..` segments, may change how the underly...
https://github.com/nodejs/node/blob/main//doc/api/path.md
main
nodejs
[ -0.036839697510004044, 0.006434490438550711, 0.04562478885054588, 0.05119699612259865, -0.057996101677417755, -0.050664033740758896, -0.045485906302928925, 0.04133794084191322, 0.06321322917938232, -0.005567651707679033, 0.03782200440764427, 0.016300177201628685, -0.030983831733465195, 0.0...
0.074807
to the root directory. Zero-length `path` segments are ignored. If no `path` segments are passed, `path.resolve()` will return the absolute path of the current working directory. ```js path.resolve('/foo/bar', './baz'); // Returns: '/foo/bar/baz' path.resolve('/foo/bar', '/tmp/file/'); // Returns: '/tmp/file' path.reso...
https://github.com/nodejs/node/blob/main//doc/api/path.md
main
nodejs
[ -0.061341121792793274, 0.007299638353288174, 0.032865140587091446, -0.0007117980276234448, -0.0032904965337365866, -0.10943026840686798, -0.01465025544166565, 0.14347538352012634, 0.0705019161105156, -0.02662038803100586, 0.029827337712049484, 0.06697793304920197, -0.0011234133271500468, 0...
0.0429
# Worker threads > Stability: 2 - Stable The `node:worker\_threads` module enables the use of threads that execute JavaScript in parallel. To access it: ```mjs import worker\_threads from 'node:worker\_threads'; ``` ```cjs 'use strict'; const worker\_threads = require('node:worker\_threads'); ``` Workers (threads) are ...
https://github.com/nodejs/node/blob/main//doc/api/worker_threads.md
main
nodejs
[ -0.06924428790807724, -0.005231431219726801, -0.03458986431360245, 0.0959927961230278, 0.03343535214662552, -0.10745995491743088, -0.02814258635044098, 0.017780762165784836, -0.014325300231575966, -0.004209715873003006, -0.07105681300163269, 0.08851034939289093, -0.014046109281480312, -0.0...
0.206297
from 'node:worker\_threads'; if (isMainThread) { // This re-loads the current file inside a Worker instance. new Worker(new URL(import.meta.url)); } else { console.log('Inside Worker!'); console.log(isMainThread); // Prints 'false'. } ``` ```cjs 'use strict'; const { Worker, isMainThread } = require('node:worker\_threa...
https://github.com/nodejs/node/blob/main//doc/api/worker_threads.md
main
nodejs
[ -0.09393788874149323, 0.042629193514585495, 0.01675405539572239, 0.0211953092366457, 0.08074236661195755, -0.11331150680780411, 0.030484642833471298, -0.021415051072835922, 0.041503019630908966, 0.02859223447740078, -0.04416963458061218, 0.05114158242940903, -0.09690846502780914, -0.035171...
0.117975
strict'; const { markAsUncloneable } = require('node:worker\_threads'); const anyObject = { foo: 'bar' }; markAsUncloneable(anyObject); const { port1 } = new MessageChannel(); try { // This will throw an error, because anyObject is not cloneable. port1.postMessage(anyObject); } catch (error) { // error.name === 'DataCl...
https://github.com/nodejs/node/blob/main//doc/api/worker_threads.md
main
nodejs
[ -0.07946646958589554, -0.028075912967324257, -0.003909686114639044, 0.06015387922525406, -0.007159201428294182, -0.07562550157308578, 0.035704515874385834, -0.013712338171899319, -0.02046283334493637, -0.0408206470310688, 0.005558175500482321, -0.06900642812252045, 0.020530525594949722, 0....
0.161695
threads, the last one will try to communicate with the main thread. ```mjs import process from 'node:process'; import { postMessageToThread, threadId, workerData, Worker, } from 'node:worker\_threads'; const channel = new BroadcastChannel('sync'); const level = workerData?.level ?? 0; if (level < 10) { const worker = n...
https://github.com/nodejs/node/blob/main//doc/api/worker_threads.md
main
nodejs
[ 0.021094629541039467, -0.022089963778853416, 0.023404790088534355, -0.008893785066902637, 0.013354051858186722, -0.06980487704277039, 0.026846351101994514, -0.029070019721984863, 0.04749756306409836, -0.027393922209739685, -0.0656476616859436, -0.011586746200919151, -0.006167578510940075, ...
0.099863
for the `key` will be deleted. The `worker.setEnvironmentData()` API sets the content of `worker.getEnvironmentData()` in the current thread and all new `Worker` instances spawned from the current context. ## `worker\_threads.threadId` \* Type: {integer} An integer identifier for the current thread. On the correspondin...
https://github.com/nodejs/node/blob/main//doc/api/worker_threads.md
main
nodejs
[ -0.10015122592449188, 0.02817448601126671, -0.07050948590040207, 0.0026013513561338186, -0.002131704706698656, -0.09743355214595795, 0.05312955752015114, -0.09257124364376068, 0.006518997717648745, -0.010098656639456749, -0.023340260609984398, 0.04436545819044113, 0.005166633054614067, -0....
0.085994
for the current process. ```mjs import { locks } from 'node:worker\_threads'; const snapshot = await locks.query(); for (const lock of snapshot.held) { console.log(`held lock: name ${lock.name}, mode ${lock.mode}`); } for (const pending of snapshot.pending) { console.log(`pending lock: name ${pending.name}, mode ${pend...
https://github.com/nodejs/node/blob/main//doc/api/worker_threads.md
main
nodejs
[ -0.03581249713897705, 0.01708122529089451, -0.03580182045698166, 0.03140454366803169, 0.02738850936293602, -0.04769797995686531, 0.05085059255361557, -0.026562927290797234, 0.04159014672040939, 0.03370002657175064, -0.003290878375992179, 0.038412317633628845, -0.0128556489944458, -0.048231...
0.048233
// Prints: // foobar // closed! port2.on('message', (message) => console.log(message)); port2.once('close', () => console.log('closed!')); port1.postMessage('foobar'); port1.close(); ``` ```cjs 'use strict'; const { MessageChannel } = require('node:worker\_threads'); const { port1, port2 } = new MessageChannel(); // Pr...
https://github.com/nodejs/node/blob/main//doc/api/worker_threads.md
main
nodejs
[ 0.007890417240560055, 0.004707548301666975, 0.007699090521782637, 0.02419242262840271, -0.012201821431517601, -0.05869096517562866, 0.03533677011728287, -0.012983825989067554, 0.07326426357030869, -0.04650415480136871, 0.02364777773618698, -0.021324697881937027, -0.01716841384768486, -0.02...
0.084677
to the receiver. // This can be used, for example, to create communication channels between // multiple `Worker` threads that are children of the same parent thread. const otherChannel = new MessageChannel(); port2.postMessage({ port: otherChannel.port1 }, [ otherChannel.port1 ]); ``` ```cjs 'use strict'; const { Messa...
https://github.com/nodejs/node/blob/main//doc/api/worker_threads.md
main
nodejs
[ -0.032594114542007446, -0.021700533106923103, -0.050927240401506424, 0.025504376739263535, -0.06287913769483566, -0.05251016095280647, 0.008638710714876652, -0.024965785443782806, 0.00992679689079523, -0.0639052465558052, -0.04179712384939194, 0.008264252915978432, -0.03747370094060898, 0....
0.124715
this.c = 3; } get d() { return 4; } } const { port1, port2 } = new MessageChannel(); port1.onmessage = ({ data }) => console.log(data); port2.postMessage(new Foo()); // Prints: { c: 3 } ``` This limitation extends to many built-in objects, such as the global `URL` object: ```js const { port1, port2 } = new MessageChann...
https://github.com/nodejs/node/blob/main//doc/api/worker_threads.md
main
nodejs
[ -0.019152797758579254, 0.005846165120601654, 0.04987422749400139, 0.0433221310377121, 0.028551097959280014, -0.10691338777542114, 0.00554510997608304, -0.03177507594227791, 0.09407875686883926, -0.05114133283495903, -0.011557957157492638, 0.04230229929089546, -0.046693190932273865, 0.01514...
0.076008
the parent side is not directly exposed, its functionalities are exposed through [`worker.postMessage()`][] and the [`worker.on('message')`][] event on the `Worker` object for the parent thread. To create custom messaging channels (which is encouraged over using the default global channel because it facilitates separat...
https://github.com/nodejs/node/blob/main//doc/api/worker_threads.md
main
nodejs
[ -0.029642529785633087, -0.02495591714978218, 0.081180639564991, 0.045160453766584396, 0.019679896533489227, -0.08305887877941132, 0.05566122382879257, -0.015343447215855122, 0.055081821978092194, -0.03439284861087799, -0.03346298635005951, 0.039218559861183167, -0.016622330993413925, 0.030...
0.133099
in the parent. \* `workerData` {any} Any JavaScript value that is cloned and made available as [`require('node:worker\_threads').workerData`][]. The cloning occurs as described in the [HTML structured clone algorithm][], and an error is thrown if the object cannot be cloned (e.g. because it contains `function`s). \* `t...
https://github.com/nodejs/node/blob/main//doc/api/worker_threads.md
main
nodejs
[ -0.13618117570877075, 0.017062274739146233, -0.019977042451500893, 0.06544460356235504, 0.11287296563386917, -0.1057901605963707, 0.05053021386265755, -0.05911823734641075, 0.03588530048727989, 0.009922871366143227, 0.008893375284969807, 0.029162948951125145, -0.027851136401295662, -0.0411...
0.223603
the actual thread. ### `worker.getHeapSnapshot([options])` \* `options` {Object} \* `exposeInternals` {boolean} If true, expose internals in the heap snapshot. \*\*Default:\*\* `false`. \* `exposeNumericValues` {boolean} If true, expose numeric values in artificial fields. \*\*Default:\*\* `false`. \* Returns: {Promise...
https://github.com/nodejs/node/blob/main//doc/api/worker_threads.md
main
nodejs
[ -0.1259980946779251, 0.07910327613353729, 0.003317215945571661, 0.0665544793009758, 0.06965648382902145, -0.10889144241809845, -0.04979875683784485, -0.0045825340785086155, 0.013198455795645714, -0.031638823449611664, -0.0706329196691513, -0.04318505898118019, -0.051862504333257675, -0.007...
0.117306
Starting a CPU profile then return a Promise that fulfills with an error or an `CPUProfileHandle` object. This API supports `await using` syntax. ```cjs const { Worker } = require('node:worker\_threads'); const worker = new Worker(` const { parentPort } = require('worker\_threads'); parentPort.on('message', () => {}); ...
https://github.com/nodejs/node/blob/main//doc/api/worker_threads.md
main
nodejs
[ -0.06126270070672035, 0.052942827343940735, -0.027728253975510597, 0.0894249677658081, 0.027798855677247047, -0.05261122062802315, 0.014602020382881165, 0.10758428275585175, -0.02836122177541256, -0.051095567643642426, -0.019854307174682617, -0.036339256912469864, -0.05174713954329491, -0....
0.066297
with `stdio`. This means that `stdio` output originating from a `Worker` can get blocked by synchronous code on the receiving end that is blocking the Node.js event loop. ```mjs import { Worker, isMainThread, } from 'node:worker\_threads'; if (isMainThread) { new Worker(new URL(import.meta.url)); for (let n = 0; n < 1e...
https://github.com/nodejs/node/blob/main//doc/api/worker_threads.md
main
nodejs
[ -0.06025318056344986, 0.025810740888118744, -0.02484099194407463, -0.010918567888438702, 0.05048613250255585, -0.08350397646427155, -0.02821245789527893, -0.031887173652648926, 0.0010812419932335615, -0.007372522260993719, -0.037855107337236404, 0.04561403766274452, -0.07826334238052368, -...
0.112179
# Modules: `node:module` API ## The `Module` object \* Type: {Object} Provides general utility methods when interacting with instances of `Module`, the [`module`][] variable often seen in [CommonJS][] modules. Accessed via `import 'node:module'` or `require('node:module')`. ### `module.builtinModules` \* Type: {string\...
https://github.com/nodejs/node/blob/main//doc/api/module.md
main
nodejs
[ -0.071896031498909, 0.016375703737139702, -0.022875988855957985, 0.07386341691017151, 0.0783470869064331, -0.041144028306007385, 0.012981930747628212, 0.03838743641972542, -0.013756604865193367, -0.09124356508255005, -0.00046204033424146473, 0.01436151098459959, 0.0032047443091869354, 0.02...
0.114206
\* Returns: {boolean} returns true if the module is builtin else returns false ```mjs import { isBuiltin } from 'node:module'; isBuiltin('node:fs'); // true isBuiltin('fs'); // true isBuiltin('wss'); // false ``` ### `module.register(specifier[, parentURL][, options])` > Stability: 1.1 - Active development \* `specifie...
https://github.com/nodejs/node/blob/main//doc/api/module.md
main
nodejs
[ -0.05403938889503479, 0.03684446960687637, -0.015035984106361866, 0.08045224100351334, 0.10705091804265976, -0.0074052102863788605, 0.0171376820653677, 0.04317379742860794, -0.0507790744304657, 0.007350016385316849, 0.0003601963398978114, -0.05939313769340515, 0.009662581607699394, 0.03649...
0.051947
{ stripTypeScriptTypes } = require('node:module'); const code = 'const a: number = 1;'; const strippedCode = stripTypeScriptTypes(code, { mode: 'strip', sourceUrl: 'source.ts' }); console.log(strippedCode); // Prints: const a = 1\n\n//# sourceURL=source.ts; ``` When `mode` is `'transform'`, the code is transformed to J...
https://github.com/nodejs/node/blob/main//doc/api/module.md
main
nodejs
[ -0.08569993078708649, 0.029632598161697388, 0.062134694308042526, 0.052236590534448624, -0.02604079246520996, -0.009030978195369244, 0.017340587452054024, -0.0007027690880931914, 0.03645522519946098, -0.003940925933420658, 0.005499719642102718, 0.03283393755555153, -0.027635719627141953, 0...
0.046363
be used to ensure the accumulated code cache is flushed to disk in case the application wants to spawn other Node.js instances and let them share the cache long before the parent exits. The compile cache layout on disk is an implementation detail and should not be relied upon. The compile cache generated is typically o...
https://github.com/nodejs/node/blob/main//doc/api/module.md
main
nodejs
[ -0.0400979109108448, -0.0023512626066803932, 0.010674932040274143, -0.01133816596120596, 0.09348291903734207, -0.03389759361743927, -0.051369670778512955, 0.019559727981686592, 0.06789348274469376, 0.014074415899813175, 0.02497817762196064, 0.13087482750415802, -0.04259638115763664, -0.032...
-0.007254
so that the cache can be reused even if the project directory is moved. This is a best-effort feature. If not specified, it will depend on whether the environment variable [`NODE\_COMPILE\_CACHE\_PORTABLE=1`][] is set. \* Returns: {Object} \* `status` {integer} One of the [`module.constants.compileCacheStatus`][] \* `m...
https://github.com/nodejs/node/blob/main//doc/api/module.md
main
nodejs
[ -0.01953488029539585, 0.04700475558638573, -0.01026102714240551, 0.034022267907857895, 0.05315360426902771, -0.026500312611460686, 0.02268681675195694, 0.000021641057173837908, 0.04426390677690506, -0.01264934428036213, 0.018504440784454346, 0.08731493353843689, -0.053214531391859055, -0.0...
0.08801
runs with flags The hooks can be registered before the application code is run by using the [`--import`][] or [`--require`][] flag: ```bash node --import ./register-hooks.js ./my-app.js node --require ./register-hooks.js ./my-app.js ``` The specifier passed to `--import` or `--require` can also come from a package: ```...
https://github.com/nodejs/node/blob/main//doc/api/module.md
main
nodejs
[ -0.05425048992037773, -0.04401400685310364, -0.036075443029403687, 0.029616935178637505, 0.06462888419628143, -0.005396721884608269, 0.04524461179971695, 0.03445329889655113, 0.006791388615965843, -0.020134873688220978, -0.040169600397348404, 0.010811759158968925, -0.016461241990327835, -0...
0.087519
Node.js default `resolve` ← `hook1.resolve` ← `hook2.resolve` The same applies to all the other hooks. A hook that returns a value lacking a required property triggers an exception. A hook that returns without calling `next()` \_and\_ without returning `shortCircuit: true` also triggers an exception. These errors are t...
https://github.com/nodejs/node/blob/main//doc/api/module.md
main
nodejs
[ -0.07186700403690338, -0.007692386396229267, 0.0986851155757904, 0.03844648599624634, -0.027646036818623543, -0.038449570536613464, -0.0835733413696289, 0.051741328090429306, 0.03943528234958649, -0.032156795263290405, -0.011830616742372513, 0.03324728086590767, 0.000619910133536905, -0.07...
0.024596
than were present in the source code. The `conditions` property in `context` is an array of conditions that will be used to match [package exports conditions][Conditional exports] for this resolution request. They can be used for looking up conditional mappings elsewhere or to modify the list when calling the default r...
https://github.com/nodejs/node/blob/main//doc/api/module.md
main
nodejs
[ -0.06058681011199951, 0.059770114719867706, 0.06597154587507248, 0.0037947725504636765, 0.02642357163131237, -0.011276043951511383, -0.016525693237781525, 0.08789890259504318, 0.0058234320022165775, 0.00702274264767766, 0.00482212333008647, -0.05773637816309929, 0.023207437247037888, -0.02...
0.068777
'string' ? result.source : Buffer.from(result.source).toString('utf8'); return { source: source.replace(/foo/g, 'bar'), ...result, }; } registerHooks({ resolve }); ``` In a more advanced scenario, this can also be used to transform an unsupported source to a supported one (see [Examples](#examples) below). ##### Accept...
https://github.com/nodejs/node/blob/main//doc/api/module.md
main
nodejs
[ -0.05337681248784065, 0.0421660915017128, 0.005812241695821285, 0.027884624898433685, -0.13721486926078796, 0.022107912227511406, -0.03196217119693756, 0.062407515943050385, 0.027209660038352013, -0.02857283130288124, -0.101639524102211, -0.07073860615491867, -0.006670194678008556, -0.0591...
-0.000063
by `--import` or `--require`, or called directly within the entry point. ```mjs // Use module.register() to register asynchronous hooks in a dedicated thread. import { register } from 'node:module'; register('./hooks.mjs', import.meta.url); // If my-app.mjs is loaded statically here as `import './my-app.mjs'`, since ES...
https://github.com/nodejs/node/blob/main//doc/api/module.md
main
nodejs
[ -0.043172020465135574, -0.033268142491579056, 0.010907852090895176, 0.04576793313026428, 0.0377214178442955, -0.02994409389793873, -0.005029828287661076, 0.06184530258178711, -0.04099734127521515, -0.02674667350947857, -0.010971431620419025, -0.012223221361637115, 0.013662870042026043, -0....
0.067528
the threads. The `register` method can be used to pass data to an [`initialize`][] hook. The data passed to the hook may include transferable objects like ports. ```mjs import { register } from 'node:module'; import { MessageChannel } from 'node:worker\_threads'; // This example demonstrates how a message channel can b...
https://github.com/nodejs/node/blob/main//doc/api/module.md
main
nodejs
[ -0.014168789610266685, -0.024161560460925102, -0.003916206303983927, 0.07985830307006836, -0.02166622318327427, -0.0533439926803112, 0.056684453040361404, 0.0315263569355011, -0.018227163702249527, -0.04930869862437248, -0.016360050067305565, -0.001171223702840507, -0.03730389475822449, 0....
0.123408
}, transferList: [port2], }); ``` ```cjs const assert = require('node:assert'); const { register } = require('node:module'); const { pathToFileURL } = require('node:url'); const { MessageChannel } = require('node:worker\_threads'); // This example showcases how a message channel can be used to communicate // between th...
https://github.com/nodejs/node/blob/main//doc/api/module.md
main
nodejs
[ -0.0601402148604393, -0.01907774992287159, 0.0012408255133777857, 0.01884475350379944, -0.008462621830403805, -0.06767478585243225, 0.023422017693519592, 0.02542698010802269, 0.009174085222184658, -0.038166847079992294, -0.012567855417728424, 0.011253404431045055, -0.03582366555929184, -0....
0.108101
nextLoad)` \* `url` {string} The URL returned by the `resolve` chain \* `context` {Object} \* `conditions` {string\[]} Export conditions of the relevant `package.json` \* `format` {string|null|undefined} The format optionally supplied by the `resolve` hook chain. This can be any string value as an input; input values d...
https://github.com/nodejs/node/blob/main//doc/api/module.md
main
nodejs
[ -0.09088847041130066, 0.05898592248558998, 0.01847219094634056, 0.05534641817212105, -0.02243741787970066, 0.005144509486854076, -0.026149136945605278, 0.016502637416124344, 0.024559134617447853, -0.0400376133620739, -0.02595309354364872, 0.024645937606692314, -0.016751166433095932, 0.0209...
0.058069
accomplish wide-ranging customizations of the Node.js code loading and evaluation behaviors. #### Import from HTTPS The hook below registers hooks to enable rudimentary support for such specifiers. While this may seem like a significant improvement to Node.js core functionality, there are substantial downsides to actua...
https://github.com/nodejs/node/blob/main//doc/api/module.md
main
nodejs
[ -0.07551990449428558, 0.05779383331537247, 0.06285544484853745, 0.06021177023649216, 0.024902446195483208, -0.04884220287203789, -0.11313633620738983, 0.037497904151678085, 0.05342250317335129, 0.027377616614103317, -0.09158167988061905, 0.06170342117547989, -0.024566059932112694, -0.03150...
0.024744
true, source: transformedSource, }; } return nextLoad(url, context); } function getPackageType(url) { const pJson = findPackageJSON(url); if (!pJson) { return undefined; } try { const file = readFileSync(pJson, 'utf-8'); return JSON.parse(file)?.type; } catch { return undefined; } } registerHooks({ load }); ``` #### Ru...
https://github.com/nodejs/node/blob/main//doc/api/module.md
main
nodejs
[ -0.1005992442369461, -0.0034943216014653444, 0.0036746023688465357, 0.03505708649754524, 0.04003645107150078, 0.0003923655895050615, 0.016283225268125534, 0.06587112694978714, 0.032166533172130585, -0.10640881955623627, -0.012971725314855576, 0.011856436729431152, -0.06962913274765015, 0.0...
0.023078