@pawells/typescript-common 1.0.1 → 1.1.1

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.
Files changed (142) hide show
  1. package/README.md +177 -2
  2. package/build/array/array-chunk.d.ts +10 -4
  3. package/build/array/array-chunk.d.ts.map +1 -1
  4. package/build/array/array-chunk.js +10 -4
  5. package/build/array/array-chunk.js.map +1 -1
  6. package/build/array/array-contains.d.ts +11 -3
  7. package/build/array/array-contains.d.ts.map +1 -1
  8. package/build/array/array-contains.js +11 -3
  9. package/build/array/array-contains.js.map +1 -1
  10. package/build/array/array-group-by.d.ts +14 -5
  11. package/build/array/array-group-by.d.ts.map +1 -1
  12. package/build/array/array-group-by.js +14 -5
  13. package/build/array/array-group-by.js.map +1 -1
  14. package/build/array/array-shuffle.d.ts +12 -3
  15. package/build/array/array-shuffle.d.ts.map +1 -1
  16. package/build/array/array-shuffle.js +12 -3
  17. package/build/array/array-shuffle.js.map +1 -1
  18. package/build/array/assert.d.ts +115 -0
  19. package/build/array/assert.d.ts.map +1 -0
  20. package/build/array/assert.js +182 -0
  21. package/build/array/assert.js.map +1 -0
  22. package/build/array/index.d.ts +1 -0
  23. package/build/array/index.d.ts.map +1 -1
  24. package/build/array/index.js +1 -0
  25. package/build/array/index.js.map +1 -1
  26. package/build/array/unique.d.ts +13 -3
  27. package/build/array/unique.d.ts.map +1 -1
  28. package/build/array/unique.js +13 -3
  29. package/build/array/unique.js.map +1 -1
  30. package/build/asserts/errors.d.ts +129 -0
  31. package/build/asserts/errors.d.ts.map +1 -0
  32. package/build/asserts/errors.js +149 -0
  33. package/build/asserts/errors.js.map +1 -0
  34. package/build/asserts/generic.d.ts +436 -0
  35. package/build/asserts/generic.d.ts.map +1 -0
  36. package/build/asserts/generic.js +543 -0
  37. package/build/asserts/generic.js.map +1 -0
  38. package/build/asserts/index.d.ts +41 -0
  39. package/build/asserts/index.d.ts.map +1 -0
  40. package/build/asserts/index.js +41 -0
  41. package/build/asserts/index.js.map +1 -0
  42. package/build/asserts/internal-utils.d.ts +53 -0
  43. package/build/asserts/internal-utils.d.ts.map +1 -0
  44. package/build/asserts/internal-utils.js +108 -0
  45. package/build/asserts/internal-utils.js.map +1 -0
  46. package/build/asserts/types.d.ts +180 -0
  47. package/build/asserts/types.d.ts.map +1 -0
  48. package/build/asserts/types.js +2 -0
  49. package/build/asserts/types.js.map +1 -0
  50. package/build/asserts/utils.d.ts +92 -0
  51. package/build/asserts/utils.d.ts.map +1 -0
  52. package/build/asserts/utils.js +103 -0
  53. package/build/asserts/utils.js.map +1 -0
  54. package/build/boolean/assert.d.ts +66 -0
  55. package/build/boolean/assert.d.ts.map +1 -0
  56. package/build/boolean/assert.js +76 -0
  57. package/build/boolean/assert.js.map +1 -0
  58. package/build/boolean/index.d.ts +9 -0
  59. package/build/boolean/index.d.ts.map +1 -0
  60. package/build/boolean/index.js +9 -0
  61. package/build/boolean/index.js.map +1 -0
  62. package/build/enum/enum-entries.d.ts +8 -3
  63. package/build/enum/enum-entries.d.ts.map +1 -1
  64. package/build/enum/enum-entries.js +8 -3
  65. package/build/enum/enum-entries.js.map +1 -1
  66. package/build/enum/enum-key-by-value.d.ts +10 -5
  67. package/build/enum/enum-key-by-value.d.ts.map +1 -1
  68. package/build/enum/enum-key-by-value.js +10 -5
  69. package/build/enum/enum-key-by-value.js.map +1 -1
  70. package/build/enum/enum-keys.d.ts +12 -3
  71. package/build/enum/enum-keys.d.ts.map +1 -1
  72. package/build/enum/enum-keys.js +12 -3
  73. package/build/enum/enum-keys.js.map +1 -1
  74. package/build/enum/enum-safe-value.d.ts +11 -6
  75. package/build/enum/enum-safe-value.d.ts.map +1 -1
  76. package/build/enum/enum-safe-value.js +11 -6
  77. package/build/enum/enum-safe-value.js.map +1 -1
  78. package/build/enum/validate-enum-value.d.ts +10 -5
  79. package/build/enum/validate-enum-value.d.ts.map +1 -1
  80. package/build/enum/validate-enum-value.js +10 -5
  81. package/build/enum/validate-enum-value.js.map +1 -1
  82. package/build/index.d.ts +5 -0
  83. package/build/index.d.ts.map +1 -1
  84. package/build/index.js +12 -0
  85. package/build/index.js.map +1 -1
  86. package/build/number/assert.d.ts +154 -0
  87. package/build/number/assert.d.ts.map +1 -0
  88. package/build/number/assert.js +153 -0
  89. package/build/number/assert.js.map +1 -0
  90. package/build/number/index.d.ts +9 -0
  91. package/build/number/index.d.ts.map +1 -0
  92. package/build/number/index.js +9 -0
  93. package/build/number/index.js.map +1 -0
  94. package/build/object/assert.d.ts +138 -0
  95. package/build/object/assert.d.ts.map +1 -0
  96. package/build/object/assert.js +204 -0
  97. package/build/object/assert.js.map +1 -0
  98. package/build/object/clone.d.ts +17 -6
  99. package/build/object/clone.d.ts.map +1 -1
  100. package/build/object/clone.js +17 -6
  101. package/build/object/clone.js.map +1 -1
  102. package/build/object/filter-cached.d.ts +15 -3
  103. package/build/object/filter-cached.d.ts.map +1 -1
  104. package/build/object/filter-cached.js +15 -3
  105. package/build/object/filter-cached.js.map +1 -1
  106. package/build/object/has-circular-reference.d.ts +12 -3
  107. package/build/object/has-circular-reference.d.ts.map +1 -1
  108. package/build/object/has-circular-reference.js +12 -3
  109. package/build/object/has-circular-reference.js.map +1 -1
  110. package/build/object/index.d.ts +1 -0
  111. package/build/object/index.d.ts.map +1 -1
  112. package/build/object/index.js +1 -0
  113. package/build/object/index.js.map +1 -1
  114. package/build/object/key-value-pairs.d.ts +11 -3
  115. package/build/object/key-value-pairs.d.ts.map +1 -1
  116. package/build/object/key-value-pairs.js +11 -3
  117. package/build/object/key-value-pairs.js.map +1 -1
  118. package/build/object/map-cached.d.ts +14 -3
  119. package/build/object/map-cached.d.ts.map +1 -1
  120. package/build/object/map-cached.js +14 -3
  121. package/build/object/map-cached.js.map +1 -1
  122. package/build/object/merge.d.ts +18 -7
  123. package/build/object/merge.d.ts.map +1 -1
  124. package/build/object/merge.js +18 -7
  125. package/build/object/merge.js.map +1 -1
  126. package/build/object/omit.d.ts +13 -4
  127. package/build/object/omit.d.ts.map +1 -1
  128. package/build/object/omit.js +13 -4
  129. package/build/object/omit.js.map +1 -1
  130. package/build/string/assert.d.ts +100 -0
  131. package/build/string/assert.d.ts.map +1 -0
  132. package/build/string/assert.js +185 -0
  133. package/build/string/assert.js.map +1 -0
  134. package/build/string/formatting.d.ts +10 -3
  135. package/build/string/formatting.d.ts.map +1 -1
  136. package/build/string/formatting.js +10 -3
  137. package/build/string/formatting.js.map +1 -1
  138. package/build/string/index.d.ts +1 -0
  139. package/build/string/index.d.ts.map +1 -1
  140. package/build/string/index.js +1 -0
  141. package/build/string/index.js.map +1 -1
  142. package/package.json +1 -1
@@ -0,0 +1,182 @@
1
+ import { SetExceptionClass, SetExceptionMessage, ThrowException } from '../asserts/utils.js';
2
+ /**
3
+ * Error thrown when a value is not a valid array or fails an array assertion.
4
+ *
5
+ * @example
6
+ * throw new ArrayError('Value is not a valid array');
7
+ */
8
+ export class ArrayError extends Error {
9
+ constructor(message) {
10
+ super(message ?? 'Array assertion failed');
11
+ this.name = 'ArrayError';
12
+ Object.setPrototypeOf(this, ArrayError.prototype);
13
+ }
14
+ }
15
+ /**
16
+ * Asserts that a value is an array, optionally validating its size.
17
+ * @template T The type of array elements.
18
+ * @param value The value to validate.
19
+ * @param args Optional size constraints.
20
+ * @param exception Optional custom exception to throw.
21
+ * @throws {ArrayError} If the value is not an array or fails size validation.
22
+ */
23
+ export function AssertArray(value, args, exceptionInput = {}) {
24
+ // Initialize exception configuration with defaults
25
+ const exception = exceptionInput ?? {};
26
+ SetExceptionClass(exception, ArrayError);
27
+ // Validate that the value is an array
28
+ if (!Array.isArray(value)) {
29
+ SetExceptionMessage(exception, `Expected array but received ${typeof value}: ${String(value)}`);
30
+ ThrowException(exception);
31
+ }
32
+ // Type cast is safe after array validation
33
+ const array = value;
34
+ // Validate exact size constraint if specified
35
+ if (args?.size !== undefined && array.length !== args.size) {
36
+ SetExceptionMessage(exception, `Expected array with size ${args.size} but received size ${array.length}`);
37
+ ThrowException(exception);
38
+ }
39
+ // Validate minimum size constraint if specified
40
+ if (args?.minSize !== undefined && array.length < args.minSize) {
41
+ SetExceptionMessage(exception, `Expected array with minimum size ${args.minSize} but received size ${array.length}`);
42
+ ThrowException(exception);
43
+ }
44
+ // Validate maximum size constraint if specified
45
+ if (args?.maxSize !== undefined && array.length > args.maxSize) {
46
+ SetExceptionMessage(exception, `Expected array with maximum size ${args.maxSize} but received size ${array.length}`);
47
+ ThrowException(exception);
48
+ }
49
+ }
50
+ /**
51
+ * Asserts that a value is a 2D array, optionally validating its dimensions.
52
+ * @template T The type of array elements.
53
+ * @param value The value to validate.
54
+ * @param args Optional dimension constraints.
55
+ * @param exception Optional custom exception to throw.
56
+ * @throws {ArrayError} If the value is not a 2D array or fails dimension validation.
57
+ */
58
+ export function AssertArray2D(value, args = {}, exception = {}) {
59
+ // Initialize exception configuration with defaults
60
+ SetExceptionClass(exception, ArrayError);
61
+ // Validate that the value is an array
62
+ if (!Array.isArray(value)) {
63
+ SetExceptionMessage(exception, `Expected array but received ${typeof value}: ${String(value)}`);
64
+ ThrowException(exception);
65
+ }
66
+ // Type cast is safe after array validation
67
+ const array = value;
68
+ // Validate that all elements are arrays (making it 2D)
69
+ if (!array.every((row) => Array.isArray(row))) {
70
+ let invalidPositions = array.map((row, idx) => {
71
+ if (!Array.isArray(row))
72
+ return idx;
73
+ return null;
74
+ });
75
+ invalidPositions = invalidPositions.filter((idx) => idx !== null);
76
+ SetExceptionMessage(exception, `Expected 2D array but found non-array elements at positions: ${invalidPositions.join(', ')}`);
77
+ ThrowException(exception);
78
+ }
79
+ // Type cast is safe after 2D validation
80
+ const array2d = array;
81
+ const rows = array2d.length;
82
+ const [firstRow] = array2d;
83
+ const columns = firstRow ? firstRow.length : 0;
84
+ // Validate rectangular matrix structure (all rows have same column count)
85
+ if (!array2d.every((row) => row.length === columns)) {
86
+ SetExceptionMessage(exception, 'Array is not rectangular - rows have different column counts');
87
+ ThrowException(exception);
88
+ }
89
+ // Validate exact row count constraint if specified
90
+ if (args?.rows !== undefined && rows !== args.rows) {
91
+ SetExceptionMessage(exception, `Array has ${rows} rows, expected exactly ${args.rows}`);
92
+ ThrowException(exception);
93
+ }
94
+ // Validate exact column count constraint if specified
95
+ if (args?.columns !== undefined && columns !== args.columns) {
96
+ SetExceptionMessage(exception, `Array has ${columns} columns, expected exactly ${args.columns}`);
97
+ ThrowException(exception);
98
+ }
99
+ // Validate minimum row count constraint if specified
100
+ if (args?.minRows !== undefined && rows < args.minRows) {
101
+ SetExceptionMessage(exception, `Array has ${rows} rows, minimum required is ${args.minRows}`);
102
+ ThrowException(exception);
103
+ }
104
+ // Validate maximum row count constraint if specified
105
+ if (args?.maxRows !== undefined && rows > args.maxRows) {
106
+ SetExceptionMessage(exception, `Array has ${rows} rows, maximum allowed is ${args.maxRows}`);
107
+ ThrowException(exception);
108
+ }
109
+ // Validate minimum column count constraint if specified
110
+ if (args?.minColumns !== undefined && columns < args.minColumns) {
111
+ SetExceptionMessage(exception, `Array has ${columns} columns, minimum required is ${args.minColumns}`);
112
+ ThrowException(exception);
113
+ }
114
+ // Validate maximum column count constraint if specified
115
+ if (args?.maxColumns !== undefined && columns > args.maxColumns) {
116
+ SetExceptionMessage(exception, `Array has ${columns} columns, maximum allowed is ${args.maxColumns}`);
117
+ ThrowException(exception);
118
+ }
119
+ }
120
+ /**
121
+ * Asserts that an array is not empty.
122
+ * @template T The type of array elements.
123
+ * @param value The array to validate.
124
+ * @param exception Optional custom exception to throw.
125
+ * @throws {ArrayError} If the array is empty.
126
+ */
127
+ export function AssertArrayNotEmpty(value, exception = {}) {
128
+ // Initialize exception configuration with defaults
129
+ SetExceptionClass(exception, ArrayError);
130
+ // First validate that it's an array using the base AssertArray function
131
+ AssertArray(value, undefined, exception);
132
+ // Then check if the array is empty
133
+ if (value.length === 0) {
134
+ SetExceptionMessage(exception, 'Array should not be empty');
135
+ ThrowException(exception);
136
+ }
137
+ }
138
+ /**
139
+ * Asserts that all elements in an array satisfy a predicate.
140
+ * @template T The type of array elements.
141
+ * @param array The array to validate.
142
+ * @param predicate A function to test each element.
143
+ * @param exception Optional custom exception to throw.
144
+ * @throws {ArrayError} If any element fails the predicate test.
145
+ */
146
+ export function AssertArrayAll(array, predicate, exception = {}) {
147
+ // Initialize exception configuration with defaults
148
+ SetExceptionClass(exception, ArrayError);
149
+ // Validate that the value is an array
150
+ if (!Array.isArray(array)) {
151
+ SetExceptionMessage(exception, 'Value is not an array');
152
+ ThrowException(exception);
153
+ }
154
+ // Check if all elements satisfy the predicate
155
+ if (!array.every(predicate)) {
156
+ SetExceptionMessage(exception, 'Not all elements satisfy the predicate condition');
157
+ ThrowException(exception);
158
+ }
159
+ }
160
+ /**
161
+ * Asserts that at least one element in an array satisfies a predicate.
162
+ * @template T The type of array elements.
163
+ * @param array The array to validate.
164
+ * @param predicate A function to test each element.
165
+ * @param exception Optional custom exception to throw.
166
+ * @throws {ArrayError} If no elements pass the predicate test.
167
+ */
168
+ export function AssertArrayAny(array, predicate, exception = {}) {
169
+ // Initialize exception configuration with defaults
170
+ SetExceptionClass(exception, ArrayError);
171
+ // Validate that the value is an array
172
+ if (!Array.isArray(array)) {
173
+ SetExceptionMessage(exception, 'Value is not an array');
174
+ ThrowException(exception);
175
+ }
176
+ // Check if any elements satisfy the predicate
177
+ if (!array.some(predicate)) {
178
+ SetExceptionMessage(exception, 'No elements satisfy the predicate condition');
179
+ ThrowException(exception);
180
+ }
181
+ }
182
+ //# sourceMappingURL=assert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert.js","sourceRoot":"","sources":["../../src/array/assert.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AA4B7F;;;;;GAKG;AACH,MAAM,OAAO,UAAW,SAAQ,KAAK;IACpC,YAAY,OAAgB;QAC3B,KAAK,CAAC,OAAO,IAAI,wBAAwB,CAAC,CAAC;QAC3C,IAAI,CAAC,IAA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D,iBAAiB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAEzC,sCAAsC;IACtC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,mBAAmB,CAAC,SAAS,EAAE,uBAAuB,CAAC,CAAC;QACxD,cAAc,CAAC,SAAS,CAAC,CAAC;IAC3B,CAAC;IAED,8CAA8C;IAC9C,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;QAC7B,mBAAmB,CAAC,SAAS,EAAE,kDAAkD,CAAC,CAAC;QACnF,cAAc,CAAC,SAAS,CAAC,CAAC;IAC3B,CAAC;AACF,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAAI,KAAU,EAAE,SAAoD,EAAE,YAA8B,EAAE;IACnI,mDAAmD;IACnD,iBAAiB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAEzC,sCAAsC;IACtC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,mBAAmB,CAAC,SAAS,EAAE,uBAAuB,CAAC,CAAC;QACxD,cAAc,CAAC,SAAS,CAAC,CAAC;IAC3B,CAAC;IAED,8CAA8C;IAC9C,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;QAC5B,mBAAmB,CAAC,SAAS,EAAE,6CAA6C,CAAC,CAAC;QAC9E,cAAc,CAAC,SAAS,CAAC,CAAC;IAC3B,CAAC;AACF,CAAC"}
@@ -24,4 +24,5 @@ export * from './array-count-by.js';
24
24
  export * from './array-sample.js';
