Skip to content

[Replacement]: has-ansi #643

@hyperz111

Description

@hyperz111

Package to replace

has-ansi

Suggested replacement(s)

From chalk/strip-ansi#54

const hasAnsi = (string) => string.includes("\u001B") || string.includes("\u009B");

Manifest type

micro-utility (tiny utility replaceable with native code or removal)

Rationale

  • This package using regex, which is slower for a non-ANSI string.
  • New code only using .includes(INTRODUCER), which is very small and should be inlined.

Availability

All modern enviroments that supports String.prototype.includes.

Code example (optional)

// import hasAnsi from "has-ansi";

const hasAnsi = (string) => string.includes("\u001B") || string.includes("\u009B");

console.log(hasAnsi("foo")); // false
console.log(hasAnsi("\x1b[31mfoo\x1b[39m")); // true

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedUsed to signal if a suggested replacement has been accepted.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions