lodash / babel-plugin-lodash

Modular Lodash builds without the hassle.
Other
1.96k stars 91 forks source link

Lazy evaluation not working for fp.flow #229

Closed dongseok0 closed 5 years ago

dongseok0 commented 5 years ago

Hi,

It seems lazy evaluation is not working when I use babel-plugin-lodash and lodash-webpack-plugin. For example,

_.flow(
  _.filter(n => {
    console.log(n);
    return n > 0;
  }),
  _.take(5),
)([...Array(12)].map((n, i) => i));

It results with plugin ( lazy evaluation not working )

0 1 2 3 4 5 6 7 8 9 10 11

But lazy evaluation is working well without plugins.

0 1 2 3 4 5

Here's plugin configuration

new LodashModuleReplacementPlugin({
      shorthands: true,
      collections: true,
      coercions: true,
      placeholders: true,
      flattening: true,
      currying: true,
    }),
dongseok0 commented 5 years ago

Ah.. it seems fp lazy evaluation is working as chain internally. Which means not supported by plugins. If it's correct, close the issue please!

jdalton commented 5 years ago

That's correct @dongseok0!