-
Notifications
You must be signed in to change notification settings - Fork 16
/
deno_io.deno.txt
94 lines (66 loc) · 5.23 KB
/
deno_io.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
DENO_IO
VERSION ==> #See deno doc
#Browser compatible, except RESOURCE
/=+===============================+=\
/ : : \
)==: MAIN :==(
\ :_______________________________: /
\=+===============================+=/
TextDecoder|Encoder[Stream] #Like DOM
CLOSER|READER|WRITER|SEEKER #Abstract class to implement
std/types.d.ts #Has Closer|Reader[Sync]|Writer[Sync] types
CLOSER.close() #Close underlying RESOURCE
READER.read(UINT8ARR)->>NUM|null #Reads available bytes from underlying RESOURCE and writes them into UINT8ARR.
#Usually does not wait i.e. might read:
# - 0 bytes
# - less than UINT8ARR.length
# - rest of UINT8ARR might be used for internal purposes though
#Only read up to UINT8ARR.length bytes.
#Returns NUM of bytes read, or null if EOF
WRITER.write(UINT8ARR)->>NUM #Reads all of UINT8ARR and writes it to underlying RESOURCE.
#Returns UINT8ARR.length
SEEKER.seek(NUM|BIGINT, ENUM) #Changes position used by READER.read() and WRITER.write()
->>NUM2 #NUM|BIGINT is relative offset in bytes
#ENUM is reference position among Deno.Seeker.Start|Current|End
#Before-start position is error. After-end position is implementation-dependent.
#NUM2 is new position.
/=+===============================+=\
/ : : \
)==: RESOURCE :==(
\ :_______________________________: /
\=+===============================+=/
RESOURCE #Abstraction of a file, including socket, etc.
#Usually ref'd by the process
RID #RESOURCE ID NUM. Abstraction of a file descriptor.
Deno.close(RID)
Deno.read(RID, ...)
Deno.write(RID, ...)
Deno.seek(RID, ...) #Same but on a RID
Deno.fdatasync(RID)->> #Flushes data to disk
Deno.fsync(RID)->> #Flushes data + inode modification (timestamps, permissions, etc.) to disk
Deno.readSync(...)
Deno.writeSync(...)
Deno.seekSync(...)
Deno.fdatasyncSync(...)
Deno.fsyncSync(...) #Same but sync
Deno.resources()->OBJ #Returns all RESOURCEs as { RID: VAL, ... }
#VAL is internal|undocumented
/=+===============================+=\
/ : : \
)==: ERRORS :==(
\ :_______________________________: /
\=+===============================+=/
Deno.errors.AlreadyExists #Create RESOURCE that already exists
Deno.errors.NotFound #RESOURCE not found
Deno.errors.IsADirectory #Expected a regular file but is a DIR
Deno.errors.NotADirectory #Inverse
Deno.errors.FilesystemLoop #Symlink loop
Deno.errors.InvalidData #Invalid IO read
Deno.errors.UnexpectedEof #IO read an EOF unexpectedly
Deno.errors.WriteZero #IO write 0 bytes
Deno.errors.BrokenPipe #IO write to a pipe done reading (SIGPIPE)
Deno.errors.TimedOut #IO timeout (ETIMEDOUT)
Deno.errors.Busy #RESOURCE locked by another RESOURCE
Deno.errors.BadResource #RESOURCE is in bad state