2 people like it.
Like the snippet!
LiveScript to JavaScript Converter
http://gkz.github.com/LiveScript/
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
|
open System
open System.IO
open System.Diagnostics
module LiveScript =
let toJs (source : string) =
let processInfo =
new ProcessStartInfo
("cmd", "/C livescript -c -s -b",
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardInput = true,
RedirectStandardOutput = true)
let proc = Process.Start(processInfo)
let streamWriter = proc.StandardInput
streamWriter.Write(source)
streamWriter.Close()
proc.WaitForExit()
let output = proc.StandardOutput;
let result = output.ReadToEnd()
output.Close()
proc.Close() |> ignore
result
@"[1, 2, 3] |> map (*2)" |> LiveScript.toJs
|
namespace System
namespace System.IO
namespace System.Diagnostics
val toJs : source:string -> string
Full name: Script.LiveScript.toJs
val source : string
Multiple items
val string : value:'T -> string
Full name: Microsoft.FSharp.Core.Operators.string
--------------------
type string = String
Full name: Microsoft.FSharp.Core.string
val processInfo : ProcessStartInfo
Multiple items
type ProcessStartInfo =
new : unit -> ProcessStartInfo + 2 overloads
member Arguments : string with get, set
member CreateNoWindow : bool with get, set
member Domain : string with get, set
member EnvironmentVariables : StringDictionary
member ErrorDialog : bool with get, set
member ErrorDialogParentHandle : nativeint with get, set
member FileName : string with get, set
member LoadUserProfile : bool with get, set
member Password : SecureString with get, set
...
Full name: System.Diagnostics.ProcessStartInfo
--------------------
ProcessStartInfo() : unit
ProcessStartInfo(fileName: string) : unit
ProcessStartInfo(fileName: string, arguments: string) : unit
val proc : Process
Multiple items
type Process =
inherit Component
new : unit -> Process
member BasePriority : int
member BeginErrorReadLine : unit -> unit
member BeginOutputReadLine : unit -> unit
member CancelErrorRead : unit -> unit
member CancelOutputRead : unit -> unit
member Close : unit -> unit
member CloseMainWindow : unit -> bool
member EnableRaisingEvents : bool with get, set
member ExitCode : int
...
Full name: System.Diagnostics.Process
--------------------
Process() : unit
Process.Start(startInfo: ProcessStartInfo) : Process
Process.Start(fileName: string) : Process
Process.Start(fileName: string, arguments: string) : Process
Process.Start(fileName: string, userName: string, password: Security.SecureString, domain: string) : Process
Process.Start(fileName: string, arguments: string, userName: string, password: Security.SecureString, domain: string) : Process
val streamWriter : StreamWriter
property Process.StandardInput: StreamWriter
TextWriter.Write(value: obj) : unit
(+0 other overloads)
TextWriter.Write(value: decimal) : unit
(+0 other overloads)
TextWriter.Write(value: float) : unit
(+0 other overloads)
TextWriter.Write(value: float32) : unit
(+0 other overloads)
TextWriter.Write(value: uint64) : unit
(+0 other overloads)
TextWriter.Write(value: int64) : unit
(+0 other overloads)
TextWriter.Write(value: uint32) : unit
(+0 other overloads)
TextWriter.Write(value: int) : unit
(+0 other overloads)
TextWriter.Write(value: bool) : unit
(+0 other overloads)
StreamWriter.Write(value: string) : unit
(+0 other overloads)
StreamWriter.Close() : unit
Process.WaitForExit() : unit
Process.WaitForExit(milliseconds: int) : bool
val output : StreamReader
property Process.StandardOutput: StreamReader
val result : string
StreamReader.ReadToEnd() : string
StreamReader.Close() : unit
Process.Close() : unit
val ignore : value:'T -> unit
Full name: Microsoft.FSharp.Core.Operators.ignore
module LiveScript
from Script
More information