Skip to main content

All Questions

Tagged with
0 votes
1 answer
81 views

Debounce "setting" of values in proxy trap without delay/timeout

I try to understand how i can debounce a "set" trap in javascript proxy. function debounce(func, wait, immediate = false) { let timeout = null; return function(...args) { let ...
Marc's user avatar
  • 3,836
-3 votes
1 answer
175 views

How can I use proxy with spread operator or object.assign?

I need to have methods and store bound to 'this' in my callback function, but when I use the spread operator it doesn't work. The reason for this as far as I know is that the spread operator returns a ...
EMILO's user avatar
  • 433
1 vote
1 answer
279 views

why are target and receiver not the same in this javascript proxy?

I am working with JavaScript Proxy and do not understand why the target and the receiver are different in both the get() and set() traps. They appear to be the same (based on console logging). The ...
bmacnaughton's user avatar
  • 5,198
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 ...
Maria's user avatar
  • 13
0 votes
0 answers
50 views

In Javascript, is it possible to proxy 'this' within a constructor, without editing the constructor

Imagine I have the following Javascript class: class C { constructor() { this.foo = "bar" } } I have proxied C so I can intercept construction of C: const handler = { construct(...
ebdavis's user avatar
  • 105
0 votes
1 answer
271 views

Proxy trap for a part of functions

I implemented a proxy handler to intercept all functions in a class. class SBFinder { foo1({ name, id }) { console.log(name + id); } foo2({ name, id }) { console.log(id + name); } } ...
Eduard Dubilyer's user avatar
0 votes
1 answer
121 views

How do I intercept sort function within a JS proxy with a function?

My previous related question: How do I intercept sort function within a JS proxy? Given the proxy: function sort(customSort) { /* Write logs */ console.log("Intercepted sort") return ...
Blue Granny's user avatar
3 votes
1 answer
263 views

How do I intercept sort function within a JS proxy?

I know how to intercept get`set` and such within a proxy using the following code: function get( target, prop, receiver ) { console.log("Intercepted get") return Reflect.get( target, ...
Blue Granny's user avatar
0 votes
0 answers
153 views

different behavior es6 Proxy on NodeJs and Web when return in class constructor that extends

import * as Parse from 'parse'; import { Object as ParseObject } from 'parse'; export interface IItem { num: number; } export class Item extends ParseObject<IItem> implements IItem { num = 1; ...
sdykae's user avatar
  • 118
6 votes
1 answer
578 views

Using ES6 Proxy to lazily load resources

I am building something like an ActiveRecord class for documents stored in MongoDB (akin to Mongoose). I have two goals: Intercept all property setters on a document using a Proxy, and automatically ...
Rafael Sofi-zada's user avatar
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 ...
Mario's user avatar
  • 4,932
0 votes
0 answers
42 views

Is this a bug in Node Proxy objects (v12.6.0)?

One can wrap a class in a proxy object. Proxy objects allow us to trap calls to the constructor. One can extend the proxy-wrapped class. In the browser (chrome 73.0.3683.75), calling the subclass ...
Sean Morris's user avatar
7 votes
3 answers
6k views

Intercept method calls in javascript

What's the equivalent of the __call magic method from PHP ? I was under the impression that Proxy can do this, but it can't. class MyClass{ constructor(){ return new Proxy(this, { apply: ...
Alex's user avatar
  • 67.5k
3 votes
2 answers
1k views

Why is my function proxy not being called in Node?

I was using proxy get method fine. Then I tried using it on a function and quickly realized I needed to use the apply method. This simple example is not working. It never enters apply. Node looks to ...
Dave Stein's user avatar
  • 9,126
1 vote
0 answers
790 views

How should I change my code to chain generator function by using ES6 proxy?

I've been spending many hours for the last couple days to make my code work but I can't make it work!! What I'm trying to accomplish is chaining generator functions like the below by using es6 proxy. ...
shu's user avatar
  • 244

15 30 50 per page