UNPKG

ts-mdls

Version:

Lightweigth, dependency free, fully typed wrapper of the macOS `mdls` command

16 lines (14 loc) 367 B
import parseNull, { IsNotNullError } from "./parseNull"; export default function checkNull<T>(parser: (value: string) => T) { return (value: string) => { try { return parseNull(value); } catch (maybeError) { if (maybeError instanceof IsNotNullError) { return parser(value); } else { throw maybeError; } } }; }