-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from ryanve/next
0.3.0 release
- Loading branch information
Showing
12 changed files
with
137 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 2 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
MIT License | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,22 @@ | ||
/*! | ||
* eol 0.2.0+201403200220 | ||
* https://github.com/ryanve/eol | ||
* MIT License, 2014 Ryan Van Etten | ||
*/ | ||
!function(root, name, make) { | ||
if (typeof module != 'undefined' && module.exports) module.exports = make(); | ||
else root[name] = make(); | ||
if (typeof module != 'undefined' && module.exports) module.exports = make() | ||
else root[name] = make() | ||
}(this, 'eol', function() { | ||
|
||
var api = {} | ||
var isWindows = typeof process != 'undefined' && 'win32' === process.platform | ||
var newline = /\r\n|\r|\n/g | ||
|
||
function converts(to) { | ||
return function(text) { | ||
return text.replace(newline, to); | ||
}; | ||
return text.replace(newline, to) | ||
} | ||
} | ||
var api = {}, newline = /\r\n|\r|\n/g; | ||
api['lf'] = converts('\n'); | ||
api['cr'] = converts('\r'); | ||
api['crlf'] = converts('\r\n'); | ||
api['auto'] = converts( | ||
typeof process != 'undefined' && 'win32' === process.platform ? '\r\n' : '\n' | ||
); | ||
return api; | ||
}); | ||
|
||
api['lf'] = converts('\n') | ||
api['cr'] = converts('\r') | ||
api['crlf'] = converts('\r\n') | ||
api['auto'] = converts(isWindows ? '\r\n' : '\n') | ||
|
||
return api | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,53 @@ | ||
{ | ||
"name": "eol", | ||
"description": "Newline character converter", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"homepage": "https://github.com/ryanve/eol", | ||
"license": "MIT", | ||
"author": "Ryan Van Etten", | ||
"keywords": ["eol", "newline", "convert", "converter", "conversion", "character", "ender"], | ||
"main": "./eol.js", | ||
"keywords": [ | ||
"eol", | ||
"newline", | ||
"newlines", | ||
"convert", | ||
"converter", | ||
"conversion", | ||
"character", | ||
"formatting", | ||
"format", | ||
"string", | ||
"file", | ||
"ender" | ||
], | ||
"main": "eol.js", | ||
"scripts": { | ||
"pretest": "jshint eol.js && jshint test.js", | ||
"test": "node test.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/ryanve/eol.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/ryanve/eol/issues" | ||
}, | ||
"devDependencies": { | ||
"aok": "~1.8.1", | ||
"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" | ||
"aok": "^1.9.0", | ||
"jshint": "^2.9.3" | ||
}, | ||
"jshintConfig": { | ||
"asi": true, | ||
"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, | ||
"maxerr": 5, | ||
"node": true, | ||
"sub": true, | ||
"supernew": true, | ||
"undef": true, | ||
"unused": true | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-US"> | ||
<title>Tests</title> | ||
<style> | ||
html { font: 1em/1.6 sans-serif; background: ghostwhite; color: #333 } | ||
body { width: 94%; margin: auto } | ||
</style> | ||
|
||
<h1>Tests</h1> | ||
<p>Open the console to view test results | ||
|
||
<script src="eol.js"></script> | ||
<script src="node_modules/aok/aok.js"></script> | ||
<script src="test.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
!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('./') : root.eol | ||
var isWindows = typeof process != 'undefined' && 'win32' === process.platform | ||
var meths = ['lf', 'cr', 'crlf', 'auto'] | ||
var chars = ['\n', '\r', '\r\n', isWindows ? '\r\n' : '\n'] | ||
var sample = ' ' + chars.join() + 'text' + chars.join() | ||
|
||
aok.prototype.fail = function() { | ||
throw new Error('FAILED TEST: ' + this.id) | ||
} | ||
|
||
aok('contains sees contained text', contains('ab', 'a') === true) | ||
aok('sample contains newlines', contains(sample, '\n') && contains(sample, '\r')) | ||
aok('returns other strings as is', eol.auto('random') === 'random') | ||
aok('returns empty strings as is', eol.auto('') === '') | ||
aok('whitespace intact', eol.lf(' \t ') === ' \t ') | ||
aok('lf repeat newlines intact', eol.lf('\n\n\r\r') === '\n\n\n\n') | ||
aok('cr repeat newlines intact', eol.cr('\n\n\r\r') === '\r\r\r\r') | ||
aok('crlf repeat newlines intact', eol.crlf('\r\n\r\n') === '\r\n\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 is aware', eol[isWindows ? 'crlf' : 'lf'](sample) === eol.auto(sample)) | ||
aok('auto matches only 1 and self', aok.pass(meths, function(method) { | ||
return eol.auto(sample) === eol[method](sample); | ||
}) === 2) | ||
|
||
aok.log('All tests passed =)') | ||
}(this); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.