Skip to content

Instantly share code, notes, and snippets.

View anodynos's full-sized avatar

Angelos Pikoulas anodynos

  • Freelancer
  • London, UK
View GitHub Profile
@anodynos
anodynos / proxy-promise.js
Created March 25, 2020 14:19 — forked from KiaraGrouwstra/proxy-promise.js
using ES6 Proxy to deal with methods of Promise'd objects. not sure how useful this is yet.
// using ES6 Proxy to deal with methods of Promise'd objects. works for me in Edge though not Chrome somehow.
let handler = {
get: (target, prop) => function() {
if(target instanceof Promise) {
let args = arguments;
return target.then((o) => o[prop].apply(o, args));
} else {
let value = target[prop];
return typeof value == 'function' ? value.bind(target) : value;
}