diff --git a/src/jsx_utils.erl b/src/jsx_utils.erl index 8f1eaf9..f30c104 100644 --- a/src/jsx_utils.erl +++ b/src/jsx_utils.erl @@ -23,7 +23,10 @@ -module(jsx_utils). --export([parse_opts/1, extract_opts/1, nice_decimal/1, json_escape/2]). +-export([parse_opts/1, extract_opts/1]). +-export([nice_decimal/1]). +-export([json_escape/2]). +-export([handle_event/2, init/1]). -include("../include/jsx_opts.hrl"). @@ -63,6 +66,7 @@ extract_parser_opts([K|Rest], Acc) -> end. + %% conversion of floats to 'nice' decimal output. erlang's float implementation %% is almost but not quite ieee 754. it converts negative zero to plain zero %% silently, and throws exceptions for any operations that would produce NaN @@ -262,6 +266,13 @@ to_hex(15) -> $f; to_hex(X) -> X + 48. %% ascii "1" is [49], "2" is [50], etc... + +handle_event(Event, {F, undefined}) -> F(Event), {F, undefined}; +handle_event(Event, {F, State}) -> {F, F(Event, State)}. + +init(State) -> State. + + %% eunit tests -ifdef(TEST). -include_lib("eunit/include/eunit.hrl").