25
25
  export type * from './array-element.js';
26
26
  export type { TPredicate, TTransform, TComparator, TEqualityComparator } from './types.js';
27
+ export * from './assert.js';
27
28
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/array/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,mBAAmB,oBAAoB,CAAC;AACxC,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/array/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,mBAAmB,oBAAoB,CAAC;AACxC,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC3F,cAAc,aAAa,CAAC"}
@@ -22,4 +22,5 @@ export * from './array-range.js';
22
22
  export * from './array-sort-by.js';
23
23
  export * from './array-count-by.js';
24
24
  export * from './array-sample.js';
25
+ export * from './assert.js';
25
26
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/array/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/array/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAGlC,cAAc,aAAa,CAAC"}
@@ -1,8 +1,18 @@
1
1
  /**
2
2
  * Returns a new array with duplicate values removed.
3
- * @param array The input array.
4
- * @returns A new array with unique values.
5
- * @note Uses reference equality for objects. Two distinct objects with identical property values are NOT deduplicated.
3
+ *
4
+ * @template T - The type of array elements
5
+ * @param array - The input array
6
+ * @returns A new array containing only unique values (preserves first occurrence order)
7
+ *
8
+ * @remarks Uses reference equality for objects. Two distinct objects with
9
+ * identical property values are **not** considered equal and will both be kept.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * Unique([1, 2, 2, 3, 1]); // [1, 2, 3]
14
+ * Unique(['a', 'b', 'a']); // ['a', 'b']
15
+ * ```
6
16
  */
