There is no option built-in.  I don't know of any existing libraries that
do this.  I would write it as a parser function that wraps the callback.

local function parseLine(emit)
  -- setup local variables here
  return function (chunk)
    -- look for newlines in chunk flushing and emit()ing data as you come
across them
    -- store leftover bytes in local variable for the next chunk.
  end
end

client:on("data", parseLine(function( line )
  -- data is now line parsed.
end))




On Mon, Jan 6, 2014 at 2:14 PM, develephant <[email protected]>wrote:

> Hello,
>
> I'm looking to see if there is a simple way to read the luvit tcp (smart)
> socket by line similar to the straight luasocket:
>
> client:*receive(*[pattern [, prefix]]*)*
>
>    - '*l': reads a line of text from the socket. The line is terminated
>    by a LF character (ASCII 10), optionally preceded by a CR character
>    (ASCII 13). The CR and LF characters are not included in the returned line.
>    In fact, *all* CR characters are ignored by the pattern. This is the
>    default pattern;
>
>
> http://w3.impa.br/~diego/software/luasocket/tcp.html#receive
>
> In luvit for example:
> client:on( "data", function( data )
>  --data is a line terminated by "\r\n"
> end)
>
> I'm a newbie on node, but I can't seem to find any option.  Is this
> possible?  Or will I need to parse it up myself?  Any advice would be
> appreciated.
>
> Cheers.
>
> --
> You received this message because you are subscribed to the Google Groups
> "luvit" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"luvit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to