Skip to content

Commit

Permalink
Coerce the convert functions to strings as the convert value. (#11)
Browse files Browse the repository at this point in the history
Awesome!
  • Loading branch information
usergenic authored and ryanve committed May 1, 2017
1 parent 1073f8a commit b23e98c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion eol.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@
}

function converts(to) {
return function(text) {
function convert(text) {
return text.replace(newline, to)
}
convert.toString = function() {
return to
}
return convert
}

function split(text) {
Expand Down
4 changes: 4 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
aok('split cr', eol.split('0\r1\r2').join('') === '012')
aok('split crlf', eol.split('0\r\n1\r\n2').join('') === '012')
aok('split mixed', eol.split('0\r\n1\n2\r3\r\n4').join('') === '01234')
aok('lf function coerces to string', String(eol.lf) === '\n')
aok('crlf function coerces to string', String(eol.crlf) === '\r\n')
aok('cr function coerces to string', String(eol.cr) === '\r')
aok('auto function coerces to string', String(eol.auto) === isWindows ? '\r\n' : '\n')

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

0 comments on commit b23e98c

Please sign in to comment.