Skip to content

Commit

Permalink
Remove 'default' from encoder opts and tweak README (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
williamthome authored Jul 29, 2024
1 parent 1f443d2 commit 4759d69
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 43 deletions.
70 changes: 38 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,29 @@ The second argument of `euneus:encode/2` are options, and this is the spec:
-type options() :: #{
nulls => [term()],
skip_values => [term()],
escape => default | fun((binary()) -> iodata()),
integer => default | encode(integer()),
float => default | encode(float()),
atom => default | encode(atom()),
list => default | encode(list()),
escape => fun((binary()) -> iodata()),
integer => encode(integer()),
float => encode(float()),
atom => encode(atom()),
list => encode(list()),
proplist => boolean() | {true, is_proplist()},
map => default | encode(map()),
map => encode(map()),
sort_keys => boolean(),
tuple => default
| encode(tuple())
| [ datetime
| timestamp
| ipv4
| ipv6
| {record, #{Name :: atom() => {Fields :: [atom()], Size :: pos_integer()}}
| [{Name :: atom(), Fields :: [atom()]}]}
| fun((tuple()) -> next | {halt, term()})],
pid => default | encode(pid()),
port => default | encode(port()),
reference => default | encode(reference())
tuple =>
encode(tuple())
| [
datetime
| timestamp
| ipv4
| ipv6
| {record,
#{Name :: atom() => {Fields :: [atom()], Size :: pos_integer()}}
| [{Name :: atom(), Fields :: [atom()]}]}
| fun((tuple()) -> next | {halt, term()})
],
pid => encode(pid()),
port => encode(port()),
reference => encode(reference())
}.
```

Expand All @@ -83,24 +86,27 @@ The second argument of `euneus:decode/2` are options, and this is the spec:

```erlang
-type options() :: #{
codecs => [ copy
| timestamp
| datetime
| ipv4
| ipv6
| pid
| port
| reference
| fun((binary()) -> next | {halt, term()})],
codecs => [
copy
| timestamp
| datetime
| ipv4
| ipv6
| pid
| port
| reference
| fun((binary()) -> next | {halt, term()})
],
array_start => json:array_start_fun(),
array_push => json:array_push_fun(),
array_finish => json:array_finish_fun(),
object_start => json:object_start_fun(),
object_keys => binary
| copy
| atom
| existing_atom
| json:from_binary_fun(),
object_keys =>
binary
| copy
| atom
| existing_atom
| json:from_binary_fun(),
object_push => json:object_push_fun(),
object_finish => json:object_finish_fun(),
float => json:from_binary_fun(),
Expand Down
21 changes: 10 additions & 11 deletions src/euneus_encoder.erl
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,16 @@
-type options() :: #{
nulls => [term()],
skip_values => [term()],
escape => default | fun((binary()) -> iodata()),
integer => default | encode(integer()),
float => default | encode(float()),
atom => default | encode(atom()),
list => default | encode(list()),
escape => fun((binary()) -> iodata()),
integer => encode(integer()),
float => encode(float()),
atom => encode(atom()),
list => encode(list()),
proplist => boolean() | {true, is_proplist()},
map => default | encode(map()),
map => encode(map()),
sort_keys => boolean(),
tuple =>
default
| encode(tuple())
encode(tuple())
| [
datetime
| timestamp
Expand All @@ -86,9 +85,9 @@
| [{Name :: atom(), Fields :: [atom()]}]}
| fun((tuple()) -> next | {halt, term()})
],
pid => default | encode(pid()),
port => default | encode(port()),
reference => default | encode(reference())
pid => encode(pid()),
port => encode(port()),
reference => encode(reference())
}.
-export_type([options/0]).

Expand Down

0 comments on commit 4759d69

Please sign in to comment.