dev: update deprecated use of __proto__

This commit is contained in:
KernelDeimos 2024-12-12 12:23:58 -05:00
parent 951fb32f57
commit d5ecac4d0f
4 changed files with 9 additions and 35 deletions

View File

@ -1,25 +0,0 @@
/*
* Copyright (C) 2024 Puter Technologies Inc.
*
* This file is part of Puter.
*
* Puter is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
class CodeModel {
static create () {}
}
module.exports = {
CodeModel,
};

View File

@ -109,7 +109,7 @@ class Sequence {
async run (values) {
// Initialize scope
values = values || this.thisArg?.values || {};
this.scope_.__proto__ = values;
Object.setPrototypeOf(this.scope_, values);
// Run sequence
for ( ; this.i < this.steps.length ; this.i++ ) {
@ -126,9 +126,8 @@ class Sequence {
const parent_scope = this.scope_;
this.scope_ = {};
// We could do Object.assign(this.scope_, parent_scope), but
// setting __proto__ is faster because it leverages the optimizations
// of the JS engine for the prototype chain.
this.scope_.__proto__ = parent_scope;
// setting the prototype should be faster (in theory)
Object.setPrototypeOf(this.scope_, parent_scope);
if ( this.sequence_.options_.record_history ) {
this.value_history_.push(this.scope_);

View File

@ -160,7 +160,7 @@ let config_to_export;
// load_config() may replace
const config_pointer = {};
{
config_pointer.__proto__ = config;
Object.setPrototypeOf(config_pointer, config);
config_to_export = config_pointer;
}
@ -171,14 +171,14 @@ const config_pointer = {};
let replacement_config = {
...o,
};
replacement_config = deep_proto_merge(replacement_config, config_pointer.__proto__, {
replacement_config = deep_proto_merge(replacement_config, Object.getPrototypeOf(config_pointer), {
preserve_flag: true,
})
config_pointer.__proto__ = replacement_config;
Object.setPrototypeOf(config_pointer, replacement_config);
};
const config_api = { load_config };
config_api.__proto__ = config_to_export;
Object.setPrototypeOf(config_api, config_to_export);
config_to_export = config_api;
}
@ -209,7 +209,7 @@ const config_pointer = {};
const config_runtime_values = {
$: 'runtime-values'
};
config_runtime_values.__proto__ = config_to_export;
Object.setPrototypeOf(config_runtime_values, config_to_export);
config_to_export = config_runtime_values
// These can be difficult to find and cause painful

View File

@ -132,7 +132,7 @@ class Context {
this.parent_ = opt_parent;
if ( opt_parent ) {
values.__proto__ = opt_parent.values_;
Object.setPrototypeOf(values, opt_parent.values_);
for ( const k in values ) {
const parent_val = opt_parent.values_[k];
if ( parent_val instanceof Context ) {