Skip to content

Commit f609036

Browse files
committed
Remove unnecessary returns and use default parameters
1 parent c39723c commit f609036

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

lib/coffee-script/lexer.js

+5-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lexer.coffee

+5-8
Original file line numberDiff line numberDiff line change
@@ -634,27 +634,24 @@ exports.Lexer = class Lexer
634634
else
635635
column += string.length
636636

637-
return [@chunkLine + lineCount, column]
637+
[@chunkLine + lineCount, column]
638638

639639
# Same as "token", exception this just returns the token without adding it
640640
# to the results.
641-
makeToken: (tag, value, offsetInChunk, length) ->
642-
offsetInChunk = offsetInChunk || 0
643-
if length is undefined then length = value.length
644-
641+
makeToken: (tag, value, offsetInChunk = 0, length = value.length) ->
645642
locationData = {}
646643
[locationData.first_line, locationData.first_column] =
647644
@getLineAndColumnFromChunk offsetInChunk
648645

649646
# Use length - 1 for the final offset - we're supplying the last_line and the last_column,
650647
# so if last_column == first_column, then we're looking at a character of length 1.
651-
lastCharacter = if length > 0 then (length - 1) else 0
648+
lastCharacter = Math.max 0, length - 1
652649
[locationData.last_line, locationData.last_column] =
653650
@getLineAndColumnFromChunk offsetInChunk + (length - 1)
654651

655652
token = [tag, value, locationData]
656653

657-
return token
654+
token
658655

659656
# Add a token to the results.
660657
# `offset` is the offset into the current @chunk where the token starts.
@@ -665,7 +662,7 @@ exports.Lexer = class Lexer
665662
token: (tag, value, offsetInChunk, length) ->
666663
token = @makeToken tag, value, offsetInChunk, length
667664
@tokens.push token
668-
return token
665+
token
669666

670667
# Peek at a tag in the current token stream.
671668
tag: (index, tag) ->

0 commit comments

Comments
 (0)