This is generally a weakness of text based programming languages, that you cannot easily express graph flows like:
/ B1 \ A>-| | -> C \ B2 /
In theory you can create something similar using JS OOP by attaching e.g. map/use(func) methods to every prototype:
function use(func) { func(this); return this; } function map(func) { return func(this); }
(1).map(n => n+1) .use(console.log) .map(n => "n = " + n) .use(n => console.log("str = $n"));
This is generally a weakness of text based programming languages, that you cannot easily express graph flows like:
|> operator only solves the problem for non-branched flows like A -> B -> C making them more readable by removing nested calls.In theory you can create something similar using JS OOP by attaching e.g. map/use(func) methods to every prototype:
and then: Introducing a new operator instead of a library is a huge effort. I don't think this proposal will succeed, especially that current custom operator support in JS is nil.