import { parseCubeLut } from './formats/cube' import { parseLutFormat } from './lutFormat' import { Lut } from './typings' /** * Parses the input LUT. It will try to detect the format, and will default * to Adobe's .cube * @param input */ export const parseLut = async ( input: string | Uint8Array | ArrayBuffer | Buffer ): Promise => { const options: { data: Uint8Array } = { data: new Uint8Array() } // Convert input to Uint8Array if ((input as Buffer).writeBigInt64BE) { options.data = new Uint8Array((input as Buffer).buffer) } if ((input as Uint8Array).buffer) { options.data = input as Uint8Array } if ((input as ArrayBuffer).byteLength) { options.data = new Uint8Array(input as ArrayBuffer) } const format = parseLutFormat(options) switch (format) { case 'cube': return parseCubeLut(options.data) } } export type { Lut }