diff --git a/src/eFmt.erl b/src/eFmt.erl index a7b98c6..6d474fb 100644 --- a/src/eFmt.erl +++ b/src/eFmt.erl @@ -10,6 +10,9 @@ format/2 , format/3 + , formatBin/2 + , formatBin/3 + , scan/2 , build/1 , build/2 @@ -60,6 +63,22 @@ format(Format, Args, Options) -> erlang:error(badarg, [Format, Args]) end. +-spec formatBin(Format :: io:format(), Data :: [term()]) -> chars(). +formatBin(Format, Args) -> + try iolist_to_binary(fWrite(Format, Args)) + catch + _C:_R:S -> + erlang:error(badarg, [Format, Args, _C, _R, S]) + end. + +-spec formatBin(Format :: io:format(), Data :: [term()], Options :: [{charsLimit, CharsLimit :: charsLimit()}]) -> chars(). +formatBin(Format, Args, Options) -> + try iolist_to_binary(fWrite(Format, Args, Options)) + catch + _C:_R -> + erlang:error(badarg, [Format, Args]) + end. + -spec scan(Format :: io:format(), Data :: [term()]) -> FormatList :: [char() | fmtSpec()]. scan(Format, Args) -> try fScan(Format, Args)