Path.replace() method
pathlib-ts > Path > replace
Path.replace() method
Section titled “Path.replace() method”Replace the target path, overwriting it if necessary, and return the new Path.
Signature:
replace(target: PathLike): Promise<Path>;Parameters
Section titled “Parameters”|
Parameter |
Type |
Description |
|---|---|---|
|
target |
Destination path or string. |
Returns:
Promise<Path>
Promise resolving to a Path representing the destination.
Remarks
Section titled “Remarks”Overwrite behavior matches CPython while relying on Node’s rename.
Example
Section titled “Example”Replacing assets atomically asynchronously
import { Path } from "pathlib-ts";
const staged = new Path("./public/app.css.stage");await staged.replace("./public/app.css");