alshdavid / BorrowScript

TypeScript with a Borrow Checker. Multi-threaded, Tiny binaries. No GC. Easy to write.
1.45k stars 16 forks source link

Length() function considers other functions #55

Closed GHNewbiee closed 1 year ago

GHNewbiee commented 2 years ago

Example:

msg = 'This is red text'
text = `{$chalk.red(msg)}`;
console.log(text) // This is red text
text.length === 16 // false
alshdavid commented 2 years ago

Can I get more information on what you mean?

GHNewbiee commented 2 years ago

Yes, sure. Please run the following js code.

import chalk from 'chalk';

const msg = 'This text length should be 30.';
const msgLength = msg.length;
console.log(msg, "\tIndeed, it's:", msgLength);
const text = chalk.red(msg);
const textLength = text.length;
console.log(text, "\tUnfortunately, it is not; it's ", textLength, ". Why?");