While working with lodash, I found that it applied shortcut fusion when I used implicit chaining.
$ node -e 'const _ = require("lodash"); _([1,2,3]).map(n => { console.log(n); return n }).find(n => n <= 1)'
1
But when I changed this snippet to use explicit chaining, it doesn't apply shortcut fusion.
$ node -e 'const _ = require("lodash"); _.chain([1,2,3]).map(n => { console.log(n); return n }).find(n => n <= 1).value()'
1
2
3
As you can see, a function passed to map
was called three times instead of once, which indicates lodash didn't apply shortcut fusion.
From their document, shortcut fusion should seem to be applied in both cases.
I use lodash 4.17.5 on node.js v8.10.0.
I found a ticket about this issue at their GitHub project.
It's unexpected but is what it is for now.