-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ae7bae7
Showing
9 changed files
with
243 additions
and
0 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,15 @@ | ||
lib-cov | ||
*.seed | ||
*.log | ||
*.csv | ||
*.dat | ||
*.out | ||
*.pid | ||
*.gz | ||
|
||
pids | ||
logs | ||
results | ||
|
||
node_modules | ||
npm-debug.log |
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,41 @@ | ||
# Ascii Art Reverse | ||
|
||
This is package is essentially a rainbow being | ||
farted from the aft portion of a unicorn. It's pure magic. | ||
|
||
# Install | ||
|
||
`npm install ascii-art-reverse` | ||
|
||
# Usage | ||
|
||
```javascript | ||
var reverse = require('ascii-art-reverse'); | ||
|
||
var art = | ||
" ("-^-/") " + | ||
" `o__o' ] " + | ||
" (_Y_) _/ " + | ||
" _..`--'-.`, " + | ||
" (__)_,--(__) " + | ||
" 7: ; 1 " + | ||
" _/,`-.-' : " + | ||
" (_,)-~~(_,) "; | ||
|
||
console.log(reverse(art)); | ||
``` | ||
|
||
### Output: | ||
|
||
``` | ||
("\-^-") | ||
[ 'o__o` | ||
\_ (_Y_) | ||
,`.-'--`.._ | ||
(__)--,_(__) | ||
1 ; :7 | ||
: '-.-`,\_ | ||
(,_)~~-(,_) | ||
``` | ||
|
||
Like I said, __MAGIC__. |
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,64 @@ | ||
"use strict"; | ||
|
||
var fs = require('fs'); | ||
|
||
// map of characters with opposites | ||
var opposites = { | ||
"b": "d", | ||
"d": "b", | ||
"z": "s", | ||
"(": ")", | ||
")": "(", | ||
"[": "]", | ||
"]": "[", | ||
"{": "}", | ||
"}": "{", | ||
"<": ">", | ||
">": "<", | ||
"/": "\\", | ||
"\\": "/" | ||
}; | ||
|
||
// Read a file, and return the reveresed and original | ||
function reverseArtFile(file, cb) { | ||
fs.readFile(file, function(err, data) { | ||
if (err) return cb(err); | ||
var orig = data.toString(); | ||
var art = reverseArt(orig); | ||
cb(null, art, orig); | ||
}); | ||
} | ||
|
||
// Reverse a string of ascii art | ||
function reverseArt(art) { | ||
art = art.replace('\r\n', '\n') | ||
.split('\n'); | ||
|
||
var maxLineLen = art.reduce(function(max, line) { | ||
return Math.max(line.length, max); | ||
}, 0); | ||
|
||
var art = art.map(function(line) { | ||
var pad = (new Array(1 + maxLineLen - line.length)).join(' '); | ||
line = reverseLine(line + pad); | ||
return line.replace(/\s\+$/, ''); | ||
}).join('\n'); | ||
|
||
return art; | ||
} | ||
|
||
// Reverse a line of ascii art | ||
function reverseLine(art) { | ||
var rev = ''; | ||
for (var i = art.length - 1; i >= 0; --i) { | ||
if (opposites.hasOwnProperty(art[i])) { | ||
rev += opposites[art[i]]; | ||
} else { | ||
rev += art[i]; | ||
} | ||
} | ||
return rev; | ||
} | ||
|
||
module.exports = reverseArt; | ||
reverseArt.reverseArtFile = reverseArtFile; |
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,11 @@ | ||
var fs = require('fs') | ||
, reverse = require('./index'); | ||
|
||
['eagle', 't-rex', 'pig', 'wolf', 'bear'].forEach(function(name) { | ||
var file = './tests/' + name + '.txt'; | ||
reverse.reverseArtFile(file, function(err, art, orig) { | ||
if (err) throw err; | ||
console.log(orig); | ||
console.log(art); | ||
}); | ||
}); |
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,8 @@ | ||
("-^-/") | ||
`o__o' ] | ||
(_Y_) _/ | ||
_..`--'-.`, | ||
(__)_,--(__) | ||
7: ; 1 | ||
_/,`-.-' : | ||
(_,)-~~(_,) |
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,32 @@ | ||
/T /I | ||
/ |/ | .-~/ | ||
T\ Y I |/ / _ | ||
/T | \I | I Y.-~/ | ||
I l /I T\ | | l | T / | ||
T\ | \ Y l /T | \I l \ ` l Y | ||
__ | \l \l \I l __l l \ ` _. | | ||
\ ~-l `\ `\ \ \ ~\ \ `. .-~ | | ||
\ ~-. "-. ` \ ^._ ^. "-. / \ | | ||
.--~-._ ~- ` _ ~-_.-"-." ._ /._ ." ./ | ||
>--. ~-. ._ ~>-" "\ 7 7 ] | ||
^.___~"--._ ~-{ .-~ . `\ Y . / | | ||
<__ ~"-. ~ /_/ \ \I Y : | | ||
^-.__ ~(_/ \ >._: | l______ | ||
^--.,___.-~" /_/ ! `-.~"--l_ / ~"-. | ||
(_/ . ~( /' "~"--,Y -=b-. _) | ||
(_/ . \ : / l c"~o \ | ||
\ / `. . .^ \_.-~"~--. ) | ||
(_/ . ` / / ! )/ | ||
/ / _. '. .': / ' | ||
~(_/ . / _ ` .-<_ | ||
/_/ . ' .-~" `. / \ \ ,z=. | ||
~( / ' : | K "-.~-.______// | ||
"-,. l I/ \_ __{----._(==. | ||
//( \ < ~"~" // | ||
/' /\ \ \ ,v=. (( | ||
.^. / /\ " }__ //===- ` | ||
/ / ' ' "-.,__ {---(==- | ||
.^ ' : T ~" ll -Row | ||
/ . . . : | :! \ | ||
(_/ / | | j-" ~^ | ||
~-<_(_.^-~" |
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,17 @@ | ||
_,--. ,--._ | ||
\ > `-"""-' < / | ||
`-. .-' | ||
/ 'e___e` \ | ||
( (o o) ) | ||
_\_ `=' _/_ | ||
/ /|`-._.-'|\ \ | ||
/ /||_______||\ \ | ||
_/ /_||=======||_\ \_ | ||
/ _/==|| ||==\_ \ | ||
`'( ^^ ^^ )`' | ||
\ / | ||
\______|______/ hjw | ||
|______|______| | ||
)__| |__( | ||
/ ] [ \ | ||
`--' `--' |
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,29 @@ | ||
.-=-==--==--. | ||
..-==" ,'o`) `. | ||
,' `"' \ | ||
: ( `.__...._ | ||
| ) / `-=-. | ||
: ,vv.-._ / / `---==-._ | ||
\/\/\/VV ^ d88`;' / `. | ||
`` ^/d88P!' / , `._ | ||
^/ !' ,. , / "-,,__,,--'""""-. | ||
^/ !' ,' \ . .( ( _ ) ) ) ) ))_,-.\ | ||
^(__ ,!',"' ;:+.:%:a. \:.. . ,' ) ) ) ) ,"' ' | ||
',,,'',' /o:::":%:%a. \:.:.: . ) ) _,' | ||
"""' ;':::'' `+%%%a._ \%:%| ;.). _,-"" | ||
,-='_.-' ``:%::) )%:| /:._," | ||
(/(/" ," ,'_,'%%%: (_,' | ||
( (//(`.___; \ | ||
\ \ ` ` | ||
`. `. `. : | ||
\. . .\ : . . . : | ||
\. . .: `.. . .: | ||
`..:.:\ \:...\ | ||
;:.:.; ::...: | ||
):%:: :::::; | ||
__,::%:( ::::: | ||
,;:%%%%%%%: ;:%:: | ||
;,--""-.`\ ,=--':%:%:\ | ||
/" "| /-".:%%%%%%%\ | ||
;,-"'`)%%) (CJ) | ||
/" "| |
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,26 @@ | ||
__ | ||
.d$$b | ||
.' TO$;\ | ||
/ : TP._; | ||
/ _.; :Tb| | ||
/ / ;j$j | ||
_.-" d$$$$ | ||
.' .. d$$$$; | ||
/ /P' d$$$$P. |\ | ||
/ " .d$$$P' |\^"l | ||
.' `T$P^""""" : | ||
._.' _.' ; | ||
`-.-".-'-' ._. _.-" .-" | ||
`.-" _____ ._ .-" | ||
-(.g$$$$$$$b. .' | ||
""^^T$$$P^) .(: | ||
_/ -" /.' /:/; | ||
._.'-'`-' ")/ /;/; | ||
`-.-"..--"" " / / ; | ||
.-" ..--"" -' : | ||
..--""--.-" (\ .-(\ | ||
..--"" `-\(\/;` | ||
_. : | ||
;`- | ||
:\ | ||
; bug |