chalk / slice-ansi

Slice a string with ANSI escape codes
MIT License
47 stars 21 forks source link

Merge efforts #2

Closed gajus closed 8 years ago

gajus commented 8 years ago

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.

dthree commented 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.

gajus commented 8 years ago

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.

gajus commented 8 years ago

https://github.com/gajus/ansi-slice#deprecated

NPM package has been deprecated too.

dthree commented 8 years ago

:+1:

That's very humble of you to do that. Thanks for reducing the complexity of multiple solutions :smiley:

https://xkcd.com/927/

Hypercubed commented 8 years ago

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?

dthree commented 8 years ago

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!

Hypercubed commented 8 years ago

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 .