Skip to content

use Array.from to expand array splats#965

Merged
rhendric merged 1 commit intogkz:masterfrom
rhendric:fix/LiveScript-963
May 22, 2017
Merged

use Array.from to expand array splats#965
rhendric merged 1 commit intogkz:masterfrom
rhendric:fix/LiveScript-963

Conversation

@rhendric
Copy link
Copy Markdown
Collaborator

Prior to this commit, [].slice was used to turn array-like things into
arrays when needed for splats in array literals. This commit uses
Array.from instead, when available at runtime, and falls back to slice
when not. This allows a wider range of iterables to be used as splats,
on the platforms that support them (platforms missing Array.from will
also be missing more exotic iterables).

Fix #963.


As a relatively simple bug fix, I'm setting the comment period for this at one week, after which I will merge on May 22 if nobody has any concerns.

Prior to this commit, [].slice was used to turn array-like things into
arrays when needed for splats in array literals. This commit uses
Array.from instead, when available at runtime, and falls back to slice
when not. This allows a wider range of iterables to be used as splats,
on the platforms that support them (platforms missing Array.from will
also be missing more exotic iterables).

Fix gkz#963.
Comment thread src/ast.ls
}
}'''

array-from: 'Array.from || function(x){return slice$.call(x);}'
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the second part of "or" just be slice$.call? Or is there a reason for the wrapping function

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did try that, but Function.prototype.call needs something to bind it to slice$ or it forgets where it came from.

@rhendric rhendric merged commit 8b32262 into gkz:master May 22, 2017
@rhendric rhendric deleted the fix/LiveScript-963 branch May 22, 2017 19:16
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

Successfully merging this pull request may close these issues.

Use Array.from instead of [].slice

2 participants