@f5-sales-demo/pi-utils 21.13.0 → 21.13.2

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@f5-sales-demo/pi-utils",
4
- "version": "21.13.0",
4
+ "version": "21.13.2",
5
5
  "description": "Shared utilities for pi packages",
6
6
  "homepage": "https://github.com/f5-sales-demo/xcsh",
7
7
  "author": "Can Boluk",
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/bun": "^1.3",
42
- "@f5-sales-demo/pi-natives": "21.13.0"
42
+ "@f5-sales-demo/pi-natives": "21.13.2"
43
43
  },
44
44
  "engines": {
45
45
  "bun": ">=1.3.7"
package/src/env.ts CHANGED
@@ -83,6 +83,29 @@ export function $pickenv(...keys: string[]): string | undefined {
83
83
  return undefined;
84
84
  }
85
85
 
86
+ /**
87
+ * Read an environment variable by its exact, case-sensitive name.
88
+ *
89
+ * Windows exposes case-insensitive getters for `process.env`, but enumerating
90
+ * keys preserves their real casing. Only trust a lookup when the requested
91
+ * spelling is present in that enumeration. This prevents a literal config
92
+ * value such as `public` from resolving to Windows' built-in `PUBLIC` path.
93
+ *
94
+ * @param name Environment variable name to look up.
95
+ * @param env Environment source; defaults to `process.env`.
96
+ */
97
+ export function $envExact(
98
+ name: string,
99
+ env: Readonly<Record<string, string | undefined>> = process.env,
100
+ ): string | undefined {
101
+ const value = env[name];
102
+ if (value === undefined) return undefined;
103
+ for (const key in env) {
104
+ if (key === name) return value;
105
+ }
106
+ return undefined;
107
+ }
108
+
86
109
  /**
87
110
  * Parses a positive decimal integer from `$env[name]`.
88
111
  * Empty, invalid, NaN, zero, or negative values return `defaultValue`.
package/src/index.ts CHANGED
@@ -20,6 +20,7 @@ export {
20
20
  } from "./i18n";
21
21
  export * from "./json";
22
22
  export * as logger from "./logger";
23
+ export * from "./materialize-string";
23
24
  export * from "./mermaid-ascii";
24
25
  export * from "./mermaid-color";
25
26
  export * from "./mime";
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copy text into independent UTF-16 backing storage before a bounded substring
3
+ * outlives its source. The round trip preserves every JavaScript code unit,
4
+ * including lone surrogates that UTF-8 would replace.
5
+ */
6
+ export function materializeString(text: string): string {
7
+ if (text.length === 0) return "";
8
+ return Buffer.from(text, "utf16le").toString("utf16le");
9
+ }