Closed gajus closed 8 years ago
Oh, wow.
Honestly, I looked around and did not find any libraries solving this problem, which is why I wrote it. As you only had created it a few days before, it probably wasn't showing up very high on search results.
Your implementation is a lot better. I just lazily use every chalk supported ANSI code to close each slice.
I will deprecate my package in favour of https://github.com/chalk/slice-ansi.
https://github.com/gajus/ansi-slice#deprecated
NPM package has been deprecated too.
:+1:
That's very humble of you to do that. Thanks for reducing the complexity of multiple solutions :smiley:
Sorry to resurrect this closed issue... but gajus's implementation supports negative indices (slice(str, 0, -10)
,like string slice) but I think this version does not. Am I missing something? Should we add it to chalk/slice-ansi?
Haven't gotten that feature request asked yet, not sure what the use cases would be. Feel free to do a PR if you'd like!
My use case is essentially like sindresorhus/cli-truncate but trimming from the left. At the moment I'm using https://github.com/lahmatiy/fixed-width-string .
What is the reason for not contributing to the existing codebase?
https://github.com/gajus/ansi-slice
esp. given that this was written just a few days after
ansi-slice
.