Skip to content

Instantly share code, notes, and snippets.

@vbfox
Created November 20, 2017 20:47
Show Gist options
  • Save vbfox/98038b8bc0b34358cda3e6d0a33bbb91 to your computer and use it in GitHub Desktop.
Save vbfox/98038b8bc0b34358cda3e6d0a33bbb91 to your computer and use it in GitHub Desktop.
Fable async node IO
module AsyncIO
let private readdir (dir: string): Promise<ResizeArray<string>> =
Promise.Create(fun resolve fail ->
Fs.readdir(U2.Case1 dir, fun err files ->
if isDefined err then fail.Invoke(err) else resolve.Invoke(U2.Case1 files)))
let private unlink (path: string): Promise<unit> =
Promise.Create(fun resolve fail ->
Fs.unlink(U2.Case1 path, fun err ->
if isDefined err then fail.Invoke(err) else resolve.Invoke(U2.Case1 ())))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment