File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 2
2
3
3
exports . typeImpl = function ( blob ) { return blob . type ; } ;
4
4
5
+ exports . blobImpl = function ( args ) {
6
+ return function ( mediaType ) {
7
+ return new Blob ( args , { type : mediaType } ) ;
8
+ } ;
9
+ } ;
10
+
5
11
exports . size = function ( blob ) { return blob . size ; } ;
6
12
7
13
exports . slice = function ( contentType ) {
Original file line number Diff line number Diff line change 1
1
module Web.File.Blob
2
2
( Blob
3
+ , fromString
4
+ , fromArray
3
5
, type_
4
6
, size
5
7
, StartByte (..)
@@ -20,6 +22,19 @@ import Unsafe.Coerce (unsafeCoerce)
20
22
21
23
foreign import data Blob :: Type
22
24
25
+ -- | Creates a String with the given Mediatype
26
+ -- | For example:
27
+ -- | ```
28
+ -- | myBlob = fromString (unsafeStringify { name: "Carl", age: 25 }) (MediaType "application/json")
29
+ -- | ```
30
+ fromString :: String -> MediaType -> Blob
31
+ fromString str ct = blobImpl [str] ct
32
+
33
+ -- | Creates a Blob from an Array of strings with the given Mediatype
34
+ fromArray :: Array String -> MediaType -> Blob
35
+ fromArray args opts = blobImpl args opts
36
+
37
+ foreign import blobImpl :: Array String -> MediaType -> Blob
23
38
foreign import typeImpl :: Blob -> String
24
39
25
40
-- | `MediaType` of the data contained in the `Blob`.
You can’t perform that action at this time.
0 commit comments