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

Immutablejs #21

Closed
pablohpsilva opened this issue Feb 22, 2017 · 2 comments
Closed

Immutablejs #21

pablohpsilva opened this issue Feb 22, 2017 · 2 comments
Labels

Comments

@pablohpsilva
Copy link

First things first: I loved this lib!

Is there a way to add ImmutableJS into dot-object lib? I think it would be cool and would enhance the performance.

@rhalff
Copy link
Owner

rhalff commented Feb 23, 2017

That would become a different library I think, dot-object is mutating everything in-place.

What methods / functions would like to use along side with ImmutableJS?

@pablohpsilva
Copy link
Author

I see... I thought it was mutating the source element into something else, that's why I opened this issue to see if you could use ImmutableJS in this lib advantage.

I read the move and set functions and now I get what the lib's doing.

It might be a crazy idea, but... I think dot-object can use it. Since it is creating a new object, it could create a immutable one. How? The main idea would be:

const obj = {
  'first_name': 'John',
  'last_name': 'Doe'
};

const attributeList = [
  'from|to',
  'first_name|contact.firstname',
  'last_name|contact.lastname'
];

const immutableObj = dot.move(attributeList, obj);

Then, the move function would be something that uses the Immutable.Map, for example, and would return a immutable object as result;

export const move = (attributeList, obj) => {
  const aux = (Iterable.isIterable(obj)) ? obj : Immutable.Map(obj);
  const nObject = ... // apply attributeList `aux` to create nObject;
  return Immutable.Map(nObject);
};

That function could check if the obj is already a ImmutableJS obj and take advantage on delete, set, get, merge, and some other cool functions provided by ImmutableJS itself.

@rhalff rhalff added the wontfix label Sep 20, 2017
@rhalff rhalff closed this as completed Sep 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants