Created
March 26, 2010 15:40
-
-
Save ecounysis/345022 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#light | |
open System.Text.RegularExpressions | |
let minify js = | |
let replace (m:string) (r:string) (s:string) = Regex.Replace(s, m, r) | |
js | |
|> replace "\n\f" " " | |
|> replace "\n" " " | |
|> replace "\s{2,}" " " | |
|> replace "\{ " "{" | |
|> replace "\ }" "}" | |
|> replace "\) " ")" | |
|> replace " \(" "(" | |
|> replace " = " "=" | |
|> replace " \+ " "+" | |
|> replace " - " "-" | |
|> replace " \* " "*" | |
|> replace " / " "/" | |
|> replace ", " "," | |
open System.IO | |
let openFile (file:string) = | |
let sw = new StreamReader(file) | |
let it = sw.ReadToEnd() | |
sw.Close() | |
it | |
let writeFile (file:string) (the_string:string) = | |
let sw = new StreamWriter(file) | |
sw.Write(the_string) | |
sw.Close() | |
() | |
[] | |
let main args = | |
openFile args.[0] | |
|> minify | |
|> writeFile args.[1] | |
0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment