Skip to content

Path.touch() method

pathlib-ts > Path > touch

Create the file or update its timestamps with optional mode overrides.

Signature:

touch(options?: {
mode?: number;
existOk?: boolean;
}): Promise<void>;

Parameter

Type

Description

options

{ mode?: number; existOk?: boolean; }

(Optional) File creation behaviour flags (mode, existOk).

Returns:

Promise<void>

Promise that settles once the touch operation completes.

Implements CPython semantics where existOk controls whether existing files are tolerated.

Priming cache files asynchronously

import { Path } from "pathlib-ts";
const cache = new Path("./.cache/state.json");
await cache.touch({ existOk: true });