File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -6,3 +6,4 @@ package-lock.json
66/bower_components /
77/node_modules /
88/output /
9+ * .swp
Original file line number Diff line number Diff line change @@ -2,12 +2,15 @@ module Web.File.FileList
22 ( FileList
33 , length
44 , item
5+ , items
56 ) where
67
78import Prelude
89
9- import Data.Maybe (Maybe )
10+ import Data.Maybe (Maybe (..) )
1011import Data.Nullable (Nullable , toMaybe )
12+ import Data.Array (snoc )
13+ import Data.Tuple (Tuple (..))
1114import Web.File.File (File )
1215
1316foreign import data FileList :: Type
@@ -20,3 +23,12 @@ foreign import _item :: Int -> FileList -> Nullable File
2023-- | Get `File` at the certain position
2124item :: Int -> FileList -> Maybe File
2225item i = toMaybe <<< _item i
26+
27+ items :: FileList -> Array File
28+ items fl = untilNothing (\c fs -> Tuple (c + 1 ) <<< snoc fs <$> item c fl) 0 mempty
29+
30+ untilNothing :: forall a b . (a -> b -> Maybe (Tuple a b )) -> a -> b -> b
31+ untilNothing f x y = let m = f x y in
32+ case m of (Just (Tuple x' y')) -> untilNothing f x' y'
33+ Nothing -> y
34+
You can’t perform that action at this time.
0 commit comments