lazy.js

Do Immutable.js or Lazy.js perform short-cut fusion?

妖精的绣舞 提交于 2019-12-17 17:32:28
问题 First, let me define what is short-cut fusion for those of you who don't know. Consider the following array transformation in JavaScript: var a = [1,2,3,4,5].map(square).map(increment); console.log(a); function square(x) { return x * x; } function increment(x) { return x + 1; } Here we have an array, [1,2,3,4,5] , whose elements are first squared, [1,4,9,16,25] , and then incremented [2,5,10,17,26] . Hence, although we don't need the intermediate array [1,4,9,16,25] , we still create it.