mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
* Change 'export default' to 'export =' For packages that don't actually export a 'default' property. * 7 more packages
55 lines
1.4 KiB
TypeScript
55 lines
1.4 KiB
TypeScript
import * as fs from "fs";
|
|
import temp = require("promised-temp");
|
|
|
|
function testCleanup() {
|
|
temp.cleanup().then((result: boolean | temp.Stats) => {
|
|
if (typeof result === "boolean") {
|
|
const x = result;
|
|
} else {
|
|
const { files, dirs } = result;
|
|
files.toPrecision(4);
|
|
}
|
|
});
|
|
}
|
|
|
|
function testOpen() {
|
|
temp.open({ dir: "tempDir", prefix: "pref", suffix: "suff" }).then((result: temp.OpenFile) => {
|
|
const { path, fd } = result;
|
|
path.length;
|
|
fd.toPrecision(5);
|
|
});
|
|
|
|
temp.open("strPrefix").then((result: temp.OpenFile) => {
|
|
const { path, fd } = result;
|
|
path.length;
|
|
fd.toPrecision(5);
|
|
});
|
|
}
|
|
|
|
function testCreateWriteStream() {
|
|
const stream =
|
|
temp.createWriteStream("HelloStreamAffix")
|
|
.then((stream: fs.WriteStream) => stream.write("data"));
|
|
|
|
const stream2 = temp.createWriteStream();
|
|
}
|
|
|
|
function testMkdir() {
|
|
temp.mkdir("prefix").then((dirPath: string) => {
|
|
dirPath.length;
|
|
});
|
|
}
|
|
|
|
function testPath() {
|
|
const p = temp.path({ suffix: "justSuffix" }, "defaultPrefix");
|
|
p.length;
|
|
const p2: string = temp.path("prefix");
|
|
const p3: string = temp.path({ prefix: "prefix" });
|
|
}
|
|
|
|
function testTrack() {
|
|
const tempChained = temp.track().track(true).track(false);
|
|
tempChained.dir;
|
|
tempChained.cleanup();
|
|
}
|