Skip to content

Instantly share code, notes, and snippets.

@acquitelol
Last active October 8, 2025 23:59
Show Gist options
  • Select an option

  • Save acquitelol/8c164a343dc85bdada4b6d90e9b9abec to your computer and use it in GitHub Desktop.

Select an option

Save acquitelol/8c164a343dc85bdada4b6d90e9b9abec to your computer and use it in GitHub Desktop.
Implements piping in vanilla JS.
// @ts-nocheck
globalThis.rax = null;
// for when you need the return value of the expr
function pipe(_) { return globalThis.rax; };
function _(v) { return +(globalThis.rax = v); }
Object.defineProperty(Function.prototype, Symbol.toPrimitive, {
value: function() {
globalThis.rax = this(globalThis.rax);
return true;
},
writable: true,
configurable: true
});
_(13) |0> (x => x * 2)
|0> (x => x - 1)
|0> (x => `${x}!!`)
|0> console.log;
_(12) |0> console.log;
_([1, 2, 3])
|0> (x => x.map(y => y * 2))
|0> console.log;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment