@sebspark/environment 0.0.2 → 0.0.3
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.
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +7 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -3
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";cAEa,eAAA,aAA6B,MAAA,uBAiCnC,CAAA;EAAM,QAAA,EAAU,OAAA,CAAQ,CAAA;AAAA;EAAA,CAAU,GAAA;AAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import assert from "node:assert";
|
|
2
|
-
|
|
3
2
|
//#region src/index.ts
|
|
4
3
|
const initEnvironment = () => {
|
|
5
4
|
const environmentCache = {};
|
|
6
5
|
return new Proxy({}, { get(_, k) {
|
|
7
6
|
const key = k;
|
|
8
|
-
if (key === "optional") return new Proxy({}, { get(_
|
|
9
|
-
const key
|
|
10
|
-
if (key
|
|
11
|
-
const { [key
|
|
12
|
-
environmentCache[key
|
|
13
|
-
return environmentCache[key
|
|
7
|
+
if (key === "optional") return new Proxy({}, { get(_, k) {
|
|
8
|
+
const key = k;
|
|
9
|
+
if (key in environmentCache) return environmentCache[key];
|
|
10
|
+
const { [key]: value } = process.env;
|
|
11
|
+
environmentCache[key] = value;
|
|
12
|
+
return environmentCache[key];
|
|
14
13
|
} });
|
|
15
14
|
if (key in environmentCache) return environmentCache[key];
|
|
16
15
|
const { [key]: value } = process.env;
|
|
@@ -19,7 +18,7 @@ const initEnvironment = () => {
|
|
|
19
18
|
return environmentCache[key];
|
|
20
19
|
} });
|
|
21
20
|
};
|
|
22
|
-
|
|
23
21
|
//#endregion
|
|
24
22
|
export { initEnvironment };
|
|
23
|
+
|
|
25
24
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import assert from 'node:assert'\n\nexport const initEnvironment = <T extends Record<string, string>>() => {\n const environmentCache: Record<string, string | undefined> = {}\n\n return new Proxy(\n {},\n {\n get(_, k: keyof T | 'optional' | string | symbol) {\n const key = k as string\n if (key === 'optional') {\n return new Proxy(\n {},\n {\n get(_, k: keyof T | string | symbol) {\n const key = k as string\n if (key in environmentCache) {\n return environmentCache[key]\n }\n const { [key]: value } = process.env\n environmentCache[key] = value\n return environmentCache[key]\n },\n }\n ) as T\n }\n if (key in environmentCache) {\n return environmentCache[key]\n }\n const { [key]: value } = process.env\n assert(value, `${key} is required`)\n environmentCache[key] = value\n return environmentCache[key]\n },\n }\n ) as T & { optional: Partial<T> } & { [key: string]: string }\n}\n"],"mappings":";;AAEA,MAAa,wBAA0D;CACrE,MAAM,mBAAuD,EAAE;AAE/D,QAAO,IAAI,MACT,EAAE,EACF,EACE,IAAI,GAAG,GAA2C;EAChD,MAAM,MAAM;AACZ,MAAI,QAAQ,WACV,QAAO,IAAI,MACT,EAAE,EACF,EACE,IAAI,GAAG,GAA8B;GACnC,MAAM,MAAM;AACZ,OAAI,OAAO,iBACT,QAAO,iBAAiB;GAE1B,MAAM,GAAG,MAAM,UAAU,QAAQ;AACjC,oBAAiB,OAAO;AACxB,UAAO,iBAAiB;KAE3B,CACF;AAEH,MAAI,OAAO,iBACT,QAAO,iBAAiB;EAE1B,MAAM,GAAG,MAAM,UAAU,QAAQ;AACjC,SAAO,OAAO,GAAG,IAAI,cAAc;AACnC,mBAAiB,OAAO;AACxB,SAAO,iBAAiB;IAE3B,CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sebspark/environment",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.mjs",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"test": "vitest run --passWithNoTests --coverage",
|
|
23
23
|
"typecheck": "vitest --typecheck.only --passWithNoTests"
|
|
24
24
|
},
|
|
25
|
-
"
|
|
26
|
-
"
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/seb-oss/Spark-packages.git"
|
|
27
28
|
}
|
|
28
29
|
}
|