Giter Club home page Giter Club logo

Comments (15)

coderaiser avatar coderaiser commented on June 16, 2024 1

Thanks! Just fixed šŸŽ‰ . Please re-install šŸŠ. Is it works for you?

from putout.

sirenkovladd avatar sirenkovladd commented on June 16, 2024

It's better now, but I don't see any transformation and the forEach still exists

āÆ node tt.js
(a.forEach((aa) => d.push(aa)), b.forEach((bb) => d.push(bb)));

----------------------
(a.forEach((aa) => d.push(aa)), b.forEach((bb) => d.push(bb)));

from putout.

coderaiser avatar coderaiser commented on June 16, 2024

What kind of transformation you expect to see here?

from putout.

sirenkovladd avatar sirenkovladd commented on June 16, 2024

in my opinion, it should be the most appropriate

(function() {
    for (const aa of a)
        d.push(aa);
}(),
function() {
    for (const bb of b)
        d.push(bb);
}())

can correct me if you think otherwise

from putout.

sirenkovladd avatar sirenkovladd commented on June 16, 2024

not sure if this applies to this task but I'll write here first
for code

const js = `const z=a.forEach(aa=>d.push(aa))`;

result

āÆ node tt.js
const z = a.forEach((aa) => d.push(aa));

----------------------
const z;

I expect something like

const z = function() {
    for (const bb of b)
        d.push(bb);
}()

from putout.

coderaiser avatar coderaiser commented on June 16, 2024

Just fixed šŸŽ‰ . Please re-install šŸŠ. Is it works for you?

Here is a new rule for merging loops: minify/merge-loops.

About const z=a.forEach(aa=>d.push(aa)), forEach() returns nothing so better to keep this code as is.

from putout.

sirenkovladd avatar sirenkovladd commented on June 16, 2024

But it removes the loop and without minification it causes a push
and after that it doesn't do anything

from putout.

coderaiser avatar coderaiser commented on June 16, 2024

Have you tried new version?

from putout.

sirenkovladd avatar sirenkovladd commented on June 16, 2024

Oh yes, the version was not the last
now I have a row without changes
I just thought that plugin-for-of must strictly change to for-of

but if it is skipped for minification then it seems it should just use a more complex condition than just replacing or skipping it

from putout.

coderaiser avatar coderaiser commented on June 16, 2024

Look, @putout/plugin-for-of used both in Putout linter and Minify, so when trapped on SequenceExpression it just skippes transformation, since we have @putout/plugin-extract-sequence-expression which will do the thing first.

About your case:

a.forEach(aa=>d.push(aa)),
b.forEach(bb=>d.push(bb))`;

Now with help of @putout/plugin-minify it will be transformed to:

for (const aa of [...a, ...b]) {
    d.push(aa);
}

And then all whitespaces will be reduced.

it seems it should just use a more complex condition than just replacing or skipping it

What do you suggest?

from putout.

sirenkovladd avatar sirenkovladd commented on June 16, 2024

Thank you, I understand now, thanks for the solution

from putout.

sirenkovladd avatar sirenkovladd commented on June 16, 2024

And could you update the minify version as well?

from putout.

coderaiser avatar coderaiser commented on June 16, 2024

It is updated, just re-install it

from putout.

sirenkovladd avatar sirenkovladd commented on June 16, 2024

I see that the last version was a month ago
https://www.npmjs.com/package/minify?activeTab=versions

from putout.

coderaiser avatar coderaiser commented on June 16, 2024

Iā€™m using semantic versioning, just re-install minify and it will update all dependencies.

from putout.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.