@plyaz/types 1.5.5 → 1.6.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.
@@ -779,3 +779,19 @@ export interface TrackedMockFunction<TArgs extends unknown[], TReturn> extends V
779
779
  /** Reset all tracked calls */
780
780
  resetCalls: () => void;
781
781
  }
782
+ /**
783
+ * Type for array assertion predicates with void support
784
+ */
785
+ export type ArrayPredicate<T> = (item: T, index?: number, array?: T[]) => boolean | void;
786
+ /**
787
+ * Enhanced object shape validation type
788
+ */
789
+ export type ObjectShape<T> = Partial<Record<keyof T, 'string' | 'number' | 'boolean' | 'object' | 'function' | 'undefined' | 'symbol'>>;
790
+ /**
791
+ * Pattern matching type for object assertions
792
+ */
793
+ export type ObjectPattern<T> = {
794
+ [K in keyof T]?: T[K] | RegExp | ((value: unknown) => boolean) | {
795
+ asymmetricMatch(value: unknown): boolean;
796
+ };
797
+ };
@@ -1243,12 +1243,27 @@ export interface WaitForChangeOptions<T> {
1243
1243
  * ```
1244
1244
  */
1245
1245
  export interface PerformanceMetrics {
1246
+ /** Minimum execution time (ms) */
1246
1247
  min: number;
1248
+ /** Maximum execution time (ms) */
1247
1249
  max: number;
1250
+ /** Operations per second */
1251
+ opsPerSecond: number;
1252
+ /** Mean execution time (ms) */
1248
1253
  mean: number;
1254
+ /** Median execution time (ms) */
1249
1255
  median: number;
1256
+ /** Standard deviation of execution times */
1257
+ stdDev: number;
1258
+ /** 95th percentile execution time (ms) */
1250
1259
  p95: number;
1260
+ /** 99th percentile execution time (ms) */
1251
1261
  p99: number;
1262
+ /**
1263
+ * Array of all duration measurements (ms)
1264
+ * @remarks This is actually an array of durations, not the count of runs
1265
+ * The naming is inconsistent but matches the current implementation
1266
+ */
1252
1267
  runs: number[];
1253
1268
  }
1254
1269
  /**
@@ -1300,7 +1315,33 @@ export interface MeasureTimeResult<T> {
1300
1315
  * ```
1301
1316
  */
1302
1317
  export interface BenchmarkResult {
1303
- [functionName: string]: PerformanceMetrics;
1318
+ /** Name of the benchmark suite */
1319
+ name: string;
1320
+ /**
1321
+ * Performance metrics for each benchmarked operation
1322
+ * @remarks Keys are the function names from the input functions object
1323
+ */
1324
+ operations: Record<string, PerformanceMetrics>;
1325
+ /**
1326
+ * Timestamp when benchmark was run
1327
+ * @optional
1328
+ */
1329
+ timestamp?: number;
1330
+ /**
1331
+ * Total duration of all benchmark runs (ms)
1332
+ * @optional
1333
+ */
1334
+ totalDuration?: number;
1335
+ /**
1336
+ * Comparison data between operations
1337
+ * @optional
1338
+ */
1339
+ comparison?: {
1340
+ fastest: string;
1341
+ slowest: string;
1342
+ /** Relative performance (fastest = 1.0) */
1343
+ relative: Record<string, number>;
1344
+ };
1304
1345
  }
1305
1346
  /**
1306
1347
  * Options for load testing.
@@ -1525,12 +1566,45 @@ export interface PerformanceComparisonInput<T> {
1525
1566
  * peak: 60 * 1024 * 1024 // 60MB peak
1526
1567
  * };
1527
1568
  * ```
1569
+ * @remarks
1570
+ * Added `used` and `heapUsed` properties for better compatibility
1571
+ * and clearer API. The `heapUsed` property provides compatibility
1572
+ * with Node.js memory usage conventions.
1528
1573
  */
1529
1574
  export interface MemoryMeasurement {
1575
+ /** Memory usage before operation (bytes) */
1530
1576
  before: number;
1577
+ /** Memory usage after operation (bytes) */
1531
1578
  after: number;
1579
+ /** Change in memory usage (after - before) in bytes */
1532
1580
  delta: number;
1581
+ /** Peak memory usage during operation (bytes) */
1533
1582
  peak: number;
1583
+ /**
1584
+ * Memory used by operation (bytes)
1585
+ * @remarks Alias for delta, provides clearer semantic meaning
1586
+ */
1587
+ used: number;
1588
+ /**
1589
+ * Heap memory used by operation (bytes)
1590
+ * @remarks Alias for delta, provides Node.js compatibility
1591
+ */
1592
+ heapUsed: number;
1593
+ /**
1594
+ * Total heap size (bytes)
1595
+ * @optional Additional memory information when available
1596
+ */
1597
+ heapTotal?: number;
1598
+ /**
1599
+ * External memory usage (bytes)
1600
+ * @optional V8 external memory when available
1601
+ */
1602
+ external?: number;
1603
+ /**
1604
+ * Resident set size (bytes)
1605
+ * @optional Total memory allocated for the process
1606
+ */
1607
+ rss?: number;
1534
1608
  }
1535
1609
  /**
1536
1610
  * Options for memory measurement during testing.
@@ -1549,8 +1623,27 @@ export interface MemoryMeasurement {
1549
1623
  * ```
1550
1624
  */
1551
1625
  export interface MeasureMemoryOptions {
1626
+ /**
1627
+ * Force garbage collection before measurement
1628
+ * @default false
1629
+ * @remarks Requires --expose-gc flag in Node.js
1630
+ */
1552
1631
  forceGC?: boolean;
1632
+ /**
1633
+ * Number of measurement runs to average
1634
+ * @default 1
1635
+ */
1553
1636
  runs?: number;
1637
+ /**
1638
+ * Run garbage collection between each measurement
1639
+ * @default false
1640
+ */
1641
+ gcBetweenRuns?: boolean;
1642
+ /**
1643
+ * Include detailed heap statistics
1644
+ * @default false
1645
+ */
1646
+ detailed?: boolean;
1554
1647
  }
1555
1648
  /**
1556
1649
  * Result from memory measurement testing.
@@ -2401,9 +2494,24 @@ export interface ImageLoaderProps {
2401
2494
  width: number;
2402
2495
  quality?: number;
2403
2496
  }
2497
+ /**
2498
+ * Global type augmentation for performance.memory
2499
+ *
2500
+ * @remarks
2501
+ * Extends the Performance interface to include memory property
2502
+ * available in Chrome and Node.js environments
2503
+ */
2404
2504
  export interface PerformanceMemory {
2505
+ /**
2506
+ * Performance object with memory property
2507
+ */
2405
2508
  memory?: {
2509
+ /** Used JS heap size in bytes */
2406
2510
  usedJSHeapSize: number;
2511
+ /** Total JS heap size in bytes */
2512
+ totalJSHeapSize: number;
2513
+ /** JS heap size limit in bytes */
2514
+ jsHeapSizeLimit: number;
2407
2515
  };
2408
2516
  }
2409
2517
  export interface NextPageResult {
@@ -3018,7 +3126,9 @@ export interface PerformanceEntryResult {
3018
3126
  * ```
3019
3127
  */
3020
3128
  export interface MemoryMeasurementResult<T> {
3129
+ /** Single measurement data */
3021
3130
  measurement: MemoryMeasurement;
3131
+ /** Function execution result */
3022
3132
  result: T;
3023
3133
  }
3024
3134
  /**
@@ -3034,6 +3144,10 @@ export interface MemoryMeasurementResult<T> {
3034
3144
  * ```
3035
3145
  */
3036
3146
  export interface GlobalWithGC {
3147
+ /**
3148
+ * Manual garbage collection trigger
3149
+ * @remarks Only available with --expose-gc flag
3150
+ */
3037
3151
  gc?: () => void;
3038
3152
  }
3039
3153
  /**
@@ -5755,3 +5869,67 @@ export interface AsyncHook {
5755
5869
  after?: (asyncId: number) => void;
5756
5870
  destroy?: (asyncId: number) => void;
5757
5871
  }
5872
+ /**
5873
+ * JSON parsing options for safe parsing
5874
+ */
5875
+ export interface JSONParseOptions {
5876
+ /**
5877
+ * Custom reviver function
5878
+ * @remarks Called after prototype pollution filtering
5879
+ */
5880
+ reviver?: (key: string, value: unknown) => unknown;
5881
+ /**
5882
+ * Allow parsing of Date strings
5883
+ * @default false
5884
+ */
5885
+ parseDates?: boolean;
5886
+ /**
5887
+ * Additional keys to filter out during parsing
5888
+ * @default []
5889
+ */
5890
+ filterKeys?: string[];
5891
+ }
5892
+ /**
5893
+ * JSON stringify options for safe stringification
5894
+ */
5895
+ export interface JSONStringifyOptions {
5896
+ /**
5897
+ * Indentation (number of spaces or string)
5898
+ */
5899
+ space?: string | number;
5900
+ /**
5901
+ * Custom replacer function
5902
+ */
5903
+ replacer?: (key: string, value: unknown) => unknown;
5904
+ /**
5905
+ * Custom circular reference placeholder
5906
+ * @default "[Circular]"
5907
+ */
5908
+ circularPlaceholder?: string;
5909
+ /**
5910
+ * Maximum depth for nested objects
5911
+ * @default Infinity
5912
+ */
5913
+ maxDepth?: number;
5914
+ }
5915
+ /**
5916
+ * JSON utilities interface
5917
+ */
5918
+ export interface JSONUtils {
5919
+ /**
5920
+ * Safely parse JSON with prototype pollution prevention
5921
+ */
5922
+ parse(json: string, options?: JSONParseOptions): unknown;
5923
+ /**
5924
+ * Safely stringify objects handling circular references
5925
+ */
5926
+ stringify(obj: unknown, options?: JSONStringifyOptions | string | number): string;
5927
+ /**
5928
+ * Check if a string is valid JSON
5929
+ */
5930
+ isValid?(json: string): boolean;
5931
+ /**
5932
+ * Deep clone an object using JSON
5933
+ */
5934
+ clone?<T>(obj: T): T;
5935
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plyaz/types",
3
- "version": "1.5.5",
3
+ "version": "1.6.0",
4
4
  "author": "Redeemer Pace",
5
5
  "license": "ISC",
6
6
  "description": "Provides shared TypeScript types and schema utilities for validation and parsing in the @playz ecosystem.",