import { DomSource , events , query } from '@motorcycle/dom' ; import { Stream , filter , map } from 'most' ; import { todoAppStyles } from './styles' ; export function newTodo ( dom ) { const newItem = query ( `.${ todoAppStyles . newTodoClass }` , dom ) ; const keyDown$ = events ( 'keydown' , newItem ) ; const enterKey$ = filter ( isEnterKey , keyDown$ ) ; const trimmedValue$ = map ( trimmedValue , enterKey$ ) ; return trimmedValue$ ; } function isEnterKey ( event ) { const ENTER_KEY = 13 ; return event . keyCode === ENTER_KEY ; } function trimmedValue ( event ) { return String ( ( event . target as HTMLInputElement ) . value ) . trim ( ) ; }