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

Replace awkward last-element selection pattern with 'lastOrUndefined' #2996

Merged
merged 3 commits into from
May 4, 2015

Conversation

DanielRosenwasser
Copy link
Member

No description provided.

@@ -267,7 +267,7 @@ var ts;
var sourceMapNameIndexMap = {};
var sourceMapNameIndices = [];
function getSourceMapNameIndex() {
return sourceMapNameIndices.length ? sourceMapNameIndices[sourceMapNameIndices.length - 1] : -1;
return sourceMapNameIndices.length ? lastOrUndefined(sourceMapNameIndices) : -1;
Copy link
Contributor

Choose a reason for hiding this comment

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

lastOrUndefined is for calling on arrays that might be empty. You should never actually get undefined back in these cases, and we'd want to throw if you did. We should just have an 'last' functoin that only works on non-empty arrays, and throws otherwise.

@CyrusNajmabadi
Copy link
Contributor

👍

@DanielRosenwasser DanielRosenwasser force-pushed the lastOrUndefinedReplacement branch from a9c46e7 to 9460fb5 Compare May 2, 2015 01:36
DanielRosenwasser added a commit that referenced this pull request May 4, 2015
Replace awkward last-element selection pattern with 'lastOrUndefined'
@DanielRosenwasser DanielRosenwasser merged commit 4cc1848 into master May 4, 2015
@CyrusNajmabadi CyrusNajmabadi deleted the lastOrUndefinedReplacement branch June 4, 2015 00:26
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants