3 ms·
Would that mean that instead of obj.pipeTo() I'd have to call obj[PIPE_TO] or something like that?
by Drakim 3y ago
Would that mean that instead of obj.pipeTo() I'd have to call obj[PIPE_TO] or something like that?
- Tade0 3y agoEssentially. And then have: Object.prototype.pipeTo = Object.prototype[PIPE_TO] or some other name instead of `pipeTo` should there be a conflict. JS already has a few well-known symbols like Symbol.toPrimitive that allow one to modify an object's behaviour (in this case what happens when `valueOf` or `toString` is called), so there's precedent.