sneeuwvlok/lib/strings/default.nix
Chris Kruining 1873bb7170
Some checks failed
Test action / kaas (push) Failing after 1s
initial implementation of terranix for zitadel. SUPER HAPPY, SUPER COOL!!!
2025-10-22 23:26:47 +02:00

17 lines
No EOL
487 B
Nix

{ lib, ...}:
let
inherit (builtins) isString typeOf;
inherit (lib) throwIfNot concatStringsSep splitStringBy toLower map;
in
{
strings = {
toSnakeCase =
str:
throwIfNot (isString str) "toSnakeCase only accepts string values, but got ${typeOf str}" (
str
|> splitStringBy (prev: curr: builtins.match "[a-z]" prev != null && builtins.match "[A-Z]" curr != null) true
|> map (p: toLower p)
|> concatStringsSep "_"
);
};
}