-
Notifications
You must be signed in to change notification settings - Fork 16
/
deno_json_sequence.deno.txt
37 lines (30 loc) · 2.71 KB
/
deno_json_sequence.deno.txt
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
DENO_JSON_SEQUENCE
VERSION ==> #Part of Deno
#Browser compatible
std/json/json_stringify_stream.ts #
new JsonStringifyStream([OPTS]) #Apply JSON.stringify() on each chunk
->TSTREAM #Examples of formats:
# - start '' end '\n' (def) or '\r\n': ndjson|jsonlines (see its doc)
# - start U+001E, end U+000A: json text sequence (see its doc)
#JSON.stringify() automatically escapes most delimiters (such as '\n') used in the chunk itself.
OPTS.prefix #STR (def: ''). Start of each produced chunk
OPTS.suffix #STR (def: '\n'). End of each produced chunk
OPTS.readableStrategy
OPTS.writableStrategy #Custom QUEUING_STRATEGY
std/json/json_parse_stream.ts #
new JsonParseStream([OPTS]) #Apply JSON.parse() on each chunk
->TSTREAM #JSON.parse():
# - trims whitespaces, i.e. works with ndjson|jsonlines
# - but not U+001E, which throws, i.e. does not work with json text sequences
#Ignore chunks with only whitespaces
# - as required|recommended by most formats
#JSON.stringify|parse() errors are propagated
# - required by ndjson, but forbidden by json text sequences
OPTS.readableStrategy
OPTS.writableStrategy #Custom QUEUING_STRATEGY
std/json/
concatenated_json_parse_stream.ts#
new ConcatenatedJsonParseStream
([OPTS])->TSTREAM #Like JsonParseStream, but for concatenated JSON (see its doc)