File size: 387 Bytes
8f9eb25
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
// Same pattern as transformers.js: a class whose instances are functions, so `await pipe({...})` calls `_call`.
export class Callable extends Function {
  constructor() {
    super();
    const closure = function (...args) { return closure._call(...args); };
    return Object.setPrototypeOf(closure, new.target.prototype);
  }
  _call() { throw new Error("_call not implemented"); }
}