-
Notifications
You must be signed in to change notification settings - Fork 0
/
LockedFile.cljs
287 lines (192 loc) · 8.06 KB
/
LockedFile.cljs
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
(ns web.files.LockedFile
"The LockedFile interface provides tools to deal with a given
with all the necessary locks."
(:refer-clojure :exclude [flush]))
(defn get-metadata
"Method.
The getMetadata method allows to retrieve some metadata about
locked file.
`var request = instanceOfLockedFile.getMetadata(param);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/LockedFile/getMetaData`"
[this param]
(-> this (.getMetadata param)))
(defn read-as-array-buffer
"Method.
The readAsArrayBuffer method is used to read the content of the
object and provide the result of that reading as an `js.ArrayBuffer`.
many ways, it performs like the `FileReader.readAsArrayBuffer()`
`var request = instanceOfLockedFile.readAsArrayBuffer(size);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/LockedFile/readAsArrayBuffer`"
[this size]
(-> this (.readAsArrayBuffer size)))
(defn read-as-text
"Method.
The readAsText method is used to read the content of the `web.files.LockedFile`
and provide the result of that reading as a string. In many ways,
performs like the `FileReader.readAsText()` method.
`var request = instanceOfLockedFile.readAsText(size[, encoding]);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/LockedFile/readAsText`"
[this & args]
(-> this .-readAsText (.apply this (clj->js args))))
(defn write
"Method.
The write method is used to write some data within the file.
`var request = instanceOfLockedFile.write(data);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/LockedFile/write`"
[this data]
(-> this (.write data)))
(defn append
"Method.
The append method is used to write some data at the end of the
`var request = instanceOfLockedFile.append(data);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/LockedFile/append`"
[this data]
(-> this (.append data)))
(defn truncate
"Method.
The truncate method is used to remove some data within the file.
`var request = instanceOfLockedFile.truncate(start);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/LockedFile/truncate`"
[this start]
(-> this (.truncate start)))
(defn flush
"Method.
The flush method is used to ensure any change made to a file
properly written on disk.
`var request = instanceOfLockedFile.flush();`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/LockedFile/flush`"
[this ]
(-> this (.flush)))
(defn abort
"Method.
The abort method is used to release the lock on the `web.files.LockedFile`
making it inactive: its `active` property is set to false and
ongoing operations are canceled.
`var request = instanceOfLockedFile.abort();`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/LockedFile/abort`"
[this ]
(-> this (.abort)))
(defn file-handle
"Property.
The fileHandle property gives access to the `FileHandle` object
produced the `web.files.LockedFile` object.
`var handler = instanceOfLockedFile.fileHandle`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/LockedFile/fileHandle`"
[this]
(-> this (.-fileHandle)))
(defn set-file-handle!
"Property.
The fileHandle property gives access to the `FileHandle` object
produced the `web.files.LockedFile` object.
`var handler = instanceOfLockedFile.fileHandle`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/LockedFile/fileHandle`"
[this val]
(aset this "fileHandle" val))
(defn mode
"Property.
The mode property provides the read/write status of the `web.files.LockedFile`
`var mode = instanceOfLockedFile.mode`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/LockedFile/mode`"
[this]
(-> this (.-mode)))
(defn set-mode!
"Property.
The mode property provides the read/write status of the `web.files.LockedFile`
`var mode = instanceOfLockedFile.mode`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/LockedFile/mode`"
[this val]
(aset this "mode" val))
(defn active
"Property.
The active property allows to know if the `web.files.LockedFile`
is still usable (true) or not (false). If the object is inactive
it is impossible to perform any read or write operation with
Typically, a `web.files.LockedFile` object becomes inactive when
`LockedFile.abort()` method is called or if an error occurs.
`var state = instanceOfLockedFile.active`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/LockedFile/active`"
[this]
(-> this (.-active)))
(defn set-active!
"Property.
The active property allows to know if the `web.files.LockedFile`
is still usable (true) or not (false). If the object is inactive
it is impossible to perform any read or write operation with
Typically, a `web.files.LockedFile` object becomes inactive when
`LockedFile.abort()` method is called or if an error occurs.
`var state = instanceOfLockedFile.active`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/LockedFile/active`"
[this val]
(aset this "active" val))
(defn location
"Property.
The location property is a zero-based index representing the
of the read/write pointer within the file. Its value indicates
which bytes within the file any write or read operation will
`var location = instanceOfLockedFile.location`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/LockedFile/location`"
[this]
(-> this (.-location)))
(defn set-location!
"Property.
The location property is a zero-based index representing the
of the read/write pointer within the file. Its value indicates
which bytes within the file any write or read operation will
`var location = instanceOfLockedFile.location`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/LockedFile/location`"
[this val]
(aset this "location" val))
(defn oncomplete
"Property.
Specifies an event listener to receive complete events. These
occur each time a read or write operation is successful.
`instanceOfLockedFile.oncomplete = funcRef;
Where funcRef is a function to be called when the complete event occurs.`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/LockedFile/oncomplete`"
[this]
(-> this (.-oncomplete)))
(defn set-oncomplete!
"Property.
Specifies an event listener to receive complete events. These
occur each time a read or write operation is successful.
`instanceOfLockedFile.oncomplete = funcRef;
Where funcRef is a function to be called when the complete event occurs.`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/LockedFile/oncomplete`"
[this val]
(aset this "oncomplete" val))
(defn onabort
"Property.
Specifies an event listener to receive abort events. These events
when the locked file has been aborted with the `LockedFile.abort()`
`instanceOfLockedFile.onabort = funcRef;
Where funcRef is a function to be called when the abort event occurs.`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/LockedFile/onabort`"
[this]
(-> this (.-onabort)))
(defn set-onabort!
"Property.
Specifies an event listener to receive abort events. These events
when the locked file has been aborted with the `LockedFile.abort()`
`instanceOfLockedFile.onabort = funcRef;
Where funcRef is a function to be called when the abort event occurs.`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/LockedFile/onabort`"
[this val]
(aset this "onabort" val))
(defn onerror
"Property.
Specifies an event listener to receive error events. These events
when something goes wrong.
`instanceOfLockedFile.onerror = funcRef;
Where funcRef is a function to be called when the error event occurs.`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/LockedFile/onerror`"
[this]
(-> this (.-onerror)))
(defn set-onerror!
"Property.
Specifies an event listener to receive error events. These events
when something goes wrong.
`instanceOfLockedFile.onerror = funcRef;
Where funcRef is a function to be called when the error event occurs.`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/LockedFile/onerror`"
[this val]
(aset this "onerror" val))