Skip to content

Comments

Add an option to disable escape code stripping#12

Closed
joepie91 wants to merge 1 commit intosindresorhus:mainfrom
joepie91:patch/optional-ansi-stripping
Closed

Add an option to disable escape code stripping#12
joepie91 wants to merge 1 commit intosindresorhus:mainfrom
joepie91:patch/optional-ansi-stripping

Conversation

@joepie91
Copy link

@joepie91 joepie91 commented Nov 3, 2020

Fixes #11.

index.js Outdated
const charRegex = require('char-regex');

const stringLength = string => {
const stringLength = (string, options = {}) => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const stringLength = (string, options = {}) => {
const stringLength = (string, {ignoreAnsiEscapeCodes = false} = {}) => {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be something like countAnsiEscapeCodes = true?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point, not sure why I went with a negative phrasing. Will change.

```

You should only ignore escape codes when working with terminal-related strings; otherwise, you should disable `ignoreEscapeCodes` (which defaults to `true`). This default will change in a future breaking release.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Base automatically changed from master to main January 23, 2021 19:02
@sindresorhus
Copy link
Owner

@joepie91 Bump

@joepie91
Copy link
Author

joepie91 commented Mar 7, 2021

Oops, sorry, this totally escaped me! Apparently GMail's Snooze feature is not to be trusted... I'll have a look at this tomorrow.

@joepie91 joepie91 force-pushed the patch/optional-ansi-stripping branch from efb1fb4 to bf76310 Compare March 8, 2021 15:41
@joepie91
Copy link
Author

joepie91 commented Mar 8, 2021

All issues should be resolved now :)

Copy link
Contributor

@Richienb Richienb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TypeScript definition and type tests need to be updated

@joepie91
Copy link
Author

joepie91 commented Mar 8, 2021

The TypeScript definition and type tests need to be updated

I have no idea how to test that.

@sindresorhus
Copy link
Owner

Friendly bump :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ANSI code stripping should be optional

3 participants