All Questions
Tagged with es6-proxy ecmascript-6
99
questions
0
votes
0
answers
26
views
I am trying to work with ES6 Proxies but am noticing something super weird, it is getting called twice [closed]
I am trying to implement a simple backbone model which has handlers for change and delete events on the model. The change handler for changing the value of a property gets executed 2 times instead of ...
1
vote
1
answer
119
views
Can I extend default javascript function prototype to let some code been executed on every function call?
Lets say there are functions
function a(someparams){
console.log('a called')
}
function b(){
console.log('b called')
}
...
const c (someParam) => { console.log('c called')}
I want to extend ...
0
votes
1
answer
53
views
Why does the code below log undefined for a.bar?
I wrote the code below to set a trap for the internal prototype get routine for proxy_a but the code doesn't seem to work as expected.
var base = {
foo: 100
}
var a = {
bar: 10
};
var ...
10
votes
3
answers
5k
views
ES6 proxied class, access private property (Cannot read private member #hidden from an object whose class did not declare it)
Im playing around with proxy objects, classess and private properties.
And came across this error message:
/home/marc/projects/playground/pipeline/clsss.js:14
this.#hidden = !this.#hidden;
...
-1
votes
1
answer
563
views
How to wait until a callback is finished to return from ES6 Proxy
I can't use promises because it force the user to convert everything to async functions for sync methods. Is there any way to force the proxy to not to return until the callback complete?
function ...
9
votes
3
answers
1k
views
Why isn't ownKeys Proxy trap working with Object.keys()?
In the documentation of the Proxy ownKeys trap on MDN it states that it will intercept Object.keys() calls:
This trap can intercept these operations:
Object.getOwnPropertyNames()
Object....
0
votes
0
answers
392
views
JavaScript Proxy not working properly on ie11
I am building a simple validation library and I need to use Proxy because I want to accept custom validation rules as chain object. I build something and its works properly on modern browsers but not ...
0
votes
2
answers
60
views
Return value for each element called (accessed) (passed) (traversed) when using the dot notation in JavaScript
I want to do something like this:
let DOM = {
slide1: {
button: ".btn",
box: "#box"
}
}
and then when I write:
console.log(DOM.slide1.box);
I want the output to be &...
2
votes
1
answer
260
views
Remote objects using web sockets
Is there a library which allows me to call remote objects by web sockets?
My target is to able to use an object like any other object (set/get properties on it, call methods) but the object would ...
3
votes
1
answer
896
views
Is there a way to use Javascript ES6 Proxy to spy on Object Methods [duplicate]
Is it possible, given the following object
let target = {
foo:0,
result:[],
bar(){
//some code
}
}
to then wrap said object in a Proxy()
let handler = {
get(){
// code here
},
...
1
vote
1
answer
2k
views
how to override class methods using javascript proxy
this is my class
class Chrome {
constructor(browser, page) {
this.browser;
this.page;
}
async launch() {
if (!this.browser) {
console.log("launching browser...");
this....
0
votes
2
answers
168
views
JavaScript Proxy Setter doesn't make a second Proxy call
I have the following code that is using Proxy for Class setter. In my example I am tracking specific variable to update some other variables. My Setter is writing a log of all changes to Console. ...
1
vote
0
answers
659
views
Monkey-patch a npm module in TypeScript
I have a module installed with npm with a single method as the default export. I have setup an ES6 Proxy with an apply handler to monkey-patch the method in the module. What I struggle with is how I ...
7
votes
1
answer
174
views
Make object or class property only invocable
TL:DR; Is it possible to make a property of object to be invocable ( as a function ) only ?
What i mean by this
class Foo{
bar(value){
return value
}
}
let newFoo = new Foo()
...
1
vote
1
answer
177
views
Accesing method startsWith throw error when calling console.log() in proxy
I am learning about ES6 proxies, for this purpose I follow the guide on javascript.info, the following example, avoid reading, deleting, adding a new property and listing properties if the property ...