{"id":15985962,"url":"https://github.com/aminya/patha","last_synced_at":"2025-04-15T16:16:53.885Z","repository":{"id":56871420,"uuid":"526502514","full_name":"aminya/patha","owner":"aminya","description":"File paths library. All you need to work with paths. Tiny drop-in replacement for 'path'. Works in Node, Browser, and Deno.","archived":false,"fork":false,"pushed_at":"2025-04-13T10:23:29.000Z","size":745,"stargazers_count":4,"open_issues_count":11,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-15T16:16:33.593Z","etag":null,"topics":["browser","deno","file-path","file-paths","fs","node","npm","path","path-extra","path-plus","paths"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/patha","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aminya.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["aminya"],"polar":"aminya","patreon":"aminya"}},"created_at":"2022-08-19T07:17:41.000Z","updated_at":"2025-03-29T18:39:45.000Z","dependencies_parsed_at":"2024-03-30T09:22:02.009Z","dependency_job_id":"b4e1e9a0-5a48-4ea5-9b00-09eabdb66812","html_url":"https://github.com/aminya/patha","commit_stats":{"total_commits":63,"total_committers":1,"mean_commits":63.0,"dds":0.0,"last_synced_commit":"1f56b3c88c737b51909db3c5241093f13b02faf9"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aminya%2Fpatha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aminya%2Fpatha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aminya%2Fpatha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aminya%2Fpatha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aminya","download_url":"https://codeload.github.com/aminya/patha/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249105474,"owners_count":21213536,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["browser","deno","file-path","file-paths","fs","node","npm","path","path-extra","path-plus","paths"],"created_at":"2024-10-08T02:41:23.335Z","updated_at":"2025-04-15T16:16:53.865Z","avatar_url":"https://github.com/aminya.png","language":"TypeScript","readme":"\u003c!-- Generated via running `pnpm run docs` --\u003e\n\n\u003ch1 align=\"center\"\u003epatha\u003c/h1\u003e\n\u003cp\u003e\n  \u003ca href=\"https://github.com/aminya/patha/actions/workflows/CI.yml\" target=\"_blank\"\u003e\n    \u003cimg alt=\"CI\" src=\"https://github.com/aminya/patha/actions/workflows/CI.yml/badge.svg\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/patha\" target=\"_blank\"\u003e\n    \u003cimg alt=\"Version\" src=\"https://img.shields.io/npm/v/patha.svg\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"#\" target=\"_blank\"\u003e\n    \u003cimg alt=\"License: Apache--2.0\" src=\"https://img.shields.io/badge/License-Apache--2.0-yellow.svg\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003e File paths library. All you need to work with paths. Tiny drop-in replacement for 'path'. Works in Node, Browser, and Deno.\n\n\u003c!-- @import \"[TOC]\" {cmd=\"toc\" depthFrom=1 depthTo=6 orderedList=false} --\u003e\n\n\u003c!-- code_chunk_output --\u003e\n\n- [Install](#install)\n- [Usage](#usage)\n- [API](#api)\n  - [`addExeExt` (function)](#addexeext-function)\n  - [`addNamePrefix` (function)](#addnameprefix-function)\n  - [`addNameSuffix` (function)](#addnamesuffix-function)\n  - [`addShExt` (function)](#addshext-function)\n  - [`addShRelativePrefix` (function)](#addshrelativeprefix-function)\n  - [`name` (function)](#name-function)\n  - [`normalizeTrim` (function)](#normalizetrim-function)\n  - [`removeExt` (function)](#removeext-function)\n  - [`replaceExt` (function)](#replaceext-function)\n  - [`isPathInside` (function)](#ispathinside-function)\n- [🤝 Contributing](#contributing)\n\n\u003c!-- /code_chunk_output --\u003e\n\n## Install\n\n```sh\nnpm install --save patha\n```\n\n`patha` is tiny and treeshakable.\n\n## Usage\n\nAutomatic (depends on your build system)\n\n```js\nimport * as patha from \"patha\"\n```\n\nNode\n\n```js\nimport * as patha from \"patha/dist/index.node.mjs\"\n```\n\nNode CJS\n\n```js\nconst patha = require(\"patha/dist/index.node.cjs\")\n```\n\nBrowser\n\n```js\nimport * as patha from \"patha/dist/index.browser.mjs\"\n```\n\nBrowser Legacy\n\n```js\nimport * as patha from \"patha/dist/index.browser.legacy.js\"\n```\n\nDeno\n\n```js\nimport * as patha from \"patha/dist/index.deno.mjs\"\n```\n\n## API\n\n`patha` is a drop-replacement for `path`, which is explained in [the Nodejs documentation](https://nodejs.org/api/path.html).\n\n```js\nimport {\n  basename,\n  delimiter,\n  dirname,\n  extname,\n  format,\n  isAbsolute,\n  join,\n  normalize,\n  parse,\n  posix,\n  relative,\n  resolve,\n  sep,\n  toNamespacedPath,\n  win32,\n} from \"patha\"\n```\n\nAdditionally, `patha` supports the following functions:\n\n\u003c!-- INSERT GENERATED DOCS START --\u003e\n\n### `addExeExt` (function)\n\nAdd bin extension to the given binary name.\n\n**Parameters:**\n\n- name (`string`) - The name you want to add the shell extension to\n- win_ext (`string`) - Defaults to `.exe` on Windows\n- other_ext (`string`) - Defaults to `\"\"` On other platforms.\n\n**returns:** string\n\n```js\nimport { addExeExt } from \"patha\"\n\naddExeExt(\"path/to/file-name\") // gives \"path/to/file-name.exe\" on Windows and \"path/to/file-name\" on others\n```\n\n### `addNamePrefix` (function)\n\nAdds a prefix to the start of the name of the given path\n\n**Parameters:**\n\n- path (`string`) - The given file path\n- prefix (`string`) - The prefix to add to the start of the file name\n\n**returns:** string\n\n```js\nimport { addNamePrefix } from \"patha\"\n\naddNamePrefix(\"path/to/file-name.ext\", \"new-\") // gives \"path/to/new-file-name.ext\"\n```\n\n### `addNameSuffix` (function)\n\nAdds a suffix to the end of the name of the given path\n\n**Parameters:**\n\n- path (`string`) - The given file path\n- suffix (`string`) - The suffix to add to the end of the file name\n\n**returns:** string\n\n```js\nimport { addNameSuffix } from \"patha\"\n\naddNameSuffix(\"path/to/file-name.ext\", \"-old\") // gives \"path/to/file-name-old.ext\"\n\naddNameSuffix(\"path/to/file-name.ext\", \".test\") // gives \"path/to/file-name.test.ext\"\n```\n\n### `addShExt` (function)\n\nAdd a native shell extension to the given name.\n\n**Parameters:**\n\n- name (`string`) - The name you want to add the shell extension to\n- win_ext (`string`) - `.cmd` on Windows\n- other_ext (`string`) - `.sh` On others.\n\n**returns:** string\n\n```js\nimport { addShExt } from \"patha\"\n\naddShExt(\"path/to/file-name\") // gives \"path/to/file-name.cmd\" on Windows and \"path/to/file-name.sh\" on others\n\naddShExt(\"path/to/file-name\", \".bat\") // gives \"path/to/file-name.bat\" on Windows and \"path/to/file-name.sh\" on others\n```\n\n### `addShRelativePrefix` (function)\n\nPrefix a `./` for unix shell and nothing for `cmd`.\n\n**Parameters:**\n\n- path (`string`) - The given path\n\n**returns:** string\n\n```js\nimport { addShRelativePrefix } from \"patha\"\n\naddShRelativePrefix(\"some/file-name\") // gives \"some/file-name\" on Windows and \"./some/file-name\" on others.\n```\n\n### `name` (function)\n\nGet the name of the given file path.\n\nBy default the file extension is included in the returned name. To remove the extension, set the second parameter to `false`.\n\n**Parameters:**\n\n- path (`string`) - The given file path\n- includeExtension (`boolean`) - If the name should include the file extension as well\n\n**returns:** string\n\n```js\nimport { name } from \"patha\"\n\nname(\"path/to/file.md\") // gives \"file.md\"\n\nname(\"path/to/file.md\", false) // gives \"file\"\n```\n\n### `normalizeTrim` (function)\n\nNormalizes the path and removes the trailing slashes.\n\n**Parameters:**\n\n- path (`string`) - The given file path\n\n**returns:** string\n\n```js\nimport { normalize, normalizeTrim } from \"patha\"\n\nnormalizeTrim(\"/foo/bar//baz/asdf/hello/../\") // gives \"/foo/bar/baz/asdf\"\n\nnormalize(\"/foo/bar//baz/asdf/hello/../\") // gives \"/foo/bar/baz/asdf/\"\n```\n\n### `removeExt` (function)\n\nRemove a path's extension.\n\n**Parameters:**\n\n- path (`string`) - The given path\n\n**returns:** string\n\n```js\nimport { removeExt } from \"patha\"\n\nremoveExt(\"some/dir/file.ext\") // gives \"some/dir/file\"\n```\n\n### `replaceExt` (function)\n\nReplaces the extension from path with extension and returns the updated path string.\n\nDoes not replace the extension if path is not a string or is empty.\n\n**Parameters:**\n\n- path (`string`) - The given path\n- extension (`string`) - The extension to replace\n\n**returns:** any\n\n```js\nimport { replaceExt } from \"patha\"\n\nreplaceExt(\"path/to/file.md\", \".html\") // gives \"path/to/file.html\"\n```\n\n### `isPathInside` (function)\n\nCheck if a path is inside another path.\n\nNote that relative paths are resolved against `process.cwd()` to make them absolute.\n\nThis function does not check if the paths exist and it only works with strings.\n\n**Parameters:**\n\n- childPath (`string`)\n- parentPath (`string`)\n\n**returns:** boolean\n\n```js\nimport { isPathInside } from \"patha\"\n\nisPathInside(\"a/b/c\", \"a/b\")\n//=\u003e true\n\nisPathInside(\"a/b/c\", \"x/y\")\n//=\u003e false\n\nisPathInside(\"a/b/c\", \"a/b/c\")\n//=\u003e false\n\nisPathInside(\"/Users/some/dev/aa\", \"/Users/some\")\n//=\u003e true\n```\n\n\u003c!-- INSERT GENERATED DOCS END --\u003e\n\n## 🤝 Contributing\n\nYou can sponsor my work here:\n\nhttps://github.com/sponsors/aminya\n\nPull requests, issues and feature requests are welcome.\nSee the [Contributing guide](https://github.com/aminya/patha/blob/master/CONTRIBUTING.md).\n","funding_links":["https://github.com/sponsors/aminya","https://polar.sh/aminya","https://patreon.com/aminya"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faminya%2Fpatha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faminya%2Fpatha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faminya%2Fpatha/lists"}