Search code examples
livescript

How to ignore return result


for example

child.stdout.on \data (buffer) -> 
   result.stdout += buffer

-->

child.stdout.on('data', function(buffer){
  return result.stdout += buffer;
});

and I need it without return. In F# I can add |> ignore how can I handle it in livescript?


Solution

  • You can prepend an ! to the definition of the function:

    !(buffer) -> result.stdout += buffer
    

    Alternatively, return void

    child.stdout.on \data (buffer) -> 
       result.stdout += buffer
       void
    

    In JavaScript, when you return undefined (void), it is the same as not returning anything.