readTextAsync

Read file path with asynchronous IO and return data read as a promise of string(validate with std.utf.validate)

If an error occurred, the promise will be rejected.

nothrow
readTextAsync
(
S = string
)
(
string path
)
if (
isSomeString!S
)

Parameters

path string

string representing file path.

Return Value

Type: Promise!S

A promise of string read.

Examples

import std.file : write, remove;
import dpromise.utils : runEventloop;

write("hoge.txt", "hogehogepiyopiyo");
scope(exit) remove("hoge.txt");

readTextAsync("hoge.txt").then(
  (s) {
    assert(s == "hogehogepiyopiyo");
  }
);

runEventloop();

See Also

Meta