4 ms·
I imagine something like so: { "delete":["123-234","567-700"], "insert":[123,456], "substrs":[{"foo":"bar"},[]] } Then delete the ranges from
by theendisney 2y ago
I imagine something like so:
{
"delete":["123-234","567-700"],
"insert":[123,456],
"substrs":[{"foo":"bar"},[]]
}
Then delete the ranges from the string, convert the substrs to strings and insert them at the offset.
- Izkata 2y agoI'm not sure I understand what you mean, but it almost sounds like something we already have a single verb for: "splice". It means "replace this range with these values": z = ['a', 'b', 'c', 'd', 'e', 'f'] z.splice(2, 3, 'w', 'x', 'y', 'z') Array(7) [ "a", "b", "w", "x", "y", "z", "f" ] Unfortunately it's not on strings in javascript, but the verb has basically that meaning even outside of programming and could work here too. I don't see how the values in your example would work though.
- theendisney 2y agoThat seems to be it. You compare the old string with the new one. What should be deleted is marked for deletion. Say char 10 to 30. Then the insert part points at spots where new stuff should be inserted. Commas are left as an exercise for the backend.