{"id":20083647,"url":"https://github.com/marko-js/relative-import-path","last_synced_at":"2025-05-06T01:31:30.550Z","repository":{"id":57352687,"uuid":"468855260","full_name":"marko-js/relative-import-path","owner":"marko-js","description":"Like path.relative for generating short require'able paths.","archived":false,"fork":false,"pushed_at":"2022-03-11T19:36:56.000Z","size":144,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-10-12T21:51:48.489Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marko-js.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-11T18:13:04.000Z","updated_at":"2024-01-07T04:40:19.000Z","dependencies_parsed_at":"2022-09-16T08:11:09.060Z","dependency_job_id":null,"html_url":"https://github.com/marko-js/relative-import-path","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marko-js%2Frelative-import-path","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marko-js%2Frelative-import-path/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marko-js%2Frelative-import-path/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marko-js%2Frelative-import-path/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marko-js","download_url":"https://codeload.github.com/marko-js/relative-import-path/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224479523,"owners_count":17318290,"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":[],"created_at":"2024-11-13T15:48:12.738Z","updated_at":"2024-11-13T15:48:13.506Z","avatar_url":"https://github.com/marko-js.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  \u003c!-- Logo --\u003e\n  \u003cbr/\u003e\n  relative-import-path\n\t\u003cbr/\u003e\n\n  \u003c!-- Format --\u003e\n  \u003ca href=\"https://github.com/prettier/prettier\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/styled_with-prettier-ff69b4.svg\" alt=\"Styled with prettier\"/\u003e\n  \u003c/a\u003e\n  \u003c!-- CI --\u003e\n  \u003ca href=\"https://github.com/marko-js/relative-import-path/actions/workflows/ci.yml\"\u003e\n    \u003cimg src=\"https://github.com/marko-js/relative-import-path/actions/workflows/ci.yml/badge.svg\" alt=\"Build status\"/\u003e\n  \u003c/a\u003e\n  \u003c!-- Coverage --\u003e\n  \u003ca href=\"https://codecov.io/gh/marko-js/relative-import-path\"\u003e\n    \u003cimg src=\"https://codecov.io/gh/marko-js/relative-import-path/branch/main/graph/badge.svg?token=lKuTHVY3Ks\" alt=\"Code Coverage\"/\u003e\n  \u003c/a\u003e\n  \u003c!-- NPM Version --\u003e\n  \u003ca href=\"https://npmjs.org/package/relative-import-path\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/v/relative-import-path.svg\" alt=\"NPM version\"/\u003e\n  \u003c/a\u003e\n  \u003c!-- Downloads --\u003e\n  \u003ca href=\"https://npmjs.org/package/relative-import-path\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/dm/relative-import-path.svg\" alt=\"Downloads\"/\u003e\n  \u003c/a\u003e\n\u003c/h1\u003e\n\nLike path.relative, but for generating short require'able paths.\n\n- Removes unnecessary `node_modules` from resolved relative paths.\n- Automatically converts windows style paths to POSIX.\n\n# Installation\n\n```console\nnpm install relative-import-path\n```\n\n# API\n\n```ts\n/**\n * Given two absolute file paths, resolves a short require'able relative path.\n */\nfunction resolveRelativePath(from: string, to: string): string;\n```\n\n# Examples\n\n```javascript\nimport { relativeImportPath } from \"relative-import-path\";\n\nrelativeImportPath(\"/a/b\", \"/c/d\"); // /c/d\nrelativeImportPath(\"/a/a\", \"/a/b\"); // ./b\nrelativeImportPath(\"/a/a/a\", \"/a/b/a\"); // ../b/a\nrelativeImportPath(\"/a/node_modules/a/a\", \"/a/node_modules/b/a\"); // b/a\nrelativeImportPath(\"/a/node_modules/a/a\", \"/a/node_modules/a/b\"); // ./b\nrelativeImportPath(\"/a/a\", \"/node_modules/b\"); // b\nrelativeImportPath(\"/a/a\", \"/a/node_modules/b\"); // b\nrelativeImportPath(\"/a/b/c\", \"/a/node_modules/b\"); // b\nrelativeImportPath(\"/a/a\", \"/b/node_modules/b\"); // /b/node_modules/b\nrelativeImportPath(\"/a/b/c\", \"/b/node_modules/b\"); // /b/node_modules/b\nrelativeImportPath(\"/a/a\", \"/a/b/node_modules/b\"); // ./b/node_modules/b\nrelativeImportPath(\"/a/node_modules/@a/a/a\", \"/a/node_modules/@a/b/a\"); // @a/b/a\nrelativeImportPath(\"/a/node_modules/@a/a/a\", \"/a/node_modules/@a/a/b\"); // ./b\n```\n\n# Code of Conduct\n\nThis project adheres to the [eBay Code of Conduct](./.github/CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarko-js%2Frelative-import-path","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarko-js%2Frelative-import-path","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarko-js%2Frelative-import-path/lists"}