/
Body.cljs
132 lines (95 loc) · 3.62 KB
/
Body.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
(ns web.fetch.Body
"The Body mixin of the Fetch API represents the body of the response/request,
you to declare what its content type is and how it should be"
(:refer-clojure :exclude []))
(defn array-buffer
"Method.
The arrayBuffer() method of the `web.fetch.Body` mixin takes
`web.fetch.Response` stream and reads it to completion. It returns
promise that resolves with an `js.ArrayBuffer`.
`response.arrayBuffer().then(function(buffer) {
// do something with buffer
});`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/Body/arrayBuffer`"
[this & args]
(apply (-> this .-arrayBuffer) (concat [this] args)))
(defn blob
"Method.
The blob() method of the `web.fetch.Body` mixin takes a `web.fetch.Response`
and reads it to completion. It returns a promise that resolves
a `web.files.Blob`.
`response.blob().then(function(myBlob) {
// do something with myBlob
});`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/Body/blob`"
[this & args]
(apply (-> this .-blob) (concat [this] args)))
(defn form-data
"Method.
The formData() method of the `web.fetch.Body` mixin takes a `web.fetch.Response`
and reads it to completion. It returns a promise that resolves
a `web.FormData` object.
`response.formData()
.then(function(formdata) {
// do something with your formdata
});`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/Body/formData`"
[this & args]
(apply (-> this .-formData) (concat [this] args)))
(defn json
"Method.
The json() method of the `web.fetch.Body` mixin takes a `web.fetch.Response`
and reads it to completion. It returns a promise that resolves
the result of parsing the body text as `js.JSON`.
`response.json().then(data => {
// do something with your data
});`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/Body/json`"
[this & args]
(apply (-> this .-json) (concat [this] args)))
(defn text
"Method.
The text() method of the `web.fetch.Body` mixin takes a `web.fetch.Response`
and reads it to completion. It returns a promise that resolves
a `web.USVString` object (text). The response is always decoded
UTF-8.
`response.text().then(function (text) {
// do something with the text response
});`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/Body/text`"
[this & args]
(apply (-> this .-text) (concat [this] args)))
(defn body
"Property.
The body read-only property of the `web.fetch.Body` mixin is
simple getter used to expose a `web.files.ReadableStream` of
body contents.
`var stream = responseInstance.body;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/Body/body`"
[this]
(-> this (.body)))
(defn set-body!
"Property.
The body read-only property of the `web.fetch.Body` mixin is
simple getter used to expose a `web.files.ReadableStream` of
body contents.
`var stream = responseInstance.body;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/Body/body`"
[this val]
(aset this "body" val))
(defn body-used
"Property.
The bodyUsed read-only property of the `web.fetch.Body` mixin
a `js.Boolean` that indicates whether the body has been read
`var myBodyUsed = response.bodyUsed;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/Body/bodyUsed`"
[this]
(-> this (.bodyUsed)))
(defn set-body-used!
"Property.
The bodyUsed read-only property of the `web.fetch.Body` mixin
a `js.Boolean` that indicates whether the body has been read
`var myBodyUsed = response.bodyUsed;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/Body/bodyUsed`"
[this val]
(aset this "bodyUsed" val))