Skip to content

Commit 58b5390

Browse files
committed
Extract Blob
1 parent 4aefb8c commit 58b5390

File tree

4 files changed

+46
-48
lines changed

4 files changed

+46
-48
lines changed

src/FileAPI/Blob.js

+10-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/FileAPI/Blob.res

+26-15
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,43 @@ open FileAPI
66
@new
77
external make: (~blobParts: array<blobPart>=?, ~options: blobPropertyBag=?) => blob = "Blob"
88

9-
/**
9+
module Impl = (
10+
T: {
11+
type t
12+
},
13+
) => {
14+
external asBlob: T.t => blob = "%identity"
15+
/**
1016
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Blob/slice)
1117
*/
12-
@send
13-
external slice: (blob, ~start: int=?, ~end: int=?, ~contentType: string=?) => blob = "slice"
18+
@send
19+
external slice: (T.t, ~start: int=?, ~end: int=?, ~contentType: string=?) => blob = "slice"
1420

15-
/**
21+
/**
1622
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Blob/stream)
1723
*/
18-
@send
19-
external stream: blob => readableStream<array<int>> = "stream"
24+
@send
25+
external stream: T.t => readableStream<array<int>> = "stream"
2026

21-
/**
27+
/**
2228
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Blob/text)
2329
*/
24-
@send
25-
external text: blob => Promise.t<string> = "text"
30+
@send
31+
external text: T.t => Promise.t<string> = "text"
2632

27-
/**
33+
/**
2834
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Blob/arrayBuffer)
2935
*/
30-
@send
31-
external arrayBuffer: blob => Promise.t<ArrayBuffer.t> = "arrayBuffer"
36+
@send
37+
external arrayBuffer: T.t => Promise.t<ArrayBuffer.t> = "arrayBuffer"
3238

33-
/**
39+
/**
3440
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Blob/bytes)
3541
*/
36-
@send
37-
external bytes: blob => Promise.t<array<int>> = "bytes"
42+
@send
43+
external bytes: T.t => Promise.t<array<int>> = "bytes"
44+
}
45+
46+
include Impl({
47+
type t = blob
48+
})

src/FileAPI/File.js

+6-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/FileAPI/File.res

+4-31
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
open FileAPI
22

3+
include Blob.Impl({
4+
type t = file
5+
})
6+
37
/**
48
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/File)
59
*/
@@ -9,34 +13,3 @@ external make: (
913
~fileName: string,
1014
~options: filePropertyBag=?,
1115
) => file = "File"
12-
13-
external asBlob: file => blob = "%identity"
14-
/**
15-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Blob/slice)
16-
*/
17-
@send
18-
external slice: (file, ~start: int=?, ~end: int=?, ~contentType: string=?) => blob = "slice"
19-
20-
/**
21-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Blob/stream)
22-
*/
23-
@send
24-
external stream: file => readableStream<array<int>> = "stream"
25-
26-
/**
27-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Blob/text)
28-
*/
29-
@send
30-
external text: file => Promise.t<string> = "text"
31-
32-
/**
33-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Blob/arrayBuffer)
34-
*/
35-
@send
36-
external arrayBuffer: file => Promise.t<ArrayBuffer.t> = "arrayBuffer"
37-
38-
/**
39-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Blob/bytes)
40-
*/
41-
@send
42-
external bytes: file => Promise.t<array<int>> = "bytes"

0 commit comments

Comments
 (0)