GithubHelp home page GithubHelp logo

Comments (18)

RebeccaStevens avatar RebeccaStevens commented on June 19, 2024

I'm not sure what you mean. What's the difference between what it does by default and what you want?

from deepmerge.

RebeccaStevens avatar RebeccaStevens commented on June 19, 2024

Is this what you want?

{
  arrayMerge: (target, source, options) => {
    const destination = source.slice();
    source.forEach((item, index) => {
      destination.push(item);
    });
    return destination;
  }
}

from deepmerge.

wpoortman avatar wpoortman commented on June 19, 2024

I'm not sure what you mean. What's the difference between what it does by default and what you want?

My current deepmerge.all() returns:

{
  purge: {
    content: [
      'a/path/to/my/file-ca/path/to/my/file-da/path/to/my/file-ca/path/to/my/file-d'
    ]
  }
}

Instead of:

{
  purge: {
    content: [
      'a/path/to/my/file-c',
      'a/path/to/my/file-d',
      'a/path/to/my/file-c',
      'a/path/to/my/file-d'
    ]
  }
}

Edit: arrayMerge didn't work, the item is already concatenated when it does destination.push(item)

from deepmerge.

RebeccaStevens avatar RebeccaStevens commented on June 19, 2024

oh, the strings are getting concatenated together.
What does your arrayMerge function look like?

from deepmerge.

wpoortman avatar wpoortman commented on June 19, 2024

Currently no options are included, so the default of deepmerge.all()

from deepmerge.

RebeccaStevens avatar RebeccaStevens commented on June 19, 2024

I'm not able to recreate the issue: https://codesandbox.io/s/stupefied-matan-df2ri6?file=/src/index.ts

from deepmerge.

RebeccaStevens avatar RebeccaStevens commented on June 19, 2024

I'm not sure what might be causing this issue. You could try using my library instead and see if you are having the same issue with it: https://www.npmjs.com/package/deepmerge-ts

Note: deepmerge-ts was originally planned to be the next version of this library.

from deepmerge.

wpoortman avatar wpoortman commented on June 19, 2024

Which function in your lib would replace the .all() method?

from deepmerge.

RebeccaStevens avatar RebeccaStevens commented on June 19, 2024

deepmerge; it can take any number of arguments.

Note: If you want to provide it with an array of values, call it using the spread operator e.g. deepmerge(...args)

from deepmerge.

wpoortman avatar wpoortman commented on June 19, 2024

And deepmerge a object with an object? For some reason I can't figure out this API 😄

I have two situations:

  1. Merge a array of objects
  2. Merge an object with the result of 1

Note: Previously I would do deepmerge(deepmerge.all(myArray.map((extension) => {})), MyBaseObject)

from deepmerge.

RebeccaStevens avatar RebeccaStevens commented on June 19, 2024

So for 1. - Merging an array of objects into a single object, would just be deepmerge(...myArrayOfObjects).

I'm not sure what you mean by 2. but if it is just that line of code, the equivalent would be:
deepmerge(...(myArray.map((extension) => {})), MyBaseObject)

from deepmerge.

RebeccaStevens avatar RebeccaStevens commented on June 19, 2024

If you link me your code, I can take a look at it for you.

from deepmerge.

wpoortman avatar wpoortman commented on June 19, 2024

https://pastebin.com/qJ5c1j1c

The themes.json looks like:

{
  "extensions": [
    {
      "name": "package-a",
      "src": "vendor/internal/package-a/src"
    },
    {
      "name": "package-b",
      "src": "vendor/internal/package-b/src"
    }
  ]
}

And a custom tailwind.config.js inside of one of those paths:

module.exports = {
    purge: {
        content: [
            '/view/frontend/templates/**/*.phtml',
        ]
    }
}

Put a lot of time in this... almost at a point where I'm just telling myself to use the fix and move on haha

from deepmerge.

RebeccaStevens avatar RebeccaStevens commented on June 19, 2024

Does this work for you?

return deepmerge(
  ...themeConfig.extensions.map((extension) => {
    const configFilePath = themeDirBackTrails[backtrail] + extension.src + "/tailwind.config.js";

    if (fs.existsSync(configFilePath)) {
      return require(configFilePath);
    }

    return {};
  }),
  baseConfig
);

Here's a playground link: https://codesandbox.io/s/beautiful-perlman-edswlz?file=/src/test.js

from deepmerge.

wpoortman avatar wpoortman commented on June 19, 2024

It's doing something, but break somewhere in the middle. Hard to explain what's going on.

from deepmerge.

RebeccaStevens avatar RebeccaStevens commented on June 19, 2024

If you're able to provide more data I'll look into it more tomorrow.

from deepmerge.

wpoortman avatar wpoortman commented on June 19, 2024

If you're able to provide more data I'll look into it more tomorrow.

Is there a way I can reach you via chat or something? Would communicate a lot easier if you ask me. I'm going with my current solution because I really spent to much time into this issue where I can't understand a package would by default concatenate arrays...

Let me know

from deepmerge.

TehShrike avatar TehShrike commented on June 19, 2024

To get more help you would need to provide a REPL link that replicates your problem, and demonstrates the output that you expect as opposed to what the code produces

from deepmerge.

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.