import sanitize from "./sanitize" interface ToDictionaryOptions { seperator?: string | RegExp; sanitize?: boolean; } const main = (text: string, options?: ToDictionaryOptions) => { if (options?.sanitize) { text = sanitize(text) } const array = text.split(options?.seperator || " ") const dictionary: Record = {} let index = 0 array.forEach((el) => { if (dictionary[el] !== undefined) return dictionary[el] = index index++ }) return dictionary } export default main export type { ToDictionaryOptions }