UNPKG

@stryke/path

Version:

A package containing various utilities that expand the functionality of NodeJs's built-in `path` module

1 lines 2.31 kB
{"version":3,"file":"delimiter.mjs","names":[],"sources":["../src/delimiter.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * The platform-specific file delimiter.\n *\n * Equals to `\";\"` in windows and `\":\"` in all other platforms.\n */\nexport const delimiter: \";\" | \":\" = /* @__PURE__ */ (() =>\n process?.platform === \"win32\" ? \";\" : \":\")();\n\n// Mix namespaces without side-effects of object to allow tree-shaking\n\nconst platforms = {\n posix: undefined,\n win32: undefined\n};\n\nconst mix = (del: \";\" | \":\" = delimiter) => {\n return new Proxy(\n {},\n {\n get(_, prop) {\n if (prop === \"delimiter\") {\n return del;\n }\n if (prop === \"posix\") {\n // eslint-disable-next-line ts/no-use-before-define\n return posix;\n }\n if (prop === \"win32\") {\n // eslint-disable-next-line ts/no-use-before-define\n return win32;\n }\n return platforms[prop as keyof typeof platforms];\n }\n }\n ) as unknown as typeof platforms & { delimiter: typeof del };\n};\n\nexport const posix = /* @__PURE__ */ mix(\":\");\n\nexport const win32 = /* @__PURE__ */ mix(\";\");\n"],"mappings":";;;;;;AAuBA,MAAa,YACX,SAAS,aAAa,UAAU,MAAM;AAIxC,MAAM,YAAY;CAChB,OAAO;CACP,OAAO;CACR;AAED,MAAM,OAAO,MAAiB,cAAc;AAC1C,QAAO,IAAI,MACT,EAAE,EACF,EACE,IAAI,GAAG,MAAM;AACX,MAAI,SAAS,YACX,QAAO;AAET,MAAI,SAAS,QAEX,QAAO;AAET,MAAI,SAAS,QAEX,QAAO;AAET,SAAO,UAAU;IAEpB,CACF;;AAGH,MAAa,QAAwB,oBAAI,IAAI;AAE7C,MAAa,QAAwB,oBAAI,IAAI"}