removed the default callback handler, replaced it with an anonymous function. also added a shortcut for a decoder with the default handler but custom opts
This commit is contained in:
parent
80112bce4a
commit
7d5ccfd86f
4 changed files with 7 additions and 148 deletions
|
@ -24,13 +24,17 @@
|
|||
-module(jsx).
|
||||
-author("alisdairsullivan@yahoo.ca").
|
||||
|
||||
-export([decoder/0, decoder/2, tail_clean/1]).
|
||||
-export([decoder/0, decoder/1, decoder/2, tail_clean/1]).
|
||||
|
||||
-include("jsx_common.hrl").
|
||||
|
||||
|
||||
decoder() ->
|
||||
decoder({none, []}, []).
|
||||
decoder([]).
|
||||
|
||||
decoder(Opts) ->
|
||||
F = fun(eof, State) -> lists:reverse(State) ;(Event, State) -> [Event] ++ State end,
|
||||
decoder({F, []}, Opts).
|
||||
|
||||
decoder(Callbacks, OptsList) when is_list(OptsList) ->
|
||||
Opts = parse_opts(OptsList),
|
||||
|
|
|
@ -456,10 +456,6 @@ maybe_comment_done(<<>>, Resume) ->
|
|||
|
||||
%% helper function for dispatching of parser events
|
||||
|
||||
callback(eof, {none, Callbacks}) ->
|
||||
lists:reverse(Callbacks);
|
||||
callback(Event, {none, Callbacks}) ->
|
||||
{none, [Event] ++ Callbacks};
|
||||
callback(eof, {{Mod, Function}, State}) ->
|
||||
Mod:Function(eof, State);
|
||||
callback(Event, {{Mod, Function}, State}) ->
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue