(task: string)
| 6 | completed: boolean; |
| 7 | }; |
| 8 | export const parseTask = (task: string) : Task => { |
| 9 | let completed = false; |
| 10 | let text = ''; |
| 11 | if (task.startsWith("- [ ] ")) { |
| 12 | completed = false; |
| 13 | text = task.slice(6); |
| 14 | } else if (task.startsWith("- [x] ")) { |
| 15 | completed = true; |
| 16 | text = task.slice(6); |
| 17 | } |
| 18 | const tags = text.match(/#(\w+)/g) ?? []; |
| 19 | const date = text.match(/\^(\d{4}-\d{2}-\d{2})/) ?? []; |
| 20 | return { |
| 21 | text: text.replace(/#(\w+)/g, "").replace(/\^(\d{4}-\d{2}-\d{2})/, ""), |
| 22 | tags: tags.map(f => f.replace("#", "")), |
| 23 | date: date[1], |
| 24 | completed |
| 25 | } |
| 26 | } |
| 27 |
nothing calls this directly
no test coverage detected