All Questions
Tagged with javascript-proxy or es6-proxy
323 questions
0
votes
1
answer
140
views
Undetectable JavaScript Error Object Override: Bypassing Standard Detection Mechanisms
I'm attempting to create an undetectable method of overriding the Error object in JavaScript without triggering standard detection mechanisms. My goal is to modify the Error prototype or constructor ...
2
votes
1
answer
103
views
Is it allowed in javascript to modify the handler after proxy has already been created?
I modify the handler object after proxy's creation, and obtain intended result. But nowhere in mdn document such pattern, can i rely on this pattern to work consistently across browser/in future?
...
1
vote
1
answer
106
views
When the JavaScript Reflect.get method has a receiver parameter, it returns undefined. How can this situation be reproduced at the language level?
enter image description here
const globalProxy = new Proxy(win.window, {
get(target, p, receiver){
// return undefined
return Reflect.get(target, p, receiver);
// there is a value
// ...
1
vote
0
answers
80
views
Binding scalar data to HTML element - JavaScript Proxies
I may be guilty of a bit of an XY question here, but I'm doing this out of theoretical interest rather than any immediate need.
My goal is, ultimately, to build a lightweight framework that allows me ...
0
votes
0
answers
100
views
How to intercept/trap non-existing properties AND methods using JS Proxy?
I need to wrap an immutable object coming from 3rd party code to (a) override some methods and (b) to catch non-existing properties/methods because the object throws an error if a property/method does ...
-1
votes
1
answer
62
views
Trapping a function call with a proxy does not intercept the arguments
I want to intercept function calls and found that proxies can do that as shown here on MDN using the apply method. However what I quickly found out is that the params passed to the function are not ...
0
votes
1
answer
95
views
How can I proxy [[set]] on all JavaScript array objects?
I'm trying to proxy the [[set]] method on JavaScript arrays. Is it possible to proxy all arrays, and not just a specific one? My handler would check the object being set in the array and if it ...
3
votes
1
answer
116
views
Can a Proxy trap assignment to a variable referring to it?
Consider the following Proxy object:
let proxy = new Proxy({}, handler);
If I perform the following assignment, the proxy instance will be overwriten, losing the trap handlers:
proxy = {};
Alright, ...
2
votes
1
answer
139
views
How to correctly type a JavaScript proxy handler in TypeScript for (Angular Signals-like) reactive state management?
I wanted to create a short documentation and explain the principle of Angular Signals using JavaScript proxies in an example. Then the question came up: could I quickly write it in TypeScript and set ...
0
votes
1
answer
59
views
Multiple Access to two-dimensional array (using setters/getter via Proxy or Object.defineProperty)
I have a two dimensional array that I need to perform read and write action on from various angles.
Sometimes I need to get/set a single row (easy of course) and sometimes I need to get/set a single ...
-1
votes
1
answer
88
views
Detect direct instances in JavaScript
A couple of years ago, I wanted figure how to create a type check for class A that returns true only for objects instantiated by new A(). For this, I wrote the class like this:
class A {
static #...
0
votes
1
answer
442
views
Why is this object a Proxy only when the page field is 1?
Steps to reproduce:
Open the reproduction
Open the browser console
When the project starts it will errors with:
Uncaught (in promise) DOMException: Failed to execute 'put' on 'IDBObjectStore': #<...
0
votes
1
answer
199
views
JavaScript Proxy not working for opened Window object
I need to Proxy a window object opened with window.open.
So far as I understand it (which is not well), the trivial "handler" here should effectively be the identity operation, passing thru ...
0
votes
1
answer
54
views
Expression which contains deeply nested proxy object property does not update the same proxy object property
I have a function that takes an object and returns a proxied version of this object, which can be mutated without affecting the original object.
const createProxy4 = (obj) => {
const handler = {
...
0
votes
1
answer
79
views
Mocking an async builder pattern API with proxy
I'm trying to mock knex for testing. Everything seems to work but attaching a proxy to an array as prototype seems to remove the iteratability of arrays.
Here is the mock function. Following works ...