@sapphire/framework
Version:
Discord bot framework built for advanced and amazing bots.
1 lines • 1.25 kB
Source Map (JSON)
{"version":3,"file":"boolean.mjs","names":[],"sources":["../../../../src/lib/resolvers/boolean.ts"],"sourcesContent":["import { Result } from '@sapphire/result';\nimport { Identifiers } from '../errors/Identifiers';\n\nconst baseTruths = ['1', 'true', '+', 't', 'yes', 'y'] as const;\nconst baseFalses = ['0', 'false', '-', 'f', 'no', 'n'] as const;\n\nexport function resolveBoolean(\n\tparameter: string,\n\tcustoms?: { truths?: readonly string[]; falses?: readonly string[] }\n): Result<boolean, Identifiers.ArgumentBooleanError> {\n\tconst boolean = parameter.toLowerCase();\n\n\tif ([...baseTruths, ...(customs?.truths ?? [])].includes(boolean)) {\n\t\treturn Result.ok(true);\n\t}\n\n\tif ([...baseFalses, ...(customs?.falses ?? [])].includes(boolean)) {\n\t\treturn Result.ok(false);\n\t}\n\n\treturn Result.err(Identifiers.ArgumentBooleanError);\n}\n"],"mappings":";;;;AAGA,MAAM,aAAa;CAAC;CAAK;CAAQ;CAAK;CAAK;CAAO;CAAI;AACtD,MAAM,aAAa;CAAC;CAAK;CAAS;CAAK;CAAK;CAAM;CAAI;AAEtD,SAAgB,eACf,WACA,SACoD;CACpD,MAAM,UAAU,UAAU,aAAa;AAEvC,KAAI,CAAC,GAAG,YAAY,GAAI,SAAS,UAAU,EAAE,CAAE,CAAC,SAAS,QAAQ,CAChE,QAAO,OAAO,GAAG,KAAK;AAGvB,KAAI,CAAC,GAAG,YAAY,GAAI,SAAS,UAAU,EAAE,CAAE,CAAC,SAAS,QAAQ,CAChE,QAAO,OAAO,GAAG,MAAM;AAGxB,QAAO,OAAO,IAAI,YAAY,qBAAqB"}