npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

path-is-same

v1.0.29

Published

路徑比較工具 - 檢查多個路徑是否指向相同的檔案或目錄

Downloads

2,196

Readme

path-is-same - 路徑比較工具

這個模組提供了多種路徑比較功能,可以檢查多個路徑是否指向相同的檔案或目錄。

主要功能

  • 檢查多個路徑是否相同
  • 檢查多個路徑是否指向相同的實體檔案
  • 支援相對路徑比較
  • 支援網路磁碟機路徑
  • 完全相容於 Node.js 路徑處理

安裝

yarn add path-is-same
yarn-tool add path-is-same
yt add path-is-same

快速開始

import pathIsSame from 'path-is-same';

// 檢查兩個路徑是否相同
const result = pathIsSame('/path/to/file', '/path/to/file');
console.log(result); // true

// 檢查多個路徑是否相同
const result2 = pathIsSame('/path/to/file', '/path/to/file', '/path/to/file');
console.log(result2); // true

API 文件

pathIsSame(p1: string, ...ps: string[]): boolean

檢查多個路徑是否相同。

參數:

  • p1 (string): 第一個路徑
  • ...ps (string[]): 其他路徑

返回值:

  • boolean: 如果所有路徑相同則返回 true,否則返回 false

fsSameRealpath(p1: string, ...ps: string[]): boolean

檢查多個路徑是否指向相同的實體檔案。

參數:

  • p1 (string): 第一個路徑
  • ...ps (string[]): 其他路徑

返回值:

  • boolean: 如果所有路徑指向相同的實體檔案則返回 true,否則返回 false

_pathIsSame(p1: string, p2: string): boolean

內部函數:檢查兩個路徑是否相同。

參數:

  • p1 (string): 第一個路徑
  • p2 (string): 第二個路徑

返回值:

  • boolean: 如果路徑相同則返回 true,否則返回 false

_assertInputArgv(p1: string, ...ps: string[]): void

內部函數:檢查輸入參數是否有效。

參數:

  • p1 (string): 第一個路徑
  • ...ps (string[]): 其他路徑

拋出:

  • TypeError: 如果沒有提供足夠的路徑參數

使用範例

基本路徑比較

import pathIsSame from 'path-is-same';

// 檢查相對路徑
console.log(pathIsSame('./file.txt', './file.txt')); // true

// 檢查絕對路徑
console.log(pathIsSame('/home/user/file.txt', '/home/user/file.txt')); // true

// 檢查不同路徑
console.log(pathIsSame('/path/to/file', '/different/path/file')); // false

實體檔案比較

import { fsSameRealpath } from 'path-is-same';

// 檢查符號連結是否指向相同檔案
console.log(fsSameRealpath('/path/to/link1', '/path/to/link2')); // true/false

// 檢查硬連結是否指向相同檔案
console.log(fsSameRealpath('/path/to/hardlink1', '/path/to/hardlink2')); // true/false

多路徑比較

import pathIsSame from 'path-is-same';

// 檢查多個路徑是否都相同
const paths = ['/path/to/file', '/path/to/file', '/path/to/file'];
console.log(pathIsSame(...paths)); // true

// 檢查多個路徑是否不完全相同
const differentPaths = ['/path/to/file1', '/path/to/file2', '/path/to/file3'];
console.log(pathIsSame(...differentPaths)); // false

貢獻

歡迎提交問題和拉取請求!

授權

ISC