7
17
  export declare function Unique<T>(array: T[]): T[];
8
18
  //# sourceMappingURL=unique.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"unique.d.ts","sourceRoot":"","sources":["../../src/array/unique.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAMzC"}
1
+ {"version":3,"file":"unique.d.ts","sourceRoot":"","sources":["../../src/array/unique.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAMzC"}
@@ -1,8 +1,18 @@
1
1
  /**
2
2
  * Returns a new array with duplicate values removed.
3
- * @param array The input array.
4
- * @returns A new array with unique values.
5
- * @note Uses reference equality for objects. Two distinct objects with identical property values are NOT deduplicated.
3
+ *
4
+ * @template T - The type of array elements
5
+ * @param array - The input array
6
+ * @returns A new array containing only unique values (preserves first occurrence order)
7
+ *
8
+ * @remarks Uses reference equality for objects. Two distinct objects with
9
+ * identical property values are **not** considered equal and will both be kept.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * Unique([1, 2, 2, 3, 1]); // [1, 2, 3]
14
+ * Unique(['a', 'b', 'a']); // ['a', 'b']
15
+ * ```
6
16
  */
7
17
  export function Unique(array) {
8
18
  if (!array) {
@@ -1 +1 @@
1
- {"version":3,"file":"unique.js","sourceRoot":"","sources":["../../src/array/unique.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAI,KAAU;IACnC,IAAI,CAAC,KAAK,EAAE,CAAC;QACZ,OAAO,EAAE,CAAC;IACX,CAAC;IAED,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;AAC5B,CAAC"}
1
+ {"version":3,"file":"unique.js","sourceRoot":"","sources":["../../src/array/unique.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,MAAM,CAAI,KAAU;IACnC,IAAI,CAAC,KAAK,EAAE,CAAC;QACZ,OAAO,EAAE,CAAC;IACX,CAAC;IAED,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,129 @@
1
+ /**
2
+ * Base error class for all custom errors in the assertion library.
3
+ *
4
+ * Extends the built-in `Error` with a machine-readable `Code` string and an
5
+ * optional `Context` bag for structured diagnostic metadata. All other error
6
+ * classes in this module extend `BaseError`.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * class MyError extends BaseError {
11
+ * constructor(message: string) {
12
+ * super(message, 'MY_ERROR');
13
+ * }
14
+ * }
15
+ * throw new MyError('Something went wrong');
16
+ * ```
17
+ */
18
+ export declare class BaseError extends Error {
19
+ readonly Code: string;
20
+ readonly Context: Record<string, unknown> | undefined;
21
+ /**
22
+ * @param message - Human-readable description of the error
23
+ * @param code - Machine-readable error code (e.g. `'VALIDATION_ERROR'`)
24
+ * @param context - Optional structured metadata for diagnostics
25
+ */
26
+ constructor(message: string, code: string, context?: Record<string, unknown>);
27
+ }
28
+ /**
29
+ * Error thrown when input data fails a validation rule.
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * throw new ValidationError('Email address is not valid', { field: 'email' });
34
+ * ```
35
+ */
36
+ export declare class ValidationError extends BaseError {
37
+ /**
38
+ * @param message - Description of the validation failure
39
+ * @param context - Optional structured metadata for diagnostics
40
+ */
41
+ constructor(message: string, context?: Record<string, unknown>);
42
+ }
43
+ /**
44
+ * Error thrown when a runtime type assertion fails.
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * throw new AssertionError('Expected string but received number');
49
+ * ```
50
+ */
51
+ export declare class AssertionError extends BaseError {
52
+ /**
53
+ * @param message - Description of the failed assertion
54
+ * @param context - Optional structured metadata for diagnostics
55
+ */
56
+ constructor(message: string, context?: Record<string, unknown>);
57
+ }
58
+ /**
59
+ * Error thrown when a function argument is invalid.
60
+ * The error message is auto-formatted as
61
+ * `"Invalid argument '<argumentName>': <reason>"`.
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * throw new InvalidArgumentError('userId', 'must be a positive integer');
66
+ * // message: "Invalid argument 'userId': must be a positive integer"
67
+ * ```
68
+ */
69
+ export declare class InvalidArgumentError extends BaseError {
70
+ /**
71
+ * @param argumentName - Name of the invalid argument
72
+ * @param reason - Explanation of why the argument is invalid
73
+ * @param context - Optional structured metadata for diagnostics
74
+ */
75
+ constructor(argumentName: string, reason: string, context?: Record<string, unknown>);
76
+ }
77
+ /**
78
+ * Error thrown when a requested operation is not supported in the current context.
79
+ * The error message is auto-formatted as `"Operation not supported: <operation>"`.
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * throw new NotSupportedError('bulk delete in read-only mode');
84
+ * // message: "Operation not supported: bulk delete in read-only mode"
85
+ * ```
86
+ */
87
+ export declare class NotSupportedError extends BaseError {
88
+ /**
89
+ * @param operation - Description of the unsupported operation
90
+ * @param context - Optional structured metadata for diagnostics
91
+ */
92
+ constructor(operation: string, context?: Record<string, unknown>);
93
+ }
94
+ /**
95
+ * Error thrown when a required resource or value cannot be found.
96
+ * The error message is auto-formatted as `"Not found: <item>"`.
97
+ *
98
+ * @example
99
+ * ```typescript
100
+ * throw new NotFoundError('user with id 42');
101
+ * // message: "Not found: user with id 42"
102
+ * ```
103
+ */
104
+ export declare class NotFoundError extends BaseError {
105
+ /**
106
+ * @param item - Description of the resource that was not found
107
+ * @param context - Optional structured metadata for diagnostics
108
+ */
109
+ constructor(item: string, context?: Record<string, unknown>);
110
+ }
111
+ /**
112
+ * Error thrown when a buffer or collection exceeds its maximum capacity.
113
+ * The error message is auto-formatted as
114
+ * `"Buffer overflow: maximum size <maxSize> exceeded"`.
115
+ *
116
+ * @example
117
+ * ```typescript
118
+ * throw new BufferOverflowError(1000);
119
+ * // message: "Buffer overflow: maximum size 1000 exceeded"
120
+ * ```
121
+ */
122
+ export declare class BufferOverflowError extends BaseError {
123
+ /**
124
+ * @param maxSize - The maximum capacity that was exceeded
125
+ * @param context - Optional structured metadata for diagnostics
126
+ */
127
+ constructor(maxSize: number, context?: Record<string, unknown>);
128
+ }
129
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/asserts/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,SAAU,SAAQ,KAAK;IACnC,SAAgB,IAAI,EAAE,MAAM,CAAC;IAE7B,SAAgB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAE7D;;;;OAIG;gBACS,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAS5E;AAED;;;;;;;GAOG;AACH,qBAAa,eAAgB,SAAQ,SAAS;IAC7C;;;OAGG;gBACS,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAG9D;AAED;;;;;;;GAOG;AACH,qBAAa,cAAe,SAAQ,SAAS;IAC5C;;;OAGG;gBACS,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAG9D;AAED;;;;;;;;;;GAUG;AACH,qBAAa,oBAAqB,SAAQ,SAAS;IAClD;;;;OAIG;gBACS,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAGnF;AAED;;;;;;;;;GASG;AACH,qBAAa,iBAAkB,SAAQ,SAAS;IAC/C;;;OAGG;gBACS,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAGhE;AAED;;;;;;;;;GASG;AACH,qBAAa,aAAc,SAAQ,SAAS;IAC3C;;;OAGG;gBACS,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAG3D;AAED;;;;;;;;;;GAUG;AACH,qBAAa,mBAAoB,SAAQ,SAAS;IACjD;;;OAGG;gBACS,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAG9D"}
@@ -0,0 +1,149 @@
1
+ /**
2
+ * Base error class for all custom errors in the assertion library.
3
+ *
4
+ * Extends the built-in `Error` with a machine-readable `Code` string and an
5
+ * optional `Context` bag for structured diagnostic metadata. All other error
6
+ * classes in this module extend `BaseError`.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * class MyError extends BaseError {
11
+ * constructor(message: string) {
12
+ * super(message, 'MY_ERROR');
13
+ * }
14
+ * }
15
+ * throw new MyError('Something went wrong');
16
+ * ```
17
+ */
18
+ export class BaseError extends Error {
19
+ Code;
20
+ Context;
21
+ /**
22
+ * @param message - Human-readable description of the error
23
+ * @param code - Machine-readable error code (e.g. `'VALIDATION_ERROR'`)
24
+ * @param context - Optional structured metadata for diagnostics
25
+ */
26
+ constructor(message, code, context) {
27
+ super(message);
28
+ this.name = this.constructor.name;
29
+ this.Code = code;
30
+ this.Context = context;
31
+ if (typeof Error.captureStackTrace === 'function') {
32
+ Error.captureStackTrace(this, this.constructor);
33
+ }
34
+ }
35
+ }
36
+ /**
37
+ * Error thrown when input data fails a validation rule.
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * throw new ValidationError('Email address is not valid', { field: 'email' });
42
+ * ```
43
+ */
44
+ export class ValidationError extends BaseError {
45
+ /**
46
+ * @param message - Description of the validation failure
47
+ * @param context - Optional structured metadata for diagnostics
48
+ */
49
+ constructor(message, context) {
50
+ super(message, 'VALIDATION_ERROR', context);
51
+ }
52
+ }
53
+ /**
54
+ * Error thrown when a runtime type assertion fails.
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * throw new AssertionError('Expected string but received number');
59
+ * ```
60
+ */
61
+ export class AssertionError extends BaseError {
62
+ /**
63
+ * @param message - Description of the failed assertion
64
+ * @param context - Optional structured metadata for diagnostics
65
+ */
66
+ constructor(message, context) {
67
+ super(message, 'ASSERTION_ERROR', context);
68
+ }
69
+ }
70
+ /**
71
+ * Error thrown when a function argument is invalid.
72
+ * The error message is auto-formatted as
73
+ * `"Invalid argument '<argumentName>': <reason>"`.
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * throw new InvalidArgumentError('userId', 'must be a positive integer');
78
+ * // message: "Invalid argument 'userId': must be a positive integer"
79
+ * ```
80
+ */
81
+ export class InvalidArgumentError extends BaseError {
82
+ /**
83
+ * @param argumentName - Name of the invalid argument
84
+ * @param reason - Explanation of why the argument is invalid
85
+ * @param context - Optional structured metadata for diagnostics
86
+ */
87
+ constructor(argumentName, reason, context) {
88
+ super(`Invalid argument '${argumentName}': ${reason}`, 'INVALID_ARGUMENT', context);
89
+ }
90
+ }
91
+ /**
92
+ * Error thrown when a requested operation is not supported in the current context.
93
+ * The error message is auto-formatted as `"Operation not supported: <operation>"`.
94
+ *
95
+ * @example
96
+ * ```typescript
97
+ * throw new NotSupportedError('bulk delete in read-only mode');
98
+ * // message: "Operation not supported: bulk delete in read-only mode"
99
+ * ```
100
+ */
101
+ export class NotSupportedError extends BaseError {
102
+ /**
103
+ * @param operation - Description of the unsupported operation
104
+ * @param context - Optional structured metadata for diagnostics
105
+ */
106
+ constructor(operation, context) {
107
+ super(`Operation not supported: ${operation}`, 'NOT_SUPPORTED', context);
108
+ }
109
+ }
110
+ /**
111
+ * Error thrown when a required resource or value cannot be found.
112
+ * The error message is auto-formatted as `"Not found: <item>"`.
113
+ *
114
+ * @example
115
+ * ```typescript
116
+ * throw new NotFoundError('user with id 42');
117
+ * // message: "Not found: user with id 42"
118
+ * ```
119
+ */
120
+ export class NotFoundError extends BaseError {
121
+ /**
122
+ * @param item - Description of the resource that was not found
123
+ * @param context - Optional structured metadata for diagnostics
124
+ */
125
+ constructor(item, context) {
126
+ super(`Not found: ${item}`, 'NOT_FOUND', context);
127
+ }
128
+ }
129
+ /**
130
+ * Error thrown when a buffer or collection exceeds its maximum capacity.
131
+ * The error message is auto-formatted as
132
+ * `"Buffer overflow: maximum size <maxSize> exceeded"`.
133
+ *
134
+ * @example
135
+ * ```typescript
136
+ * throw new BufferOverflowError(1000);
137
+ * // message: "Buffer overflow: maximum size 1000 exceeded"
138
+ * ```
139
+ */
140
+ export class BufferOverflowError extends BaseError {
141
+ /**
142
+ * @param maxSize - The maximum capacity that was exceeded
143
+ * @param context - Optional structured metadata for diagnostics
144
+ */
145
+ constructor(maxSize, context) {
146
+ super(`Buffer overflow: maximum size ${maxSize} exceeded`, 'BUFFER_OVERFLOW', context);
147
+ }
148
+ }
149
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/asserts/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK;IACnB,IAAI,CAAS;IAEb,OAAO,CAAsC;IAE7D;;;;OAIG;IACH,YAAY,OAAe,EAAE,IAAY,EAAE,OAAiC;QAC3E,KAAK,CAAC,O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