export type Index = { [key: string]: T }; export type Option = T | undefined; export const map = (a: Option, f: (a: A) => B): Option => { return a ? f(a) : undefined; }; export const flatMap = (a: Option, f: (a: A) => Option): Option => { return a ? f(a) : undefined; }; export const getOrElse = (t: Option, _default: T): T => { return t ? t : _default; }; export const obfuscateString = (rawString?: string): string | undefined => { if (!rawString) { return undefined; } const stringLength = rawString.length; if (stringLength === 0) { return ''; } else { const clearSize = Math.floor(0.3 * stringLength); const clear = rawString.substring(0, clearSize); const obfuscated = 'X'.repeat(stringLength - clearSize); return clear + obfuscated; } };