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:
alisdair sullivan 2010-05-26 01:05:16 -07:00
parent 80112bce4a
commit 7d5ccfd86f
4 changed files with 7 additions and 148 deletions

View file

@ -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),