Skip to content

Instantly share code, notes, and snippets.

View JamieVaughn's full-sized avatar
🏗️
make devs

Jamie Vaughn JamieVaughn

🏗️
make devs
  • Altana.ai
  • Rochester, NY
  • 23:02 (UTC -05:00)
View GitHub Profile
@JamieVaughn
JamieVaughn / piping-experiments.js
Created July 5, 2020 05:24 — forked from ducaale/piping-experiments.js
Using ES6 Proxies to turn methods into pipe friendly functions
// .babelrc
// {"plugins": [["@babel/plugin-proposal-pipeline-operator", { "proposal": "minimal" }]]}
const pipeable = (class_) => new Proxy({}, {
get: (target, prop) => (
(prop in class_.prototype)
? (...args) => (receiver) => class_.prototype[prop].call(receiver, ...args)
: class_[prop].bind(class_) // https://stackoverflow.com/a/30819436/5915221
)
});