Skip to content
Snippets Groups Projects
Commit b3e847b4 authored by lowercasedonkey's avatar lowercasedonkey
Browse files

autofix

parent cd9e886e
No related branches found
No related tags found
1 merge request!7472Fixes for nursery, tweaks.
(function() { (function() {
const readOnlySymbol = Symbol("readonly proxy"); const readOnlySymbol = Symbol("readonly proxy");
globalThis.createReadonlyProxy = function(target) { globalThis.createReadonlyProxy = function(target) {
if (target == null) return target; //intentionally == if (target == null) { return target; } // intentionally ==
if (target[readOnlySymbol]) { return target; } if (target[readOnlySymbol]) { return target; }
if (_.isArray(target)) { if (_.isArray(target)) {
return new Proxy(target, { return new Proxy(target, {
...@@ -10,9 +10,9 @@ ...@@ -10,9 +10,9 @@
const val = o[prop]; const val = o[prop];
if (typeof val === 'function') { if (typeof val === 'function') {
if (['push', 'unshift', 'pop'].includes(prop)) { if (['push', 'unshift', 'pop'].includes(prop)) {
return function () { return function() {
throw Error("Cannot modify a readonly array"); throw Error("Cannot modify a readonly array");
} };
} }
return val.bind(target); return val.bind(target);
} }
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
}; };
const cheaterSymbol = Symbol("cheating proxy"); const cheaterSymbol = Symbol("cheating proxy");
globalThis.createCheatProxy = function(target) { globalThis.createCheatProxy = function(target) {
if (target == null) return target; //intentionally == if (target == null) { return target; } // intentionally ==
if (target[cheaterSymbol]) { return target; } if (target[cheaterSymbol]) { return target; }
if (_.isArray(target)) { if (_.isArray(target)) {
return new Proxy(target, { return new Proxy(target, {
...@@ -53,12 +53,12 @@ ...@@ -53,12 +53,12 @@
const val = o[prop]; const val = o[prop];
if (typeof val === 'function') { if (typeof val === 'function') {
if (['push', 'unshift', 'pop'].includes(prop)) { if (['push', 'unshift', 'pop'].includes(prop)) {
return function (el) { return function(el) {
const retval = Array.prototype[prop].apply(o, arguments); const retval = Array.prototype[prop].apply(o, arguments);
//Make sure we set cheater after calling the function // Make sure we set cheater after calling the function
State.variables.cheater = 1;//Can't use `V` because it probably points to a proxy. State.variables.cheater = 1;// Can't use `V` because it probably points to a proxy.
return retval; return retval;
} };
} }
return val.bind(target); return val.bind(target);
} }
...@@ -66,12 +66,12 @@ ...@@ -66,12 +66,12 @@
}, },
set:function(o, prop, value) { set:function(o, prop, value) {
o[prop] = value; o[prop] = value;
State.variables.cheater = 1;//Can't use `V` because it probably points to a proxy. State.variables.cheater = 1;// Can't use `V` because it probably points to a proxy.
return true; return true;
}, },
deleteProperty:function(o, prop) { deleteProperty:function(o, prop) {
delete o[prop]; delete o[prop];
State.variables.cheater = 1;//Can't use `V` because it probably points to a proxy. State.variables.cheater = 1;// Can't use `V` because it probably points to a proxy.
return true; return true;
} }
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment