typescript-string-operations icon indicating copy to clipboard operation
typescript-string-operations copied to clipboard

Line separator should be considered to use os.EOL when AppendLine

Open NewGyu opened this issue 4 years ago • 2 comments

Current implementation is the following.

    public AppendLine(value: string) {
        this.Values.push('\r\n' + value);
    }

On Windows, the line separator \r\n is correct, but it is not correct separator on Linux/Mac. Could you consider to use os.EOL?

https://nodejs.org/api/os.html#os_os_eol

NewGyu avatar Dec 31 '20 05:12 NewGyu

Mhm, I think this wouldn`t work for browser enviroments.

Maybe something like this would match your requirement, but work in both environments? https://github.com/p2227/universal-eol/blob/master/eol.js?

aequi42 avatar Jan 25 '21 19:01 aequi42

Sorry for lack of information about my usecase. I used this npm for command line tool which is run on node.js. I didn't thik about the case running on Browser. I'm not familiar with Browser JS, but I explore some library implementation. The following implementation seems similar to the example you've mentioned. Thank you.

https://github.com/ryanve/eol/blob/e89fda4a2480d03cddd5274f787313f15c6cb73c/eol.js#L7

NewGyu avatar Jan 26 '21 08:01 NewGyu