Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to attach merge strategies on objects as a Symbol #264

Open
dlespiau opened this issue Sep 15, 2019 · 0 comments
Open

Add the ability to attach merge strategies on objects as a Symbol #264

dlespiau opened this issue Sep 15, 2019 · 0 comments
Labels
kind/enhancement New feature or request topic/std Relates to the standard library

Comments

@dlespiau
Copy link
Member

dlespiau commented Sep 15, 2019

At the moment we have to explicitly tell merge the rules to merge two objects. For instance:

const pod = {
  spec: {
    containers: [{
      name: 'my-app',
      image: 'busybox',
      command: ['sh', '-c', 'echo Hello Kubernetes!'],
    },{
      name: 'sidecar',
      image: 'sidecar:v1',
    }],
  },
};

const sidecarImage = {
  spec: {
    containers: [{
      name: 'sidecar',
      image: 'sidecar:v2',
    }],
  },
};

merge(pod, sidecarImage, {
  spec: {
    containers: deepWithKey('name'),
  },
});

We could attach:

{
  spec: {
    containers: deepWithKey('name'),
  },
}

as a Symbol on the left-hand side object and have merge pick it up automatically (only if the 3rd argument to merge is undefined though).

We could start having well known jk.* symbols, say Symbol.for('jk.merge') for this one.

@dlespiau dlespiau added kind/enhancement New feature or request topic/std Relates to the standard library labels Sep 15, 2019
@dlespiau dlespiau changed the title Add the ability to attach merge strategies on object as a Symbol Add the ability to attach merge strategies on objects as a Symbol Sep 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request topic/std Relates to the standard library
Projects
None yet
Development

No branches or pull requests

1 participant