Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spaces not outputting as expected. #26

Open
geozak opened this issue Sep 30, 2017 · 3 comments
Open

Spaces not outputting as expected. #26

geozak opened this issue Sep 30, 2017 · 3 comments

Comments

@geozak
Copy link

geozak commented Sep 30, 2017

I ran this code in NodeJS console using npm version "^1.2.3"

var wrap = require('word-wrap');
var test = '1234 12345678';
var arguments = {width: 10, indent: ' ', newline: ' \n'};
var result = wrap(test, arguments);
result

In the following I will use '-' to represent a space.

I expected result to output -1234-\n-12345678 however the output of result was -1234--\n12345678.

Can someone explain why result has more and less spaces than I expected or confirm that this is a bug.

Thanks.

@jonschlinkert
Copy link
Owner

jonschlinkert commented Oct 1, 2017

you're defining the newline with a leading space, it seems like the output is correct, since -\n would be appended to 1234- (also using - to represent a space)

@geozak
Copy link
Author

geozak commented Oct 4, 2017

Ah, so the space is considered part of the preceding string.

What about the lack of leading indent for the second line?

@geozak
Copy link
Author

geozak commented Oct 4, 2017

In index.js line 19 var newline = options.newline || '\n' + indent; when options.newline is used the indent is not appended.

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

No branches or pull requests

2 participants