-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
util: deduplicate stripStr implementation
- Loading branch information
1 parent
5ae21e7
commit 29a5cbe
Showing
3 changed files
with
11 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
# Small utilities for internal reuse, not exposed externally | ||
{ lib }: | ||
let | ||
inherit (builtins) filter match split; | ||
inherit (builtins) filter match split head; | ||
inherit (lib) isString; | ||
|
||
isEmptyStr = s: isString s && match " *" s == null; | ||
in | ||
{ | ||
splitComma = s: if s == "" then [ ] else filter isEmptyStr (split " *, *" s); | ||
|
||
stripStr = s: | ||
let | ||
t = match "[\t ]*(.*[^\t ])[\t ]*" s; | ||
in | ||
if t == null | ||
then "" | ||
else head t; | ||
} |