This repository was archived by the owner on Oct 4, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +7
-17
lines changed Expand file tree Collapse file tree 2 files changed +7
-17
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ exports.appendString = function(form) {
1616 } ;
1717} ;
1818
19- exports . appendFile = function ( form ) {
19+ exports . appendWithName = function ( form ) {
2020 return function ( key ) {
2121 return function ( val ) {
2222 return function ( name ) {
@@ -27,13 +27,3 @@ exports.appendFile = function(form) {
2727 } ;
2828} ;
2929
30- exports . appendBlob = function ( form ) {
31- return function ( key ) {
32- return function ( val ) {
33- return function ( name ) {
34- form . append ( key , val , name ) ;
35- return { } ;
36- } ;
37- } ;
38- } ;
39- } ;
Original file line number Diff line number Diff line change 11module DOM.XHR.FormData (FormDataValue (..), toFormData ) where
22
3+ import Data.Foldable
34import Data.Tuple
45import DOM.File.Types
56import DOM.XHR.Types
@@ -12,19 +13,18 @@ data FormDataValue =
1213 | FormDataBlob String Blob -- ^ Blob name and `Blob` object.
1314
1415-- | Convert an associated array of keys and values to a `FormData`.
15- toFormData :: Array (Tuple String FormDataValue ) -> FormData
16+ toFormData :: forall f . ( Foldable f ) => f (Tuple String FormDataValue ) -> FormData
1617toFormData dat =
1718 let form = newFormData unit in
18- let _unit = map (appendData form) dat in
19+ let _unit = foldMap (appendData form) dat in
1920 form
2021
2122 where
2223 appendData form (Tuple key (FormDataString val)) = appendString form key val
23- appendData form (Tuple key (FormDataFile name val)) = appendFile form key val name
24- appendData form (Tuple key (FormDataBlob name val)) = appendBlob form key val name
24+ appendData form (Tuple key (FormDataFile name val)) = appendWithName form key val name
25+ appendData form (Tuple key (FormDataBlob name val)) = appendWithName form key val name
2526
2627foreign import newFormData :: Unit -> FormData
2728
2829foreign import appendString :: FormData -> String -> String -> Unit
29- foreign import appendFile :: FormData -> String -> File -> String -> Unit
30- foreign import appendBlob :: FormData -> String -> Blob -> String -> Unit
30+ foreign import appendWithName :: forall a . FormData -> String -> a -> String -> Unit
You can’t perform that action at this time.
0 commit comments