@oh-my-pi/pi-utils 17.0.9 → 17.1.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,3 +1,5 @@
1
1
  export declare function isRecord(value: unknown): value is Record<string, unknown>;
2
+ /** Reads an own string-valued property without invoking accessors. */
3
+ export declare function stringProperty(value: object, key: string): string | undefined;
2
4
  export declare function asRecord(value: unknown): Record<string, unknown> | null;
3
5
  export declare function toError(value: unknown): Error;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@oh-my-pi/pi-utils",
4
- "version": "17.0.9",
4
+ "version": "17.1.0",
5
5
  "description": "Shared utilities for pi packages",
6
6
  "homepage": "https://omp.sh",
7
7
  "author": "Can Boluk",
@@ -31,7 +31,7 @@
31
31
  "fmt": "biome format --write ."
32
32
  },
33
33
  "dependencies": {
34
- "@oh-my-pi/pi-natives": "17.0.9",
34
+ "@oh-my-pi/pi-natives": "17.1.0",
35
35
  "handlebars": "^4.7.9",
36
36
  "winston": "^3.19.0",
37
37
  "winston-daily-rotate-file": "^5.0.0"
@@ -2,6 +2,12 @@ export function isRecord(value: unknown): value is Record<string, unknown> {
2
2
  return !!value && typeof value === "object" && !Array.isArray(value);
3
3
  }
4
4
 
5
+ /** Reads an own string-valued property without invoking accessors. */
6
+ export function stringProperty(value: object, key: string): string | undefined {
7
+ const field = Object.getOwnPropertyDescriptor(value, key)?.value;
8
+ return typeof field === "string" ? field : undefined;
9
+ }
10
+
5
11
  export function asRecord(value: unknown): Record<string, unknown> | null {
6
12
  return isRecord(value) ? value : null;
7
13
  }