@@ -966,21 +966,18 @@ exports.Assign = class Assign extends Base
966
966
# Compile the assignment from an array splice literal, using JavaScript's
967
967
# `Array#splice` method.
968
968
compileSplice : (o ) ->
969
- {range } = @variable .properties .pop ()
970
- name = @variable .compile o
971
- excl = range .exclusive
972
- to = " #{ name} .length" unless range .to
973
- if range .from
974
- [fromDecl , fromRef ] = range .from .cache o, LEVEL_OP
975
- else
976
- [fromDecl , fromRef ] = [' 0' , ' 0' ]
977
- unless to
978
- if range .from and range .from .isSimpleNumber () and range .to .isSimpleNumber ()
979
- to = + range .to .compile (o) - + fromRef
980
- to += 1 unless excl
969
+ {range : {from , to , exclusive }} = @variable .properties .pop ()
970
+ name = @variable .compile o
971
+ [fromDecl , fromRef ] = if from then from .cache (o, LEVEL_OP) else [' 0' , ' 0' ]
972
+ if to
973
+ if from and from .isSimpleNumber () and to .isSimpleNumber ()
974
+ to = + to .compile (o) - + fromRef
975
+ to += 1 unless exclusive
981
976
else
982
- to = range .to .compile (o) + ' - ' + fromRef
983
- to += ' + 1' unless excl
977
+ to = to .compile (o) + ' - ' + fromRef
978
+ to += ' + 1' unless exclusive
979
+ else
980
+ to = " #{ name} .length"
984
981
val = @value .compile (o)
985
982
" [].splice.apply(#{ name} , [#{ fromDecl} , #{ to} ].concat(#{ val} ))"
986
983
0 commit comments