jaandrle / jaandrle.github.io

Personal page/blog
https://jaandrle.github.io/
MIT License
2 stars 3 forks source link

Převedení metod na samostatné funkce pomocí `Proxy` #61

Closed jaandrle closed 3 years ago

jaandrle commented 3 years ago
const { find, map }= new Proxy(Array.prototype, { get(target,name){ return Function.prototype.call.bind(target[name]); } });
const toFunctional= object=> new Proxy(object.prototype, { get(target,name){ return Function.prototype.call.bind(target[name]); } });
const { map, join }= toFunctional(Array);
const { repeat }= toFunctional(String);
const { keys }= Object;
console.log(join(map(keys({ a: "A" }), key=> repeat(key, 2))));

Ke zmínění