@dsherret/path 0.3.3 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @david/path
1
+ # path
2
2
 
3
3
  [![JSR](https://jsr.io/badges/@david/path)](https://jsr.io/@david/path)
4
4
  [![npm](https://img.shields.io/npm/v/@dsherret/path)](https://www.npmjs.com/package/@dsherret/path)
package/esm/mod.d.ts CHANGED
@@ -28,8 +28,10 @@ export interface StreamPipeOptions {
28
28
  /** Signal used to abort the pipe. */
29
29
  signal?: AbortSignal;
30
30
  }
31
+ /** Something that can be converted to a {@linkcode Path}. */
32
+ export type PathLike = string | URL | Path;
31
33
  /** Creates a new {@linkcode Path}. Shorthand for `new Path(...)`. */
32
- export declare function path(path: string | URL | Path): Path;
34
+ export declare function path(path: PathLike): Path;
33
35
  export default path;
34
36
  /** Represents a path on the file system. */
35
37
  export declare class Path {
@@ -42,7 +44,7 @@ export declare class Path {
42
44
  */
43
45
  private static instanceofSymbol;
44
46
  /** Creates a new path from the provided string, URL, or another Path. */
45
- constructor(path: string | URL | Path);
47
+ constructor(path: PathLike);
46
48
  /** @internal */
47
49
  static [Symbol.hasInstance](instance: unknown): boolean;
48
50
  /** Gets the string representation of this path. */
@@ -124,7 +126,7 @@ export declare class Path {
124
126
  /** Gets a new path reference with the provided file or directory name. */
125
127
  withBasename(basename: string): Path;
126
128
  /** Gets the relative path from this path to the specified path. */
127
- relative(to: string | URL | Path): string;
129
+ relative(to: PathLike): string;
128
130
  /** Gets if the path exists. Beware of TOCTOU issues. */
129
131
  exists(): Promise<boolean>;
130
132
  /** Synchronously gets if the path exists. Beware of TOCTOU issues. */
@@ -160,11 +162,11 @@ export declare class Path {
160
162
  /**
161
163
  * Creates a hardlink to the provided target path.
162
164
  */
163
- linkTo(targetPath: string | URL | Path): Promise<void>;
165
+ linkTo(targetPath: PathLike): Promise<void>;
164
166
  /**
165
167
  * Synchronously creates a hardlink to the provided target path.
166
168
  */
167
- linkToSync(targetPath: string | URL | Path): void;
169
+ linkToSync(targetPath: PathLike): void;
168
170
  /** Reads the entries in the directory. */
169
171
  readDir(): AsyncIterable<DirEntry>;
170
172
  /** Synchronously reads the entries in the directory. */
@@ -333,70 +335,70 @@ export declare class Path {
333
335
  /** Copies a file or directory to the provided destination.
334
336
  * @returns The destination path.
335
337
  */
336
- copy(destinationPath: string | URL | Path, options?: {
338
+ copy(destinationPath: PathLike, options?: {
337
339
  overwrite?: boolean;
338
340
  }): Promise<Path>;
339
341
  /** Copies a file or directory to the provided destination synchronously.
340
342
  * @returns The destination path.
341
343
  */
342
- copySync(destinationPath: string | URL | Path, options?: {
344
+ copySync(destinationPath: PathLike, options?: {
343
345
  overwrite?: boolean;
344
346
  }): Path;
345
347
  /**
346
348
  * Copies the file or directory to the specified directory.
347
349
  * @returns The destination path.
348
350
  */
349
- copyToDir(destinationDirPath: string | URL | Path, options?: {
351
+ copyToDir(destinationDirPath: PathLike, options?: {
350
352
  overwrite?: boolean;
351
353
  }): Promise<Path>;
352
354
  /**
353
355
  * Copies the file or directory to the specified directory synchronously.
354
356
  * @returns The destination path.
355
357
  */
356
- copyToDirSync(destinationDirPath: string | URL | Path, options?: {
358
+ copyToDirSync(destinationDirPath: PathLike, options?: {
357
359
  overwrite?: boolean;
358
360
  }): Path;
359
361
  /**
360
362
  * Copies the file to the specified destination path.
361
363
  * @returns The destination path.
362
364
  */
363
- copyFile(destinationPath: string | URL | Path): Promise<Path>;
365
+ copyFile(destinationPath: PathLike): Promise<Path>;
364
366
  /**
365
367
  * Copies the file to the destination path synchronously.
366
368
  * @returns The destination path.
367
369
  */
368
- copyFileSync(destinationPath: string | URL | Path): Path;
370
+ copyFileSync(destinationPath: PathLike): Path;
369
371
  /**
370
372
  * Copies the file to the specified directory.
371
373
  * @returns The destination path.
372
374
  */
373
- copyFileToDir(destinationDirPath: string | URL | Path): Promise<Path>;
375
+ copyFileToDir(destinationDirPath: PathLike): Promise<Path>;
374
376
  /**
375
377
  * Copies the file to the specified directory synchronously.
376
378
  * @returns The destination path.
377
379
  */
378
- copyFileToDirSync(destinationDirPath: string | URL | Path): Path;
380
+ copyFileToDirSync(destinationDirPath: PathLike): Path;
379
381
  /**
380
382
  * Moves the file or directory returning a promise that resolves to
381
383
  * the renamed path.
382
384
  * @returns The destination path.
383
385
  */
384
- rename(newPath: string | URL | Path): Promise<Path>;
386
+ rename(newPath: PathLike): Promise<Path>;
385
387
  /**
386
388
  * Moves the file or directory returning the renamed path synchronously.
387
389
  * @returns The destination path.
388
390
  */
389
- renameSync(newPath: string | URL | Path): Path;
391
+ renameSync(newPath: PathLike): Path;
390
392
  /**
391
393
  * Moves the file or directory to the specified directory.
392
394
  * @returns The destination path.
393
395
  */
394
- renameToDir(destinationDirPath: string | URL | Path): Promise<Path>;
396
+ renameToDir(destinationDirPath: PathLike): Promise<Path>;
395
397
  /**
396
398
  * Moves the file or directory to the specified directory synchronously.
397
399
  * @returns The destination path.
398
400
  */
399
- renameToDirSync(destinationDirPath: string | URL | Path): Path;
401
+ renameToDirSync(destinationDirPath: PathLike): Path;
400
402
  /** Opens the file and pipes it to the writable stream. */
401
403
  pipeTo(dest: WritableStream<Uint8Array>, options?: StreamPipeOptions): Promise<this>;
402
404
  }
package/esm/mod.js CHANGED
@@ -1,9 +1,6 @@
1
- // npm/esm/_dnt.shims.js
2
- var dntGlobalThis = globalThis;
3
-
4
1
  // npm/esm/deps/jsr.io/@std/internal/1.0.14/_os.js
5
2
  function checkWindows() {
6
- const global = dntGlobalThis;
3
+ const global = globalThis;
7
4
  const platform = global.process?.platform;
8
5
  if (typeof platform === "string")
9
6
  return platform.startsWith("win");
@@ -640,7 +637,7 @@ function normalize3(path2) {
640
637
 
641
638
  // npm/esm/deps/jsr.io/@std/path/1.1.6/_common/env.js
642
639
  function cwd(errorMessage) {
643
- const global = dntGlobalThis;
640
+ const global = globalThis;
644
641
  const getCwd = global.process?.cwd ?? global.Deno?.cwd;
645
642
  if (typeof getCwd !== "function") {
646
643
  throw new TypeError(errorMessage);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dsherret/path",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "Path class for JavaScript.",
5
5
  "keywords": [
6
6
  "path",
@@ -20,12 +20,13 @@
20
20
  "module": "./esm/mod.js",
21
21
  "exports": {
22
22
  ".": {
23
- "import": "./esm/mod.js"
23
+ "import": "./esm/mod.js",
24
+ "default": "./esm/mod.js"
24
25
  }
25
26
  },
26
27
  "scripts": {},
27
28
  "devDependencies": {
28
29
  "@types/node": "^24.0.0"
29
30
  },
30
- "_generatedBy": "dnt@dev"
31
+ "_generatedBy": "dnt@0.44.0"
31
32
  }