/** Alias for a value that might come in a Promise. */ export type Awaitable = T | Promise /** String that has been decrypted. */ export type DecodedValue = string /** String that has been encrypted. */ export type EncodedValue = string /** A key used for encryption. */ export type KeyValue = string /** * Interface that designates a particular value as able to be constructed. */ export interface Instantiable { new(...args: any[]): T } /** * Returns true if the given value is instantiable. * @param what */ export function isInstantiable(what: unknown): what is Instantiable { return ( Boolean(what) && (typeof what === 'object' || typeof what === 'function') && (what !== null) && 'constructor' in what && typeof what.constructor === 'function' ) } /** * Serialized payload of a given value. */ export type EncodedPayload = string /** * Determines that a given item is a valid serialized payload. * @param what */ export function isEncodedPayload(what: unknown): what is EncodedPayload { if ( typeof what !== 'string' ) { return false } return what.startsWith('multicrypt:') }