@@ -50,8 +50,8 @@ defmodule Jason.Formatter do
50
50
"""
51
51
@ spec pretty_print ( iodata , opts ) :: binary
52
52
def pretty_print ( iodata , opts \\ [ ] ) do
53
- pretty_print_to_iolist ( iodata , opts )
54
- |> :erlang . list_to_binary
53
+ pretty_print_to_iodata ( iodata , opts )
54
+ |> IO . iodata_to_binary
55
55
end
56
56
57
57
@@ -61,19 +61,19 @@ defmodule Jason.Formatter do
61
61
62
62
See `pretty_print/2` for details and options.
63
63
"""
64
- @ spec pretty_print_to_iolist ( iodata , opts ) :: iolist
65
- def pretty_print_to_iolist ( iodata , opts \\ [ ] ) do
64
+ @ spec pretty_print_to_iodata ( iodata , opts ) :: iodata
65
+ def pretty_print_to_iodata ( iodata , opts \\ [ ] ) do
66
66
depth = 0
67
67
in_str = false
68
68
in_bs = false
69
69
empty = false
70
70
first = true
71
71
opts = normalize_opts ( opts )
72
72
73
- { iolist , _state } =
73
+ { output , _state } =
74
74
pp_iodata ( iodata , [ ] , depth , in_str , in_bs , empty , first , opts )
75
75
76
- iolist
76
+ output
77
77
end
78
78
79
79
@@ -95,8 +95,8 @@ defmodule Jason.Formatter do
95
95
"""
96
96
@ spec minimize ( iodata , opts ) :: binary
97
97
def minimize ( iodata , opts \\ [ ] ) do
98
- minimize_to_iolist ( iodata , opts )
99
- |> :erlang . list_to_binary
98
+ minimize_to_iodata ( iodata , opts )
99
+ |> IO . iodata_to_binary
100
100
end
101
101
102
102
@@ -106,9 +106,9 @@ defmodule Jason.Formatter do
106
106
107
107
See `minimize/2` for details and options.
108
108
"""
109
- @ spec minimize_to_iolist ( iodata , opts ) :: iolist
110
- def minimize_to_iolist ( iodata , opts ) do
111
- pretty_print_to_iolist (
109
+ @ spec minimize_to_iodata ( iodata , opts ) :: iodata
110
+ def minimize_to_iodata ( iodata , opts ) do
111
+ pretty_print_to_iodata (
112
112
iodata ,
113
113
indent: "" ,
114
114
line_separator: "" ,
@@ -151,14 +151,14 @@ defmodule Jason.Formatter do
151
151
152
152
@ spec pp_iodata (
153
153
iodata , ## input -- input data
154
- iolist , ## output_acc -- output iolist (built in reverse order)
154
+ iodata , ## output_acc -- output iolist (built in reverse order)
155
155
non_neg_integer , ## depth -- current nesting depth
156
156
boolean , ## in_str -- is the current byte in a string?
157
157
boolean , ## in_bs -- does the current byte follow a backslash in a string?
158
158
boolean , ## empty -- is the current object or array empty?
159
159
boolean , ## first -- is this the first object or array in the input?
160
160
opts
161
- ) :: { iolist , pp_state }
161
+ ) :: { iodata , pp_state }
162
162
defp pp_iodata ( input , output_acc , depth , in_str , in_bs , empty , first , opts )
163
163
164
164
defp pp_iodata ( "" , output_acc , depth , in_str , in_bs , empty , first , opts ) do
@@ -173,7 +173,7 @@ defmodule Jason.Formatter do
173
173
pp_byte ( byte , rest , output_acc , depth , in_str , in_bs , empty , first , opts )
174
174
end
175
175
176
- defp pp_iodata ( byte , output_acc , depth , in_str , in_bs , empty , first , opts ) when is_number ( byte ) do
176
+ defp pp_iodata ( byte , output_acc , depth , in_str , in_bs , empty , first , opts ) when is_integer ( byte ) do
177
177
pp_byte ( byte , [ ] , output_acc , depth , in_str , in_bs , empty , first , opts )
178
178
end
179
179
@@ -191,14 +191,14 @@ defmodule Jason.Formatter do
191
191
@ spec pp_byte (
192
192
byte , ## byte -- current byte
193
193
iodata , ## rest -- rest of input data
194
- iolist , ## output -- output iolist (built in reverse order)
194
+ iodata , ## output -- output iolist (built in reverse order)
195
195
non_neg_integer , ## depth -- current nesting depth
196
196
boolean , ## in_str -- is the current byte in a string?
197
197
boolean , ## in_bs -- does the current byte follow a backslash in a string?
198
198
boolean , ## empty -- is the current object or array empty?
199
199
boolean , ## first -- is this the first object or array in the input?
200
200
opts
201
- ) :: { iolist , pp_state }
201
+ ) :: { iodata , pp_state }
202
202
defp pp_byte ( byte , rest , output , depth , in_str , in_bs , empty , first , opts )
203
203
204
204
## in string, following backslash
@@ -239,7 +239,7 @@ defmodule Jason.Formatter do
239
239
first -> byte
240
240
empty -> [ opts [ :line_separator ] , tab ( opts , depth ) , byte ]
241
241
depth == 0 -> [ opts [ :record_separator ] , byte ]
242
- :else -> byte
242
+ true -> byte
243
243
end
244
244
first = false
245
245
empty = true
0 commit comments