{"_id":"@lazy-node/types-path","_rev":"4182014","name":"@lazy-node/types-path","description":"路徑處理類型定義模組 - 提供完整的路徑處理相關類型定義，支援多種平台和路徑處理庫","dist-tags":{"latest":"1.0.3"},"maintainers":[{"name":"bluelovers","email":""}],"time":{"modified":"2026-03-01T21:54:05.000Z","created":"2026-03-01T14:25:17.094Z","1.0.3":"2026-03-02T02:14:58.439Z","1.0.2":"2026-03-01T14:25:17.094Z"},"users":{},"author":{"name":"bluelovers"},"repository":{"type":"git","url":"git+https://github.com/bluelovers/ws-iconv.git","directory":"packages/@lazy-node/types-path"},"versions":{"1.0.3":{"name":"@lazy-node/types-path","version":"1.0.3","description":"路徑處理類型定義模組 - 提供完整的路徑處理相關類型定義，支援多種平台和路徑處理庫","keywords":["create-by-yarn-tool","path","types","typescript","nodejs","cross-platform"],"homepage":"https://github.com/bluelovers/ws-iconv/tree/master/packages/@lazy-node/types-path#readme","bugs":{"url":"https://github.com/bluelovers/ws-iconv/issues"},"repository":{"type":"git","url":"git+https://github.com/bluelovers/ws-iconv.git","directory":"packages/@lazy-node/types-path"},"license":"ISC","author":{"name":"bluelovers"},"sideEffects":false,"type":"commonjs","main":"index.js","scripts":{"review":"yarn run review:coverage","review:coverage":"yarn run lint && yarn run coverage","review:test":"yarn run lint && yarn run test","coverage":"yarn run test -- --coverage","lint":"yarn run lint:eslint","lint:eslint":"ynpx eslint --ext .ts,.tsx,.mts,.cts ./","pretest":"echo pretest","test":"jest --passWithNoTests","test:jest":"jest --passWithNoTests","test:jest:coverage":"yarn run test:jest -- --coverage","test:jest:snapshot":"yarn run test:jest -- -u","test:mocha":"ynpx --quiet -p ts-node -p mocha mocha -- --require ts-node/register \"!(node_modules)/**/*.{test,spec}.{ts,tsx}\"","test:snapshot":"yarn run test -- -u","test:tsd":"ynpx tsd","test:tsdx":"ynpx @bluelovers/tsdx test --passWithNoTests","build:dts:bundle":"ynpx @bluelovers/dts-bundle-generator -o ./dist/index.d.ts ./src/index.ts --no-banner --inline-declare-global & echo build:dts:bundle","build:dts:copy":"copy .\\src\\index.d.ts .\\dist\\index.d.ts & echo build:dts","build:dts:tsc":"yarn run build:dts:tsc:emit && yarn run build:dts:copy","build:dts:tsc:emit":"tsc --emitDeclarationOnly --declaration --noEmit false","build:microbundle":"ynpx microbundle --target node","build:tsdx":"ynpx @bluelovers/tsdx build --target node --name index","ci:install":"echo ci:install","ci:build":"echo ci:build","preversion":"echo preversion && yarn run test","version":"echo version","postversion":"echo postversion","prepublish":"echo prepublish","prepare":"echo prepare","prepublishOnly":"echo prepublishOnly","prepack":"echo prepack","pack":"echo pack","postpack":"echo postpack","publish":"echo publish","postpublish":"echo postpublish","postpublishOnly":"echo postpublishOnly","sort-package-json":"yarn-tool sort","tsc:default":"tsc -p tsconfig.json","tsc:esm":"tsc -p tsconfig.esm.json","tsc:showConfig":"ynpx get-current-tsconfig -p"},"dependencies":{"@types/node":"*","ts-type":"^3.0.1","tslib":">=2"},"publishConfig":{"access":"public"},"gitHead":"b3974c1f5bf98e50fca3e403453837fc8e681230","types":"./index.d.ts","_id":"@lazy-node/types-path@1.0.3","_nodeVersion":"24.13.1","_npmVersion":"lerna/6.6.2/node@v24.13.1+x64 (win32)","dist":{"shasum":"44afcd74cd235c3a269a791c584cd933ad19453c","size":7469,"noattachment":false,"key":"/@lazy-node/types-path/-/@lazy-node/types-path-1.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/@lazy-node/types-path/download/@lazy-node/types-path-1.0.3.tgz"},"_npmUser":{"name":"bluelovers","email":"codelovers@users.sourceforge.net"},"directories":{},"maintainers":[{"name":"bluelovers","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/types-path_1.0.3_1772417698283_0.4574705913581476"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2026-03-02T02:14:58.439Z","publish_time":1772417698439,"_source_registry_name":"default","_cnpm_publish_time":1772417698439},"1.0.2":{"name":"@lazy-node/types-path","version":"1.0.2","description":"路徑處理類型定義模組 - 提供完整的路徑處理相關類型定義，支援多種平台和路徑處理庫","keywords":["create-by-yarn-tool","path","types","typescript","nodejs","cross-platform"],"homepage":"https://github.com/bluelovers/ws-iconv/tree/master/packages/@lazy-node/types-path#readme","bugs":{"url":"https://github.com/bluelovers/ws-iconv/issues"},"repository":{"type":"git","url":"git+https://github.com/bluelovers/ws-iconv.git","directory":"packages/@lazy-node/types-path"},"license":"ISC","author":{"name":"bluelovers"},"sideEffects":false,"type":"commonjs","main":"index.js","scripts":{"review":"yarn run review:coverage","review:coverage":"yarn run lint && yarn run coverage","review:test":"yarn run lint && yarn run test","coverage":"yarn run test -- --coverage","lint":"yarn run lint:eslint","lint:eslint":"ynpx eslint --ext .ts,.tsx,.mts,.cts ./","pretest":"echo pretest","test":"jest --passWithNoTests","test:jest":"jest --passWithNoTests","test:jest:coverage":"yarn run test:jest -- --coverage","test:jest:snapshot":"yarn run test:jest -- -u","test:mocha":"ynpx --quiet -p ts-node -p mocha mocha -- --require ts-node/register \"!(node_modules)/**/*.{test,spec}.{ts,tsx}\"","test:snapshot":"yarn run test -- -u","test:tsd":"ynpx tsd","test:tsdx":"ynpx @bluelovers/tsdx test --passWithNoTests","build:dts:bundle":"ynpx @bluelovers/dts-bundle-generator -o ./dist/index.d.ts ./src/index.ts --no-banner --inline-declare-global & echo build:dts:bundle","build:dts:copy":"copy .\\src\\index.d.ts .\\dist\\index.d.ts & echo build:dts","build:dts:tsc":"yarn run build:dts:tsc:emit && yarn run build:dts:copy","build:dts:tsc:emit":"tsc --emitDeclarationOnly --declaration --noEmit false","build:microbundle":"ynpx microbundle --target node","build:tsdx":"ynpx @bluelovers/tsdx build --target node --name index","ci:install":"echo ci:install","ci:build":"echo ci:build","preversion":"echo preversion && yarn run test","version":"echo version","postversion":"echo postversion","prepublish":"echo prepublish","prepare":"echo prepare","prepublishOnly":"echo prepublishOnly","prepack":"echo prepack","pack":"echo pack","postpack":"echo postpack","publish":"echo publish","postpublish":"echo postpublish","postpublishOnly":"echo postpublishOnly","sort-package-json":"yarn-tool sort","tsc:default":"tsc -p tsconfig.json","tsc:esm":"tsc -p tsconfig.esm.json","tsc:showConfig":"ynpx get-current-tsconfig -p"},"dependencies":{"@types/node":"*","ts-type":"^3.0.1","tslib":">=2"},"publishConfig":{"access":"public"},"gitHead":"6bcfe6a585ad7e5657a40a5b0727c6281b564b60","_id":"@lazy-node/types-path@1.0.2","_nodeVersion":"24.13.1","_npmVersion":"lerna/6.6.2/node@v24.13.1+x64 (win32)","dist":{"shasum":"d85d90702bfd7c5d03b92255572be3cefe893a9b","size":3254,"noattachment":false,"key":"/@lazy-node/types-path/-/@lazy-node/types-path-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/@lazy-node/types-path/download/@lazy-node/types-path-1.0.2.tgz"},"_npmUser":{"name":"bluelovers","email":"codelovers@users.sourceforge.net"},"directories":{},"maintainers":[{"name":"bluelovers","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/types-path_1.0.2_1772375116938_0.47131924539864367"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2026-03-01T14:25:17.094Z","publish_time":1772375117094,"_source_registry_name":"default","_cnpm_publish_time":1772375117094}},"readme":"# @lazy-node/types-path - 路徑處理類型定義模組\n\n這個模組提供了完整的路徑處理相關類型定義，支援多種平台和路徑處理庫。\n\n## 主要功能\n\n- 完整的路徑處理類型定義\n- 支援多種平台（Windows、POSIX）\n- 支援多種路徑處理庫（Node.js、upath2）\n- 靈活的路徑處理介面\n- 路徑分隔符合規表示式工具\n- TypeScript 友好的類型支援\n\n## 安裝\n\n```bash\nyarn add @lazy-node/types-path\nyarn-tool add @lazy-node/types-path\nyt add @lazy-node/types-path\n```\n\n## 快速開始\n\n```typescript\nimport { IPath, EnumPathPlatformOrigin, makeRePathSepSlash } from '@lazy-node/types-path';\n\n// 使用路徑處理介面\nconst pathHandler: IPath = {\n  name: EnumPathPlatformOrigin.posix,\n  join: (path, ...paths) => path + '/' + paths.join('/'),\n  normalize: (path) => path.replace(/\\\\/g, '/'),\n  // ... 其他方法\n};\n\n// 建立路徑分隔符合規表示式\nconst reSlash = makeRePathSepSlash({ global: true });\nconst reWin32 = makeRePathSepSlash({ sep: '\\\\', global: true });\n\nconsole.log('/path/to/file'.replace(reSlash, '\\\\')); // 轉換為 Windows 路徑\n```\n\n## API 文件\n\n### 基本類型\n\n#### IPlatformPathNodeOrigin\nNode.js 原生 path 模組的類型定義。\n\n#### IPathPlatformOrigin\n平台特定的路徑類型，支援 'win32' 和 'posix'。\n\n#### IPathPlatform\n完整的路徑平台類型，包含原生和擴展平台類型。\n\n#### IPathSep\n平台特定的檔案分隔符類型。\n\n#### IPathDelimiter\n平台特定的路徑分隔符類型。\n\n### 介面定義\n\n#### IPathNode\nNode.js 原生 path 模組介面，包含核心路徑處理方法。\n\n#### IPath\n擴展路徑處理介面，提供更靈活的路徑處理功能。\n\n### 工具函數\n\n#### makeRePathSepSlash(options?: IRePathSepSlashOptions): RegExp\n建立路徑分隔符合規表示式。\n\n**參數：**\n- `options` (IRePathSepSlashOptions): 選項物件\n\n**返回值：**\n- `RegExp`: 正規表示式\n\n**選項物件：**\n```typescript\ninterface IRePathSepSlashOptions {\n  sep?: IPathSep;        // 指定分隔符\n  all?: boolean;         // 是否匹配所有分隔符\n  global?: boolean;      // 是否全域匹配\n  match?: boolean;       // 是否使用捕獲群組\n  matchFull?: boolean;   // 是否完整匹配\n  repeat?: number;       // 重複次數\n}\n```\n\n## 使用範例\n\n### 基本類型使用\n\n```typescript\nimport { EnumPathPlatformOrigin, IPathPlatform } from '@lazy-node/types-path';\n\n// 使用平台列舉\nconst platform: IPathPlatform = EnumPathPlatformOrigin.win32;\n\n// 檢查平台類型\nif (platform === EnumPathPlatformOrigin.posix) {\n  console.log('POSIX 平台');\n}\n```\n\n### 路徑處理介面\n\n```typescript\nimport { IPath, EnumPathPlatformOrigin } from '@lazy-node/types-path';\n\n// 實作自定義路徑處理器\nconst customPathHandler: IPath = {\n  name: EnumPathPlatformOrigin.posix,\n  join: (path, ...paths) => {\n    return [path, ...paths].join('/').replace(/\\/+/g, '/');\n  },\n  normalize: (path) => {\n    return path.replace(/\\\\/g, '/').replace(/\\/+$/, '');\n  },\n  // ... 實作其他方法\n};\n```\n\n### 正規表示式工具\n\n```typescript\nimport { makeRePathSepSlash, EnumPathSep } from '@lazy-node/types-path';\n\n// 建立全域路徑分隔符合規表示式\nconst reAll = makeRePathSepSlash({ global: true });\nconsole.log('/path\\\\to/file'.replace(reAll, '/')); // '/path/to/file'\n\n// 建立 Windows 專用正規表示式\nconst reWin32 = makeRePathSepSlash({ \n  sep: EnumPathSep.win32, \n  global: true \n});\nconsole.log('C:\\\\path\\\\to\\\\file'.replace(reWin32, '/')); // 'C:/path/to/file'\n\n// 建立完整匹配正規表示式\nconst reFull = makeRePathSepSlash({ matchFull: true });\nconsole.log(reFull.test('/path/to/file')); // true\n```\n\n### 實際應用場景\n\n```typescript\nimport { IPath, makeRePathSepSlash } from '@lazy-node/types-path';\n\n// 跨平台路徑處理工具\nclass CrossPlatformPath {\n  private pathHandler: IPath;\n\n  constructor(platform: 'win32' | 'posix') {\n    this.pathHandler = this.createPathHandler(platform);\n  }\n\n  private createPathHandler(platform: 'win32' | 'posix'): IPath {\n    const sep = platform === 'win32' ? '\\\\' : '/';\n    \n    return {\n      name: platform,\n      join: (path, ...paths) => {\n        return [path, ...paths].join(sep).replace(new RegExp(`${sep}+`, 'g'), sep);\n      },\n      normalize: (path) => {\n        const re = makeRePathSepSlash({ global: true });\n        return path.replace(re, sep).replace(new RegExp(`${sep}+$`), '');\n      },\n      // ... 其他方法\n    };\n  }\n\n  join(...paths: string[]): string {\n    return this.pathHandler.join(...paths);\n  }\n\n  normalize(path: string): string {\n    return this.pathHandler.normalize(path);\n  }\n}\n\n// 使用範例\nconst win32Path = new CrossPlatformPath('win32');\nconsole.log(win32Path.join('C:', 'Users', 'name', 'Documents')); // 'C:\\Users\\name\\Documents'\n\nconst posixPath = new CrossPlatformPath('posix');\nconsole.log(posixPath.join('/home', 'user', 'documents')); // '/home/user/documents'\n```\n\n## 貢獻\n\n歡迎提交問題和拉取請求！\n\n## 授權\n\nISC\n\n","_attachments":{},"homepage":"https://github.com/bluelovers/ws-iconv/tree/master/packages/@lazy-node/types-path#readme","bugs":{"url":"https://github.com/bluelovers/ws-iconv/issues"},"license":"ISC"}