-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into kevinuehara/adding-typescript-tests
- Loading branch information
Showing
275 changed files
with
8,523 additions
and
4,645 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
blank_issues_enabled: true | ||
contact_links: | ||
- name: ⁉️ Need help with Node.js? | ||
- name: ⁉️ Need general help with Node.js? | ||
url: https://github.com/nodejs/help | ||
about: Please file an issue in our help repo. | ||
- name: 📦 Have an issue with npm? | ||
url: https://github.com/npm/cli/issues | ||
about: npm has a seperate issue tracker. | ||
- name: 📡 Have an issue with undici? (`WebSocket`, `fetch`, etc.) | ||
url: https://github.com/nodejs/undici/issues | ||
about: Undici has a seperate issue tracker. | ||
- name: 🌐 Found a problem with nodejs.org beyond the API reference docs? | ||
url: https://github.com/nodejs/nodejs.org/issues/new/choose | ||
about: Please file an issue in the Node.js website repo. |
This file was deleted.
Oops, something went wrong.
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
BASIC=basic | ||
|
||
# COMMENTS=work | ||
#BASIC=basic2 | ||
#BASIC=basic3 | ||
|
||
# previous line intentionally left blank | ||
AFTER_LINE=after_line | ||
EMPTY= | ||
EMPTY_SINGLE_QUOTES='' | ||
EMPTY_DOUBLE_QUOTES="" | ||
EMPTY_BACKTICKS=`` | ||
SINGLE_QUOTES='single_quotes' | ||
SINGLE_QUOTES_SPACED=' single quotes ' | ||
DOUBLE_QUOTES="double_quotes" | ||
DOUBLE_QUOTES_SPACED=" double quotes " | ||
DOUBLE_QUOTES_INSIDE_SINGLE='double "quotes" work inside single quotes' | ||
DOUBLE_QUOTES_WITH_NO_SPACE_BRACKET="{ port: $MONGOLAB_PORT}" | ||
SINGLE_QUOTES_INSIDE_DOUBLE="single 'quotes' work inside double quotes" | ||
BACKTICKS_INSIDE_SINGLE='`backticks` work inside single quotes' | ||
BACKTICKS_INSIDE_DOUBLE="`backticks` work inside double quotes" | ||
BACKTICKS=`backticks` | ||
BACKTICKS_SPACED=` backticks ` | ||
DOUBLE_QUOTES_INSIDE_BACKTICKS=`double "quotes" work inside backticks` | ||
SINGLE_QUOTES_INSIDE_BACKTICKS=`single 'quotes' work inside backticks` | ||
DOUBLE_AND_SINGLE_QUOTES_INSIDE_BACKTICKS=`double "quotes" and single 'quotes' work inside backticks` | ||
EXPAND_NEWLINES="expand\nnew\nlines" | ||
DONT_EXPAND_UNQUOTED=dontexpand\nnewlines | ||
DONT_EXPAND_SQUOTED='dontexpand\nnewlines' | ||
# COMMENTS=work | ||
INLINE_COMMENTS=inline comments # work #very #well | ||
INLINE_COMMENTS_SINGLE_QUOTES='inline comments outside of #singlequotes' # work | ||
INLINE_COMMENTS_DOUBLE_QUOTES="inline comments outside of #doublequotes" # work | ||
INLINE_COMMENTS_BACKTICKS=`inline comments outside of #backticks` # work | ||
INLINE_COMMENTS_SPACE=inline comments start with a#number sign. no space required. | ||
EQUAL_SIGNS=equals== | ||
RETAIN_INNER_QUOTES={"foo": "bar"} | ||
RETAIN_INNER_QUOTES_AS_STRING='{"foo": "bar"}' | ||
RETAIN_INNER_QUOTES_AS_BACKTICKS=`{"foo": "bar's"}` | ||
TRIM_SPACE_FROM_UNQUOTED= some spaced out string | ||
SPACE_BEFORE_DOUBLE_QUOTES= "space before double quotes" | ||
EMAIL=therealnerdybeast@example.tld | ||
SPACED_KEY = parsed | ||
EDGE_CASE_INLINE_COMMENTS="VALUE1" # or "VALUE2" or "VALUE3" | ||
|
||
MULTI_DOUBLE_QUOTED="THIS | ||
IS | ||
A | ||
MULTILINE | ||
STRING" | ||
|
||
MULTI_SINGLE_QUOTED='THIS | ||
IS | ||
A | ||
MULTILINE | ||
STRING' | ||
|
||
MULTI_BACKTICKED=`THIS | ||
IS | ||
A | ||
"MULTILINE'S" | ||
STRING` | ||
export EXPORT_EXAMPLE = ignore export | ||
|
||
MULTI_NOT_VALID_QUOTE=" | ||
MULTI_NOT_VALID=THIS | ||
IS NOT MULTILINE |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#include <node_api.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
#define NODE_API_CALL(call) \ | ||
do { \ | ||
napi_status status = call; \ | ||
if (status != napi_ok) { \ | ||
fprintf(stderr, #call " failed: %d\n", status); \ | ||
abort(); \ | ||
} \ | ||
} while (0) | ||
|
||
#define ABORT_IF_FALSE(condition) \ | ||
if (!(condition)) { \ | ||
fprintf(stderr, #condition " failed\n"); \ | ||
abort(); \ | ||
} | ||
|
||
static void Finalize(node_api_basic_env env, void* data, void* hint) { | ||
delete[] static_cast<uint8_t*>(data); | ||
} | ||
|
||
static napi_value CreateExternalBuffer(napi_env env, napi_callback_info info) { | ||
napi_value argv[2], undefined, start, end; | ||
size_t argc = 2; | ||
int32_t n = 0; | ||
napi_valuetype val_type = napi_undefined; | ||
|
||
// Validate params and retrieve start and end function. | ||
NODE_API_CALL(napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr)); | ||
ABORT_IF_FALSE(argc == 2); | ||
NODE_API_CALL(napi_typeof(env, argv[0], &val_type)); | ||
ABORT_IF_FALSE(val_type == napi_object); | ||
NODE_API_CALL(napi_typeof(env, argv[1], &val_type)); | ||
ABORT_IF_FALSE(val_type == napi_number); | ||
NODE_API_CALL(napi_get_named_property(env, argv[0], "start", &start)); | ||
NODE_API_CALL(napi_typeof(env, start, &val_type)); | ||
ABORT_IF_FALSE(val_type == napi_function); | ||
NODE_API_CALL(napi_get_named_property(env, argv[0], "end", &end)); | ||
NODE_API_CALL(napi_typeof(env, end, &val_type)); | ||
ABORT_IF_FALSE(val_type == napi_function); | ||
NODE_API_CALL(napi_get_value_int32(env, argv[1], &n)); | ||
|
||
NODE_API_CALL(napi_get_undefined(env, &undefined)); | ||
|
||
constexpr uint32_t kBufferLen = 32; | ||
|
||
// Start the benchmark. | ||
napi_call_function(env, argv[0], start, 0, nullptr, nullptr); | ||
|
||
for (int32_t idx = 0; idx < n; idx++) { | ||
napi_handle_scope scope; | ||
uint8_t* buffer = new uint8_t[kBufferLen]; | ||
napi_value jsbuffer; | ||
NODE_API_CALL(napi_open_handle_scope(env, &scope)); | ||
NODE_API_CALL(napi_create_external_buffer( | ||
env, kBufferLen, buffer, Finalize, nullptr, &jsbuffer)); | ||
NODE_API_CALL(napi_close_handle_scope(env, scope)); | ||
} | ||
|
||
// Conclude the benchmark. | ||
napi_value end_argv[] = {argv[1]}; | ||
NODE_API_CALL(napi_call_function(env, argv[0], end, 1, end_argv, nullptr)); | ||
|
||
return undefined; | ||
} | ||
|
||
NAPI_MODULE_INIT() { | ||
napi_property_descriptor props[] = { | ||
{"createExternalBuffer", | ||
nullptr, | ||
CreateExternalBuffer, | ||
nullptr, | ||
nullptr, | ||
nullptr, | ||
static_cast<napi_property_attributes>(napi_writable | napi_configurable | | ||
napi_enumerable), | ||
nullptr}, | ||
}; | ||
|
||
NODE_API_CALL(napi_define_properties( | ||
env, exports, sizeof(props) / sizeof(*props), props)); | ||
return exports; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
'targets': [ | ||
{ | ||
'target_name': 'binding', | ||
'sources': [ 'binding.cc' ], | ||
'defines': [ | ||
'NAPI_EXPERIMENTAL' | ||
] | ||
}, | ||
{ | ||
'target_name': 'binding_node_api_v8', | ||
'sources': [ 'binding.cc' ], | ||
'defines': [ | ||
'NAPI_VERSION=8' | ||
] | ||
} | ||
] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use strict'; | ||
|
||
const common = require('../../common.js'); | ||
|
||
const bench = common.createBenchmark(main, { | ||
n: [5e6], | ||
addon: ['binding', 'binding_node_api_v8'], | ||
implem: ['createExternalBuffer'], | ||
}); | ||
|
||
function main({ n, implem, addon }) { | ||
const binding = require(`./build/${common.buildType}/${addon}`); | ||
binding[implem](bench, n); | ||
} |
Oops, something went wrong.