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

setSize may only downsize #35

Closed
sumeetsgh93 opened this issue Sep 8, 2016 · 4 comments
Closed

setSize may only downsize #35

sumeetsgh93 opened this issue Sep 8, 2016 · 4 comments

Comments

@sumeetsgh93
Copy link

While using this library with immutable-js, we are encountering a typedError "setSize may only downsize".
But there could be cases in which list size might increase. Why there is this restriction of downsize?

@davecoates
Copy link
Member

davecoates commented Sep 8, 2016

I'm assuming this was done as if you increase the size the elements would only be valid if they were a Maybe type, eg. if you had a List(Number) and you increase it's size then all new elements would be undefined as so not be valid numbers.

@sumeetsgh93
Copy link
Author

Thanks for quick response.
So in function function mergeIntoListWith(list, merger, iterables) {
var iters = [];
var maxSize = 0;
for (var ii = 0; ii < iterables.length; ii++) {
var value = iterables[ii];
var iter = IndexedIterable(value);
if (iter.size > maxSize) {
maxSize = iter.size;
}
if (!isIterable(value)) {
iter = iter.map(v => fromJS(v));
}
iters.push(iter);
}
if (maxSize > list.size) {
list = list.setSize(maxSize);
}

return mergeIntoCollectionWith(list, merger, iters);
}

setSize is called to increase the size of the list (immutable-js).

But in typed-immutable setSize is restricting upsize.
setSize(size) {
if (size > this.size) {
throw TypeError(setSize may only downsize)
}

return change(this, store => store.setSize(size))

}

I am a bit confused on how both are supposed to work together.

@davecoates
Copy link
Member

Ah - so this is when you attempt to merge two lists?

I think we will have to implement a custom merge function on List to handle this

@sumeetsgh93
Copy link
Author

Any rough timeline for this? We are facing issues because of this. Obviously, we will do some workarounds for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants