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 22
33exports . typeImpl = function ( blob ) { return blob . type ; } ;
44
5+ exports . blobImpl = function ( args ) {
6+ return function ( mediaType ) {
7+ return new Blob ( args , { type : mediaType } ) ;
8+ } ;
9+ } ;
10+
511exports . size = function ( blob ) { return blob . size ; } ;
612
713exports . slice = function ( contentType ) {
Original file line number Diff line number Diff line change 11module Web.File.Blob
22 ( Blob
3+ , fromString
4+ , fromArray
35 , type_
46 , size
57 , StartByte (..)
@@ -20,6 +22,19 @@ import Unsafe.Coerce (unsafeCoerce)
2022
2123foreign import data Blob :: Type
2224
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
2338foreign import typeImpl :: Blob -> String
2439
2540-- | `MediaType` of the data contained in the `Blob`.
You can’t perform that action at this time.
0 commit comments