Skip to content
Snippets Groups Projects
Commit f5e4ad60 authored by Shpuld Shpludson's avatar Shpuld Shpludson
Browse files

wip start

parent 65ac7113
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@ export const replaceWord = (str, toReplace, replacement) => {
return str.slice(0, toReplace.start) + replacement + str.slice(toReplace.end)
}
// This seems to work fine
export const wordAtPosition = (str, pos) => {
const words = splitIntoWords(str)
const wordsWithPosition = addPositionToWords(words)
......@@ -11,6 +12,7 @@ export const wordAtPosition = (str, pos) => {
return find(wordsWithPosition, ({ start, end }) => start <= pos && end > pos)
}
// This works fine
export const addPositionToWords = (words) => {
return reduce(words, (result, word) => {
const data = {
......@@ -34,6 +36,7 @@ export const addPositionToWords = (words) => {
}, [])
}
// This needs to be altered, split words at space
export const splitIntoWords = (str) => {
// Split at word boundaries
const regex = /\b/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment