Skip to content

Commit 75f9083

Browse files
authored
split keyword arguments (#6)
1 parent c784f24 commit 75f9083

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

src/CodecZstd.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ import TranscodingStreams:
1616
initialize,
1717
finalize
1818

19+
# TODO: This method will be added in the next version of TranscodingStreams.jl.
20+
function splitkwargs(kwargs, keys)
21+
hits = []
22+
others = []
23+
for kwarg in kwargs
24+
push!(kwarg[1] keys ? hits : others, kwarg)
25+
end
26+
return hits, others
27+
end
28+
1929
include("libzstd.jl")
2030
include("compression.jl")
2131
include("decompression.jl")

src/compression.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ const ZstdCompressorStream{S} = TranscodingStream{ZstdCompressor,S} where S<:IO
3737
Create a new zstd compression stream (see `ZstdCompressor` for `kwargs`).
3838
"""
3939
function ZstdCompressorStream(stream::IO; kwargs...)
40-
return TranscodingStream(ZstdCompressor(;kwargs...), stream)
40+
x, y = splitkwargs(kwargs, (:level,))
41+
return TranscodingStream(ZstdCompressor(;x...), stream; y...)
4142
end
4243

4344

src/decompression.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ end
2121
const ZstdDecompressorStream{S} = TranscodingStream{ZstdDecompressor,S} where S<:IO
2222

2323
"""
24-
ZstdDecompressorStream(stream::IO)
24+
ZstdDecompressorStream(stream::IO; kwargs...)
2525
26-
Create a new zstd decompression stream.
26+
Create a new zstd decompression stream (`kwargs` are passed to `TranscodingStream`).
2727
"""
28-
function ZstdDecompressorStream(stream::IO)
29-
return TranscodingStream(ZstdDecompressor(), stream)
28+
function ZstdDecompressorStream(stream::IO; kwargs...)
29+
return TranscodingStream(ZstdDecompressor(), stream; kwargs...)
3030
end
3131

3232

0 commit comments

Comments
 (0)