Missing dissocIn. #14

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

Comments

Projects
None yet
3 participants
@ngbrown

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 aearly added the enhancement label Dec 2, 2015

@aearly

This comment has been minimized.

Show comment
Hide comment
@aearly

aearly Dec 2, 2015

Owner

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) );

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) );

@mdgbayly mdgbayly referenced this issue in davidkpiano/react-redux-form Apr 8, 2016

Closed

Question: Action to remove a property from an object? #128

@neekey

This comment has been minimized.

Show comment
Hide comment
@neekey

neekey Aug 16, 2016

+1 for this API

neekey commented Aug 16, 2016

+1 for this API

@aearly aearly added the help wanted label Dec 7, 2016

@aearly

This comment has been minimized.

Show comment
Hide comment
@aearly

aearly Dec 8, 2016

Owner

@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)

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

This comment has been minimized.

Show comment
Hide comment
@neekey

neekey 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 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

This comment has been minimized.

Show comment
Hide comment
@neekey

neekey Jan 6, 2017

Hi @aearly any progress for this feature?

neekey commented Jan 6, 2017

Hi @aearly any progress for this feature?

@aearly

This comment has been minimized.

Show comment
Hide comment
@aearly

aearly Jan 6, 2017

Owner

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

Owner

aearly commented Jan 6, 2017

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

tscholl2 added a commit to tscholl2/icepick that referenced this issue Jan 9, 2018

@tscholl2 tscholl2 referenced this issue Jan 9, 2018

Merged

Dissoc in #37

@aearly

This comment has been minimized.

Show comment
Hide comment
@aearly

aearly Jan 10, 2018

Owner

Closed in #37 !

Owner

aearly commented Jan 10, 2018

Closed in #37 !

@aearly aearly closed this Jan 10, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment