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

Missing dissocIn. #14

Closed
ngbrown opened this issue Dec 2, 2015 · 7 comments
Closed

Missing dissocIn. #14

ngbrown opened this issue Dec 2, 2015 · 7 comments

Comments

@ngbrown
Copy link

ngbrown commented Dec 2, 2015

Just as dissoc is the pair to assoc but removes a key, dissocIn should be the pair to assocIn and remove the key at the end of a path (passed as an array).

@aearly
Copy link
Owner

aearly commented Dec 2, 2015

I'm keeping an eye on this: http://dev.clojure.org/jira/browse/CLJ-1063

There's an open question as to whether empty arrays/objects in the hierarchy would be dissoc'd as well.

In the meantime you can use i.assocIn(obj, path, undefined) or i.updateIn(obj, path, (obj) => i.dissoc(obj, prop) );

@neekey
Copy link

neekey commented Aug 16, 2016

+1 for this API

@aearly
Copy link
Owner

aearly commented Dec 8, 2016

@neekey Should

i.dissocIn({
  a: {
    b: {
      c: 1
    },
  a2: 1
}, ['a', 'b', 'c'])`

return

{
  a: {
    b: {}
  },
  a2: 1
}

or

{
  a2: 1
}

(e.g. should it remove intermediate empty collections)

@neekey
Copy link

neekey commented Dec 9, 2016

hi @aearly I think it shouldn't remove intermediate empty collections. It's kind of an unexpected behavior if it does so.

In a normal delete scene, it will keep the empty collections:

const obj = { a: { b: 1 } };
delete obj.a.b;
console.log( obj.a ); // output: '{}'

@neekey
Copy link

neekey commented Jan 6, 2017

Hi @aearly any progress for this feature?

@aearly
Copy link
Owner

aearly commented Jan 6, 2017

I haven't decided what to do exactly. It's not pressing since there's a workaround.

tscholl2 pushed a commit to tscholl2/icepick that referenced this issue Jan 9, 2018
@tscholl2 tscholl2 mentioned this issue Jan 9, 2018
@aearly
Copy link
Owner

aearly commented Jan 10, 2018

Closed in #37 !

@aearly aearly closed this as completed Jan 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants