mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-18 11:31:20 -05:00
adding a new comprehension 'for all key, value of object', which compiles to the naked JS for..in, including enumerable properties inherited from prototypes.
This commit is contained in:
@@ -1226,6 +1226,7 @@ exports.ForNode: class ForNode extends BaseNode
|
||||
@source: source.source
|
||||
@guard: source.guard
|
||||
@step: source.step
|
||||
@raw: !!source.raw
|
||||
@object: !!source.object
|
||||
[@name, @index]: [@index, @name] if @object
|
||||
@pattern: @name instanceof ValueNode
|
||||
@@ -1291,10 +1292,13 @@ exports.ForNode: class ForNode extends BaseNode
|
||||
else
|
||||
varPart: (namePart or '') and (if @pattern then namePart else "${@idt(1)}$namePart;\n")
|
||||
if @object
|
||||
forPart: "$ivar in $svar) { if (${utility('hasProp')}.call($svar, $ivar)"
|
||||
if @raw
|
||||
forPart: "$ivar in $svar"
|
||||
else
|
||||
forPart: "$ivar in $svar) { if (${utility('hasProp')}.call($svar, $ivar)"
|
||||
body: body.compile(merge(o, {indent: @idt(1), top: true}))
|
||||
vars: if range then name else "$name, $ivar"
|
||||
close: if @object then '}}' else '}'
|
||||
close: if @object and not @raw then '}}' else '}'
|
||||
"${sourcePart}for ($forPart) {\n$varPart$body\n$@tab$close$returnResult"
|
||||
|
||||
#### IfNode
|
||||
|
||||
Reference in New Issue
Block a user