|
1 |
| -const fs = require("fs"); |
2 |
| -const os = require("os"); |
3 |
| -const path = require("path"); |
4 |
| -const process = require("process"); |
| 1 | +import { mkdtempSync } from "fs"; |
| 2 | +import { tmpdir } from "os"; |
| 3 | +import { join } from "path"; |
| 4 | +import { hrtime } from "process"; |
5 | 5 |
|
6 |
| -exports.tmpdir = (prefix) => () => |
7 |
| - fs.mkdtempSync(path.join(os.tmpdir(), prefix), "utf-8"); |
8 |
| - |
9 |
| -exports.hrtime = () => { |
10 |
| - const t = process.hrtime() |
11 |
| - return { seconds: t[0], nanos: t[1] }; |
| 6 | +const tmpdirImpl = function (prefix) { |
| 7 | + return () => mkdtempSync(join(tmpdir(), prefix), "utf-8"); |
12 | 8 | };
|
| 9 | +export { tmpdirImpl as tmpdir }; |
13 | 10 |
|
14 |
| -exports.hrtimeDiff = (old) => () => { |
15 |
| - const t = process.hrtime([old.seconds, old.nanos]); |
| 11 | +const hrtimeImpl = function () { |
| 12 | + const t = hrtime(); |
16 | 13 | return { seconds: t[0], nanos: t[1] };
|
17 | 14 | };
|
| 15 | +export { hrtimeImpl as hrtime }; |
| 16 | + |
| 17 | +export function hrtimeDiff(old) { |
| 18 | + return () => { |
| 19 | + const t = hrtime([old.seconds, old.nanos]); |
| 20 | + return { seconds: t[0], nanos: t[1] }; |
| 21 | + }; |
| 22 | +} |
0 commit comments