index.test-d.ts 671 B

12345678910111213141516171819202122232425262728293031
  1. import { file, withFile, dir, withDir, tmpName } from ".";
  2. async function fileExample() {
  3. const { path, fd, cleanup } = await file({ discardDescriptor: true });
  4. await cleanup();
  5. await withFile(
  6. async ({ path, fd, cleanup }) => {
  7. console.log(fd);
  8. await cleanup();
  9. },
  10. { discardDescriptor: true }
  11. );
  12. }
  13. async function dirExample() {
  14. const { path, cleanup } = await dir({ unsafeCleanup: true });
  15. await cleanup();
  16. await withDir(
  17. async ({ path, cleanup }) => {
  18. console.log(path);
  19. await cleanup();
  20. },
  21. { unsafeCleanup: true }
  22. );
  23. }
  24. async function tmpNameExample() {
  25. const name = await tmpName({ tries: 3 });
  26. }