17 lines
394 B
Lua
17 lines
394 B
Lua
-- Arrow functions in Lua
|
|
-- f = (n) => 2 + n
|
|
|
|
return function(op)
|
|
return {
|
|
name = 'Arrow functions',
|
|
transform = function(e, opts)
|
|
return e.src
|
|
-- multiple-line
|
|
:gsub('%(([^%(%)]*)%)%s*==>%s*(.-)%s<==',
|
|
'function(%1) %2 end')
|
|
-- single-line
|
|
:gsub('%(([^%(%)]*)%)%s*=>[ \t\v\f]*([^\n\r]*)',
|
|
'function(%1) return %2 end')
|
|
end,
|
|
}
|
|
end
|