FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
msgpack-javascript/src/decodeAsync.ts at main · msgpack/msgpack-javascript · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
msgpack
/
msgpack-javascript
Public
Notifications
You must be signed in to change notification settings
Fork
180
Star
1.6k
Code
Issues
18
Pull requests
6
Discussions
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
msgpack-javascript
/
src
/
decodeAsync.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
44 lines (41 loc) · 1.8 KB
Breadcrumbs
msgpack-javascript
/
src
/
decodeAsync.ts
Copy path
File metadata and controls
44 lines (41 loc) · 1.8 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import
{
Decoder
}
from
"./Decoder.ts"
;
import
{
ensureAsyncIterable
}
from
"./utils/stream.ts"
;
import
type
{
DecoderOptions
}
from
"./Decoder.ts"
;
import
type
{
ReadableStreamLike
}
from
"./utils/stream.ts"
;
import
type
{
SplitUndefined
}
from
"./context.ts"
;
/**
*
@throws
{
@link RangeError
} if the buffer is incomplete, including the case where the buffer is empty.
*
@throws
{
@link DecodeError
} if the buffer contains invalid data.
*/
export
async
function
decodeAsync
<
ContextType
=
undefined
>
(
streamLike
:
ReadableStreamLike
<
ArrayLike
<
number
>
|
BufferSource
>
,
options
?:
DecoderOptions
<
SplitUndefined
<
ContextType
>
>
,
)
:
Promise
<
unknown
>
{
const
stream
=
ensureAsyncIterable
(
streamLike
)
;
const
decoder
=
new
Decoder
(
options
)
;
return
decoder
.
decodeAsync
(
stream
)
;
}
/**
*
@throws
{
@link RangeError
} if the buffer is incomplete, including the case where the buffer is empty.
*
@throws
{
@link DecodeError
} if the buffer contains invalid data.
*/
export
function
decodeArrayStream
<
ContextType
>
(
streamLike
:
ReadableStreamLike
<
ArrayLike
<
number
>
|
BufferSource
>
,
options
?:
DecoderOptions
<
SplitUndefined
<
ContextType
>
>
,
)
:
AsyncGenerator
<
unknown
,
void
,
unknown
>
{
const
stream
=
ensureAsyncIterable
(
streamLike
)
;
const
decoder
=
new
Decoder
(
options
)
;
return
decoder
.
decodeArrayStream
(
stream
)
;
}
/**
*
@throws
{
@link RangeError
} if the buffer is incomplete, including the case where the buffer is empty.
*
@throws
{
@link DecodeError
} if the buffer contains invalid data.
*/
export
function
decodeMultiStream
<
ContextType
>
(
streamLike
:
ReadableStreamLike
<
ArrayLike
<
number
>
|
BufferSource
>
,
options
?:
DecoderOptions
<
SplitUndefined
<
ContextType
>
>
,
)
:
AsyncGenerator
<
unknown
,
void
,
unknown
>
{
const
stream
=
ensureAsyncIterable
(
streamLike
)
;
const
decoder
=
new
Decoder
(
options
)
;
return
decoder
.
decodeStream
(
stream
)
;
}
Back
|
FazBrowse Home
|
New Git URL