Skip to content

Commit 27f3e34

Browse files
committed
Add Search.length
1 parent 963c31e commit 27f3e34

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/Lib/Search.elm

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module Lib.Search exposing
1010
, isEmptyQuery
1111
, isEmptyResults
1212
, isSearching
13+
, length
1314
, queriesEquals
1415
, query
1516
, queryEquals
@@ -189,6 +190,25 @@ isEmptyQuery =
189190
query >> String.isEmpty
190191

191192

193+
length : Search a -> Maybe Int
194+
length s =
195+
case s of
196+
NotAsked _ ->
197+
Nothing
198+
199+
Searching _ (Just r) ->
200+
Just (SearchResults.length r)
201+
202+
Searching _ Nothing ->
203+
Nothing
204+
205+
Success _ r ->
206+
Just (SearchResults.length r)
207+
208+
Failure _ _ ->
209+
Nothing
210+
211+
192212
isEmptyResults : Search a -> Maybe Bool
193213
isEmptyResults s =
194214
case s of

0 commit comments

Comments
 (0)