UNPKG

@livepeer/core

Version:

Livepeer UI Kit's core vanilla JS library.

58 lines (50 loc) 2.4 kB
interface IObject { [key: string]: any; } type TUnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never; interface DeepMergeOptions { mergeArrays: boolean; } declare const deepMerge: { <T extends IObject[]>(...objects: T): TUnionToIntersection<T[number]>; options: DeepMergeOptions; withOptions<T extends IObject[]>(options: Partial<DeepMergeOptions>, ...objects: T): TUnionToIntersection<T[number]>; }; /** * Create a new object containing only the specified keys */ declare const pick: <T extends object, K extends keyof T>(obj: T, ...keys: readonly K[]) => Pick<T, K>; /** * Create a new object excluding the specified keys */ declare function omit<T extends object, K extends keyof T>(obj: T, ...keys: readonly K[]): Omit<T, K>; /** * Takes an Arweave URL and returns a formatted Arweave URL if it is valid. * _This does not allow paths, query params, or hash in the URL and will return null_. * It does not check if the hash is a correct base64 URL encoded SHA-256 hash * * @param possibleArweaveString A possible URL for an Arweave resource. Can be a gateway or Arweave protocol URL. * @returns The formatted Arweave URI with `ar://` protocol and hash. Returns null if the URL is not valid. */ declare const parseArweaveTxId: (possibleArweaveString: string | null | undefined) => { url: string; id: string; } | null; /** * Takes an IPFS CID or URL and returns a formatted IPFS URL if the CID/URL is valid. * _This does not allow paths, query params, or hash in the URL and will return null_. * * @param possibleIpfsString A possible URL for an IPFS resource. Can be a gateway or IPFS protocol URL. * @returns The formatted IPFS URI with protocol and CID. Returns null if the URL is not valid. */ declare const parseCid: (possibleIpfsString: string | null | undefined) => { url: string; id: string; } | null; declare const b64Encode: (input: string) => string | null; declare const b64Decode: (input: string) => string | null; declare const b64UrlEncode: (input: string) => string | null; declare const b64UrlDecode: (input: string) => string | null; declare const noop: (..._args: any[]) => void; declare function warn(message: string, id?: string): void; export { b64Decode, b64Encode, b64UrlDecode, b64UrlEncode, deepMerge, noop, omit, parseArweaveTxId, parseCid, pick, warn };