UNPKG

remix-nlux

Version:

Remix IDE NLUX integration. Remix IDE is the leading IDE for building and deploying smart contracts on Ethereum. NLUX is a JavaScript and React library for building conversational AI experiences.

26 lines (20 loc) 785 B
import {AiChatProps, AiChatPropsInEvents} from '../types/aiChat/props'; export const propsToCorePropsInEvents = <AiMsg>( props: AiChatProps<AiMsg>, ): AiChatPropsInEvents<AiMsg> => { // All keys except the adapter key type KeyType = keyof AiChatPropsInEvents<AiMsg>; const excludeKeys: (keyof AiChatProps<AiMsg>)[] = [ 'adapter', 'events', ]; const keys: KeyType[] = Object.keys(props).filter( (key) => !excludeKeys.includes(key as keyof AiChatProps<AiMsg>), ) as KeyType[]; const result = {} as Record<KeyType, AiChatPropsInEvents<AiMsg>[KeyType]>; for (let i = 0; i < keys.length; i++) { const key: KeyType = keys[i]; result[key] = props[key]; } return result as AiChatPropsInEvents<AiMsg>; };