Skip to content

Commit b23e98c

Browse files
usergenicryanve
authored andcommitted
Coerce the convert functions to strings as the convert value. (#11)
Awesome!
1 parent 1073f8a commit b23e98c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

eol.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@
1717
}
1818

1919
function converts(to) {
20-
return function(text) {
20+
function convert(text) {
2121
return text.replace(newline, to)
2222
}
23+
convert.toString = function() {
24+
return to
25+
}
26+
return convert
2327
}
2428

2529
function split(text) {

test.js

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
aok('split cr', eol.split('0\r1\r2').join('') === '012')
2929
aok('split crlf', eol.split('0\r\n1\r\n2').join('') === '012')
3030
aok('split mixed', eol.split('0\r\n1\n2\r3\r\n4').join('') === '01234')
31+
aok('lf function coerces to string', String(eol.lf) === '\n')
32+
aok('crlf function coerces to string', String(eol.crlf) === '\r\n')
33+
aok('cr function coerces to string', String(eol.cr) === '\r')
34+
aok('auto function coerces to string', String(eol.auto) === isWindows ? '\r\n' : '\n')
3135

3236
aok.pass(meths, function(method, i) {
3337
var normalized = eol[method](sample)

0 commit comments

Comments
 (0)