Path.unlink() method
pathlib-ts > Path > unlink
Path.unlink() method
Section titled “Path.unlink() method”Remove this file or link. Use Path.rmdir() for directories.
Signature:
unlink(options?: { missingOk?: boolean; }): Promise<void>;Parameters
Section titled “Parameters”|
Parameter |
Type |
Description |
|---|---|---|
|
options |
{ missingOk?: boolean; } |
(Optional) Deletion behaviour flags ( |
Returns:
Promise<void>
Promise that settles once the file is removed.
Remarks
Section titled “Remarks”Matches CPython behavior for missingOk, mapping ENOENT to the expected silent outcome.
Example
Section titled “Example”Removing stale cache asynchronously
import { Path } from "pathlib-ts";
const cache = new Path("./.cache/state.json");await cache.unlink({ missingOk: true });