This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Module = require('node:module') | |
const path = require('node:path') | |
const load = Module._load | |
const aliases = [['myawesomemodule', path.dirname(require.resolve('./myawesomemodule/'))]] | |
Module._load = function (request, parent) { | |
const alias = aliases.find(([module]) => request.startsWith(module)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// These two functions are identical. | |
const fn1 = async () => { return 5 } | |
const fn2 = () => new Promise((resolve, reject) => { | |
try { | |
resolve(5) | |
} catch (e) { | |
reject(e) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ grep -nH name -- test/{node-api,js-native-api}/*/binding.gyp | awk '{print $NF;}' | sed -e 's/"//g' -e "s/'//g" | sort | |
2_function_arguments, | |
3_callbacks, | |
4_object_factory, | |
5_function_factory, | |
6_object_wrap, | |
7_factory_wrap, | |
8_passing_wrapped, | |
binding, | |
binding, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/js_native_api.h b/src/js_native_api.h | |
index 07e3df1340..dbb69ace45 100644 | |
--- a/src/js_native_api.h | |
+++ b/src/js_native_api.h | |
@@ -534,11 +534,16 @@ napi_add_finalizer(napi_env env, | |
#ifdef NAPI_EXPERIMENTAL | |
#define NODE_API_EXPERIMENTAL_HAS_POST_FINALIZER | |
+#if defined(NODE_API_EXPERIMENTAL_NOGC_ENV_OPT_OUT) | |
+#define node_api_post_finalizer(env, finalize_cb, finalize_data, finalize_hint) \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fs from 'node:fs' | |
import async_hooks from 'node:async_hooks' | |
import process from 'node:process' | |
declare global { | |
var promises: Record<string, number> | |
var enableHook: () => {} | |
var disableHook: () => {} | |
var dumpPromises: () => void | |
} | |
global.promises = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const result = await fetch('https://some-place/some/path) | |
.then( | |
res => { | |
doSomethingComplicatedWith(res) | |
}, | |
err => { | |
console.log('Failed to fetch') | |
} | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <gtk/gtk.h> | |
int main(int argc, char *argv[]) { | |
GtkWidget *view; | |
GtkTextBuffer *buffer; | |
GtkWidget *window; | |
GdkDisplay *display; | |
GdkScreen *screen; | |
GtkCssProvider *provider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Script to be used with gdb to trace changes to the maps file as Node.js | |
# performs mmaps. | |
import io | |
import os | |
import sys | |
import gdb | |
import shutil | |
import subprocess |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set pagination off | |
set breakpoint pending on | |
set style enabled off | |
set environment NODE_ENV=production | |
define domaps | |
shell echo "*** Start Event ***" | |
bt 10 | |
python gdb.execute('finish'); | |
shell echo "*** End Event *****" | |
continue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FinishMapsBreak (gdb.FinishBreakpoint): | |
def stop(self): | |
gdb.write('----------- End Event ------------\n') | |
gdb.flush() | |
return False | |
def out_of_scope(self): | |
return self.stop() | |
class MapsBreak (gdb.Breakpoint): |
NewerOlder