Title: Improve Path.parse / Path.format combo · Issue #1999 · nodejs/node · GitHub
Open Graph Title: Improve Path.parse / Path.format combo · Issue #1999 · nodejs/node
X Title: Improve Path.parse / Path.format combo · Issue #1999 · nodejs/node
Description: We have Path.format / Path.parse functions. They can be chained which is very convenient. import Path from "path"; let path = "/foo/bar/bazz.js"; let pathP = Path.format(Path.parse(path)); Currently parse converts string to an object wit...
Open Graph Description: We have Path.format / Path.parse functions. They can be chained which is very convenient. import Path from "path"; let path = "/foo/bar/bazz.js"; let pathP = Path.format(Path.parse(path)); Currentl...
X Description: We have Path.format / Path.parse functions. They can be chained which is very convenient. import Path from "path"; let path = "/foo/bar/bazz.js"; let pathP = Path.format(Path.pa...
Opengraph URL: https://github.com/nodejs/node/issues/1999
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Improve Path.parse / Path.format combo","articleBody":"We have `Path.format` / `Path.parse` functions.\nThey can be chained which is very convenient.\n\n``` js\nimport Path from \"path\";\n\nlet path = \"/foo/bar/bazz.js\";\nlet pathP = Path.format(Path.parse(path));\n```\n\nCurrently `parse` converts string to an object with such structure\n\n``` js\n{ root: '/',\n dir: '/Users/ivankleshnin/Projects/demo',\n base: 'config.yml',\n ext: '.yml',\n name: 'config' }\n```\n\nThis object contains denormalized data between `base`, `name` and `ext` key values.\nNow let's try to replace file extension.\n\n``` js\nimport Path from \"path\";\nimport {assoc} from \"ramda\"\n\nlet path = \"/Users/ivankleshnin/Projects/demo/config.js\";\nlet pathP = assoc(\"ext\", \".json\", Path.parse(path));\n/* {...\n base: 'config.js', -- these two are \n ext: '.json', -- unsynced!\n...} */\nconsole.log(Path.format(pathP)); // extension weren't changed :(\n```\n\nThe simplest task is going to be not so simple?!\nNow if `format` took into consideration `ext` and `name` rather than `base` this could lead to an equal problem with changes to `base` key being ignored. \n\nCan we get rid of this `base` key? It's always `parsed.name + parsed.ext` formula, not a big deal to make it manually. Example of hidden file parse: `{ base: '.gitignore', ext: '', name: '.gitignore' }` - same rule apply.\n\nWe can probably also implement it in a backward-compatibile way,\nkeeping `base` but using JS getter / setter for it's evaluation.\n","author":{"url":"https://github.com/ivan-kleshnin","@type":"Person","name":"ivan-kleshnin"},"datePublished":"2015-06-17T08:54:39Z","url":"https://github.com/nodejs/node/issues/1999"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:528668e7-ecfb-3a9b-f913-698beb623d28 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E5A4:328E29:7EEF6B:A4BF4B:6AED3448 |
| html-safe-nonce | c40ec36d0df15c75ee28723af0a6a161f5ef8373d39fb825d40496d0295183f0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNUE0OjMyOEUyOTo3RUVGNkI6QTRCRjRCOjZBRUQzNDQ4IiwidmlzaXRvcl9pZCI6IjIxNjIwNDg3MTcxMTgzMjE3MzYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 971f35fb306d1a322457379a59497d6640bab2bb6a3873e27523fad312435ed1 |
| hovercard-subject-tag | issue:88959802 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/1999/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f90ff723a05f873c25a8e94e17c3e91bfad3ffa977b6398ae1fe2027828743cf/nodejs/node/issues/1999 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f90ff723a05f873c25a8e94e17c3e91bfad3ffa977b6398ae1fe2027828743cf/nodejs/node/issues/1999 |
| og:image:alt | We have Path.format / Path.parse functions. They can be chained which is very convenient. import Path from "path"; let path = "/foo/bar/bazz.js"; let pathP = Path.format(Path.parse(path)); Currentl... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ivan-kleshnin |
| hostname | github.com |
| expected-hostname | github.com |
| None | e51d0b7b5ab34b1688c05b54c3ed17b8658b2fa9bca973a9c740683ccb12cf4a |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 59ebb7b901cc154ecc179a44f266fcf69f343b30 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width