Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions benchmark/sqlite/sqlite-is-transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ function main(conf) {
}

let i;
let deadCodeElimination = true;
let deadCodeElimination;

bench.start();
for (i = 0; i < conf.n; i += 1)
deadCodeElimination &&= db.isTransaction;
deadCodeElimination = db.isTransaction;
bench.end(conf.n);

assert.ok(deadCodeElimination === (conf.transaction === 'true'));
assert.strictEqual(deadCodeElimination, conf.transaction === 'true');

if (conf.transaction === 'true') {
db.exec('ROLLBACK');
Expand Down
13 changes: 13 additions & 0 deletions doc/api/repl.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,15 @@ undefined
undefined
```

### Error handling

By default, uncaught exceptions in the REPL are printed to the output stream
(as with `Uncaught Error: REPL await` above). `uncaughtException` listeners
can be added freely in both standalone and nested REPLs. The `handleError`
option of [`repl.start()`][] can customize this behavior, including
forwarding exceptions to [`'uncaughtException'`][] by returning
`'unhandled'`.

### Reverse-i-search

<!-- YAML
Expand Down Expand Up @@ -425,6 +434,9 @@ const firstInstance = repl.start(options);
const secondInstance = new repl.REPLServer(options);
```

Calling `repl.REPLServer()` without the `new` keyword throws a `TypeError`
(see [DEP0185][]).

### Event: `'exit'`

<!-- YAML
Expand Down Expand Up @@ -1127,6 +1139,7 @@ avoiding open network interfaces.

Original code from <https://gist.github.com/TooTallNate/2053342>.

[DEP0185]: deprecations.md#dep0185-instantiating-noderepl-classes-without-new
[TTY keybindings]: readline.md#tty-keybindings
[ZSH]: https://en.wikipedia.org/wiki/Z_shell
[`'uncaughtException'`]: process.md#event-uncaughtexception
Expand Down
13 changes: 12 additions & 1 deletion lib/ffi.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'use strict';

const {
ArrayBufferPrototypeGetDetached,
DataViewPrototypeGetBuffer,
FunctionPrototypeCall,
ObjectDefineProperty,
ObjectFreeze,
Expand All @@ -10,11 +12,14 @@ const {
SafeWeakMap,
SafeWeakRef,
SymbolDispose,
TypedArrayPrototypeGetBuffer,
} = primordials;
const { Buffer } = require('buffer');
const { emitExperimentalWarning } = require('internal/util');
const {
isDataView,
isArrayBufferView,
isSharedArrayBuffer,
} = require('internal/util/types');
const {
codes: {
Expand Down Expand Up @@ -299,7 +304,13 @@ function exportArrayBufferView(source, data, len) {

validateInteger(len, 'len', 0);

if (len < source.byteLength) {
// Reading byteLength throws for a detached DataView. Let the native binding
// reject detached views consistently with detached ArrayBuffers.
const buffer = isDataView(source) ?
DataViewPrototypeGetBuffer(source) : TypedArrayPrototypeGetBuffer(source);
if ((isSharedArrayBuffer(buffer) ||
!ArrayBufferPrototypeGetDetached(buffer)) &&
len < source.byteLength) {
throw new ERR_OUT_OF_RANGE('len', `>= ${source.byteLength}`, len);
}

Expand Down
3 changes: 1 addition & 2 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,7 @@ function reconstructCallSite(callSite) {
if (!entry?.originalSource) return;
return {
__proto__: null,
// If the name is not found, it is an empty string to match the behavior of `util.getCallSite()`
functionName: entry.name ?? '',
functionName: entry.name || callSite.functionName,
scriptName: entry.originalSource,
lineNumber: entry.originalLine + 1,
column: entry.originalColumn + 1,
Expand Down
31 changes: 20 additions & 11 deletions src/node_options-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,19 @@ namespace options_parser {
template <typename Options>
void OptionsParser<Options>::AddOption(const char* name,
const char* help_text,
bool Options::*field,
bool (*getter)(Options*),
void (*setter)(Options*, bool),
OptionEnvvarSettings env_setting,
bool default_is_true,
OptionNamespaces namespace_id) {
options_.emplace(name,
OptionInfo{kBoolean,
std::make_shared<SimpleOptionField<bool>>(field),
env_setting,
help_text,
default_is_true,
NamespaceEnumToString(namespace_id)});
options_.emplace(
name,
OptionInfo{kBoolean,
std::make_shared<BitFieldOptionField>(getter, setter),
env_setting,
help_text,
default_is_true,
NamespaceEnumToString(namespace_id)});
}

template <typename Options>
Expand Down Expand Up @@ -207,6 +209,13 @@ auto OptionsParser<Options>::Convert(
return original->LookupImpl((options->*get_child)());
}

bool GetBool(Options* options) const override {
return original->GetBool((options->*get_child)());
}
void SetBool(Options* options, bool value) override {
original->SetBool((options->*get_child)(), value);
}

AdaptedField(
std::shared_ptr<OriginalField> original,
ChildOptions* (Options::* get_child)())
Expand Down Expand Up @@ -432,8 +441,8 @@ void OptionsParser<Options>::Parse(
if (value.type == kV8Option) {
v8_args->push_back(value.name);
} else {
*value.target_field->template Lookup<bool>(
options) = value.target_value;
value.target_field->SetBool(options,
value.target_value);
}
});
}
Expand Down Expand Up @@ -479,7 +488,7 @@ void OptionsParser<Options>::Parse(

switch (info.type) {
case kBoolean:
*Lookup<bool>(info.field, options) = !is_negation;
info.field->SetBool(options, !is_negation);
break;
case kInteger: {
// Special case to pass --stack-trace-limit down to V8.
Expand Down
Loading
Loading