For consideration: https://github.com/chalk/wrap-ansi
No sense reinventing the wheel. But will it build for browser? I seem to recall Sindre doesn't value browser compatibility for these kinds of things since they're mostly used for Node.js after all.