Comparing version 0.1.0 to 0.2.0
12
eol.js
/*! | ||
* eol 0.1.0+201403121730 | ||
* eol 0.2.0+201403200220 | ||
* https://github.com/ryanve/eol | ||
* MIT License (c) 2014 Ryan Van Etten | ||
* MIT License, 2014 Ryan Van Etten | ||
*/ | ||
(function(root, name, make) { | ||
!function(root, name, make) { | ||
if (typeof module != 'undefined' && module.exports) module.exports = make(); | ||
@@ -20,3 +19,6 @@ else root[name] = make(); | ||
api['crlf'] = converts('\r\n'); | ||
api['auto'] = converts( | ||
typeof process != 'undefined' && 'win32' === process.platform ? '\r\n' : '\n' | ||
); | ||
return api; | ||
})); | ||
}); |
/*! | ||
* eol 0.1.0+201403121730 | ||
* eol 0.2.0+201403200220 | ||
* https://github.com/ryanve/eol | ||
* MIT License (c) 2014 Ryan Van Etten | ||
* MIT License, 2014 Ryan Van Etten | ||
*/ | ||
!function(a,b,c){"undefined"!=typeof module&&module.exports?module.exports=c():a[b]=c()}(this,"eol",function(){function a(a){return function(b){return b.replace(c,a)}}var b={},c=/\r\n|\r|\n/g;return b.lf=a("\n"),b.cr=a("\r"),b.crlf=a("\r\n"),b}); | ||
!function(a,b,c){"undefined"!=typeof module&&module.exports?module.exports=c():a[b]=c()}(this,"eol",function(){function a(a){return function(b){return b.replace(c,a)}}var b={},c=/\r\n|\r|\n/g;return b.lf=a("\n"),b.cr=a("\r"),b.crlf=a("\r\n"),b.auto=a("undefined"!=typeof process&&"win32"===process.platform?"\r\n":"\n"),b}); |
{ | ||
"name": "eol", | ||
"description": "Newline character converter", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"homepage": "https://github.com/ryanve/eol", | ||
@@ -16,8 +16,30 @@ "license": "MIT", | ||
"aok": "~1.8.1", | ||
"universal": "~0.0.2", | ||
"grunt": "~0.4.2", | ||
"universal": "~0.0.5", | ||
"grunt": "~0.4.4", | ||
"grunt-contrib-uglify": "~0.3.0", | ||
"grunt-contrib-concat": "~0.3.0", | ||
"grunt-contrib-jshint": "~0.8.0" | ||
}, | ||
"jshintConfig": { | ||
"boss": true, | ||
"browser": true, | ||
"debug": true, | ||
"devel": true, | ||
"eqnull": true, | ||
"evil": true, | ||
"expr": true, | ||
"globals": { | ||
"define": true, | ||
"ender": true | ||
}, | ||
"jquery": true, | ||
"latedef": "nofunc", | ||
"laxcomma": true, | ||
"maxerr": 10, | ||
"node": true, | ||
"sub": true, | ||
"supernew": true, | ||
"undef": true, | ||
"unused": true | ||
} | ||
} |
@@ -6,13 +6,17 @@ # eol | ||
### `eol.auto(text)` | ||
- Normalize line endings in <var>text</var> for the current operating system | ||
- <b>@return</b> string with line endings normalized to `\r\n` or `\n` | ||
### `eol.crlf(text)` | ||
- Normalize <var>text</var> to <b>CRLF</b> (Windows, DOS) line endings | ||
- <b>@return</b> string | ||
- Normalize line endings in <var>text</var> to <b>CRLF</b> (Windows, DOS) | ||
- <b>@return</b> string with line endings normalized to `\r\n` | ||
### `eol.lf(text)` | ||
- Normalize <var>text</var> to <b>LF</b> (Unix, OS X) line endings | ||
- <b>@return</b> string | ||
- Normalize line endings in <var>text</var> to <b>LF</b> (Unix, OS X) | ||
- <b>@return</b> string with line endings normalized to `\n` | ||
### `eol.cr(text)` | ||
- Normalize <var>text</var> to <b>CR</b> (Mac OS) line endings | ||
- <b>@return</b> string | ||
- Normalize line endings in <var>text</var> to <b>CR</b> (Mac OS) | ||
- <b>@return</b> string with line endings normalized to `\r` | ||
@@ -19,0 +23,0 @@ ## License |
@@ -1,2 +0,2 @@ | ||
(function(root, name, make) { | ||
!function(root, name, make) { | ||
if (typeof module != 'undefined' && module.exports) module.exports = make(); | ||
@@ -14,3 +14,6 @@ else root[name] = make(); | ||
api['crlf'] = converts('\r\n'); | ||
api['auto'] = converts( | ||
typeof process != 'undefined' && 'win32' === process.platform ? '\r\n' : '\n' | ||
); | ||
return api; | ||
})); | ||
}); |
(function(root) { | ||
function contains(str, needle) { | ||
return !!~str.indexOf(needle); | ||
} | ||
var common = typeof module != 'undefined' && !!module.exports; | ||
var aok = common ? require('aok') : root.aok; | ||
var eol = common ? require('../src') : root.eol; | ||
var platform = typeof process != 'undefined' && process.platform; | ||
var meths = ['lf', 'cr', 'crlf', 'auto']; | ||
var chars = ['\n', '\r', '\r\n', 'win32' === platform ? '\r\n' : '\n']; | ||
var sample = ' ' + chars.join() + 'text' + chars.join(); | ||
function contains(str, needle, guard) { | ||
if (guard) needle = str, str = this; | ||
return !!~str.indexOf(needle); | ||
} | ||
aok.fail(meths, function(method, i) { | ||
if (!contains('ab', 'a')) return void aok.warn('contains() does not return expected result.'); | ||
if (!contains(sample, chars[i])) return void aok.warn('Sample lacks the needed characters.'); | ||
return true; | ||
}, aok, 1); | ||
aok.pass(['lf', 'cr', 'crlf'], function(method, i) { | ||
var sample = ' ' + this.join() + 'text' + this.join(), normal = eol[method](sample); | ||
aok(method + ' retains', contains(normal, this[i])); | ||
aok(method + ' normalizes', ('crlf' === method ? 0 : 2) === aok.fail(this, contains, normal)); | ||
}, ['\n', '\r', '\r\n']); | ||
aok.pass(meths, function(method, i) { | ||
var normalized = eol[method](sample); | ||
aok(method + ' retains', contains(normalized, chars[i])); | ||
aok(method + ' normalizes', !aok.fail(chars, function(c) { | ||
return contains(chars[i], c) === contains(normalized, c); | ||
})); | ||
return eol.auto(sample) === normalized; | ||
}); | ||
aok('auto agress', 2 === aok.pass(meths, function(method) { | ||
return eol.auto(sample) === eol[method](sample); | ||
})); | ||
}(this)); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5998
72
24