functype-os 2.2.2 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigResolver.js","names":["ConfigErrorConstructor","IO","Left","List","Option","Right","ConfigError","Fs","expandPath","tryExpandPath","candidate","v","findFirstExisting","candidates","head","found","presentPaths","c","ConfigResolver","options","path","perPath"],"sources":["../../src/config/ConfigResolver.ts"],"sourcesContent":["import type { Either } from \"functype\"\nimport { IO, Left, List, Option, Right } from \"functype\"\n\nimport type { ConfigError } from \"../errors/errors\"\nimport { ConfigError as ConfigErrorConstructor } from \"../errors/errors\"\nimport { Fs } from \"../fs/Fs\"\nimport { expandPath } from \"../path/PathExpander\"\n\nconst tryExpandPath = (candidate: string): Option<string> => {\n const result = expandPath(candidate)\n return result.fold(\n () => Option<string>(undefined),\n (v) => Option(v),\n )\n}\n\n// Checks candidates in order and stops at the first that exists.\nconst findFirstExisting = (candidates: List<string>): IO<never, never, Option<string>> =>\n candidates.headOption().fold(\n () => IO.succeed(Option<string>(undefined)),\n (head) =>\n Fs.exists(head).flatMap((found) => (found ? IO.succeed(Option(head)) : findFirstExisting(candidates.tail()))),\n )\n\n// Expand each candidate; drop entries whose env variables didn't resolve.\nconst presentPaths = (candidates: readonly string[]): List<string> =>\n List<string>(candidates.flatMap((c) => tryExpandPath(c).toArray()))\n\nexport const ConfigResolver = {\n // Async methods — return a lazy IO; nothing touches the filesystem until `.run()`\n\n resolve: (options: { readonly candidates: readonly string[] }): IO<never, never, Option<string>> =>\n findFirstExisting(presentPaths(options.candidates)),\n\n resolveRequired: (options: { readonly candidates: readonly string[] }): IO<never, ConfigError, string> =>\n ConfigResolver.resolve(options).flatMap((found) =>\n found.fold
|
|
1
|
+
{"version":3,"file":"ConfigResolver.js","names":["ConfigErrorConstructor","IO","Left","List","Option","Right","ConfigError","Fs","expandPath","tryExpandPath","candidate","v","findFirstExisting","candidates","head","found","presentPaths","c","ConfigResolver","options","path","perPath"],"sources":["../../src/config/ConfigResolver.ts"],"sourcesContent":["import type { Either } from \"functype\"\nimport { IO, Left, List, Option, Right } from \"functype\"\n\nimport type { ConfigError } from \"../errors/errors\"\nimport { ConfigError as ConfigErrorConstructor } from \"../errors/errors\"\nimport { Fs } from \"../fs/Fs\"\nimport { expandPath } from \"../path/PathExpander\"\n\nconst tryExpandPath = (candidate: string): Option<string> => {\n const result = expandPath(candidate)\n return result.fold(\n () => Option<string>(undefined),\n (v) => Option(v),\n )\n}\n\n// Checks candidates in order and stops at the first that exists.\nconst findFirstExisting = (candidates: List<string>): IO<never, never, Option<string>> =>\n candidates.headOption().fold(\n () => IO.succeed(Option<string>(undefined)),\n (head) =>\n Fs.exists(head).flatMap((found) => (found ? IO.succeed(Option(head)) : findFirstExisting(candidates.tail()))),\n )\n\n// Expand each candidate; drop entries whose env variables didn't resolve.\nconst presentPaths = (candidates: readonly string[]): List<string> =>\n List<string>(candidates.flatMap((c) => tryExpandPath(c).toArray()))\n\nexport const ConfigResolver = {\n // Async methods — return a lazy IO; nothing touches the filesystem until `.run()`\n\n resolve: (options: { readonly candidates: readonly string[] }): IO<never, never, Option<string>> =>\n findFirstExisting(presentPaths(options.candidates)),\n\n resolveRequired: (options: { readonly candidates: readonly string[] }): IO<never, ConfigError, string> =>\n ConfigResolver.resolve(options).flatMap((found) =>\n found.fold(\n () => IO.fail(ConfigErrorConstructor(options.candidates)),\n (path) => IO.succeed(path),\n ),\n ),\n\n // Checks paths one at a time, in order. They're a handful of config candidates, so this\n // costs nothing measurable and keeps the result order stable.\n resolveAll: (options: { readonly candidates: readonly string[] }): IO<never, never, List<string>> =>\n IO.forEach(presentPaths(options.candidates).toArray(), (path) =>\n Fs.exists(path).map((found) => (found ? [path] : [])),\n ).map((perPath) => List<string>(perPath.flat())),\n\n // Sync methods — return Either<ConfigError, T>\n\n resolveSync: (options: { readonly candidates: readonly string[] }): Option<string> =>\n presentPaths(options.candidates).find(Fs.existsSync),\n\n resolveRequiredSync: (options: { readonly candidates: readonly string[] }): Either<ConfigError, string> => {\n const result = ConfigResolver.resolveSync(options)\n return result.fold(\n () => Left(ConfigErrorConstructor(options.candidates)),\n (v) => Right(v),\n )\n },\n\n resolveAllSync: (options: { readonly candidates: readonly string[] }): List<string> =>\n presentPaths(options.candidates).filter(Fs.existsSync),\n}\n"],"mappings":"A,iNAQA,MAAMS,EAAiBC,GACNF,EAAWE,CACd,CAAC,CAAC,SACNN,EAAe,IAAA,EAAS,EAC7BO,GAAMP,EAAOO,CAAC,CACjB,EAIIC,EAAqBC,GACzBA,EAAW,WAAW,CAAC,CAAC,SAChBZ,EAAG,QAAQG,EAAe,IAAA,EAAS,CAAC,EACzCU,GACCP,EAAG,OAAOO,CAAI,CAAC,CAAC,QAASC,GAAWA,EAAQd,EAAG,QAAQG,EAAOU,CAAI,CAAC,EAAIF,EAAkBC,EAAW,KAAK,CAAC,CAAE,CAChH,EAGIG,EAAgBH,GACpBV,EAAaU,EAAW,QAASI,GAAMR,EAAcQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAEvDC,EAAiB,CAG5B,QAAUC,GACRP,EAAkBI,EAAaG,EAAQ,UAAU,CAAC,EAEpD,gBAAkBA,GAChBD,EAAe,QAAQC,CAAO,CAAC,CAAC,QAASJ,GACvCA,EAAM,SACEd,EAAG,KAAKD,EAAuBmB,EAAQ,UAAU,CAAC,EACvDC,GAASnB,EAAG,QAAQmB,CAAI,CAC3B,CACF,EAIF,WAAaD,GACXlB,EAAG,QAAQe,EAAaG,EAAQ,UAAU,CAAC,CAAC,QAAQ,EAAIC,GACtDb,EAAG,OAAOa,CAAI,CAAC,CAAC,IAAKL,GAAWA,EAAQ,CAACK,CAAI,EAAI,CAAC,CAAE,CACtD,CAAC,CAAC,IAAKC,GAAYlB,EAAakB,EAAQ,KAAK,CAAC,CAAC,EAIjD,YAAcF,GACZH,EAAaG,EAAQ,UAAU,CAAC,CAAC,KAAKZ,EAAG,UAAU,EAErD,oBAAsBY,GACLD,EAAe,YAAYC,CAC9B,CAAC,CAAC,SACNjB,EAAKF,EAAuBmB,EAAQ,UAAU,CAAC,EACpDR,GAAMN,EAAMM,CAAC,CAChB,EAGF,eAAiBQ,GACfH,EAAaG,EAAQ,UAAU,CAAC,CAAC,OAAOZ,EAAG,UAAU,CACzD,E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "functype-os",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Functional OS utilities using functype data structures — env vars, path expansion, file ops, platform detection",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"functype",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "^24.19.2",
|
|
30
30
|
"eslint-config-prettier": "^10.1.8",
|
|
31
|
-
"functype": "^2.
|
|
31
|
+
"functype": "^2.4.0",
|
|
32
32
|
"ts-builds": "^5.0.0",
|
|
33
33
|
"tsdown": "^0.23.7",
|
|
34
34
|
"vitest": "^5.1.0"
|