@axi-engine/utils 0.2.2 → 0.2.4
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 +43 -3
- package/dist/index.d.ts +43 -3
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -127,11 +127,11 @@ declare function getRandomElement<T>(array: T[]): T | undefined;
|
|
|
127
127
|
|
|
128
128
|
/**
|
|
129
129
|
* Throws an error if the condition is true.
|
|
130
|
-
* @param
|
|
130
|
+
* @param condition - If true, an error will be thrown.
|
|
131
131
|
* @param exceptionMessage - The message for the error.
|
|
132
132
|
* @throws {Error} if the value is true
|
|
133
133
|
*/
|
|
134
|
-
declare function throwIf(
|
|
134
|
+
declare function throwIf(condition: boolean, exceptionMessage: string): asserts condition is false;
|
|
135
135
|
/**
|
|
136
136
|
* Throws an error if the value is null, undefined, or an empty array.
|
|
137
137
|
*
|
|
@@ -210,14 +210,54 @@ declare class ConstructorRegistry<T> {
|
|
|
210
210
|
*/
|
|
211
211
|
interface DataSource {
|
|
212
212
|
get(path: PathType): unknown;
|
|
213
|
+
/**
|
|
214
|
+
* Checks if a path valid.
|
|
215
|
+
* @param {PathType} path The path to the node.
|
|
216
|
+
* @returns {boolean} `true` if the node exists, otherwise `false`.
|
|
217
|
+
*/
|
|
213
218
|
has(path: PathType): boolean;
|
|
214
219
|
}
|
|
215
220
|
/**
|
|
216
|
-
* A write-only contract for any system that can accept data by path.
|
|
221
|
+
* A write-only contract for any system that can accept or mutate data by path.
|
|
222
|
+
*
|
|
223
|
+
* This interface is the counterpart to `DataSource` and represents the "write" side
|
|
224
|
+
* of a complete data storage system. It provides a standard set of methods for
|
|
225
|
+
* creating, updating, and deleting data, abstracting away the underlying
|
|
226
|
+
* implementation details.
|
|
227
|
+
*
|
|
228
|
+
* @interface
|
|
217
229
|
*/
|
|
218
230
|
interface DataSink {
|
|
231
|
+
/**
|
|
232
|
+
* Strictly updates the value at an *existing* path.
|
|
233
|
+
* This operation should typically fail or throw an error if no value exists at the path.
|
|
234
|
+
*
|
|
235
|
+
* @param path The path to the value to be updated.
|
|
236
|
+
* @param value The new value to set.
|
|
237
|
+
*/
|
|
219
238
|
set(path: PathType, value: unknown): void;
|
|
239
|
+
/**
|
|
240
|
+
* Strictly creates a new value at the specified path.
|
|
241
|
+
* This operation should typically fail or throw an error if a value already exists
|
|
242
|
+
* at the path.
|
|
243
|
+
*
|
|
244
|
+
* @param path The full path where the new value will be created.
|
|
245
|
+
* @param value The initial value to create.
|
|
246
|
+
*/
|
|
220
247
|
create(path: PathType, value: unknown): void;
|
|
248
|
+
/**
|
|
249
|
+
* Updates a value at a specified path if it exists, or creates it if it does not.
|
|
250
|
+
* This is a convenient and non-strict combination of the `set` and `create` operations.
|
|
251
|
+
*
|
|
252
|
+
* @param path The path to the value to be created or updated.
|
|
253
|
+
* @param value The value to set.
|
|
254
|
+
*/
|
|
255
|
+
upset(path: PathType, value: unknown): void;
|
|
256
|
+
/**
|
|
257
|
+
* Deletes the value at the specified path.
|
|
258
|
+
*
|
|
259
|
+
* @param path The path to the value to be deleted.
|
|
260
|
+
*/
|
|
221
261
|
delete(path: PathType): void;
|
|
222
262
|
}
|
|
223
263
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -127,11 +127,11 @@ declare function getRandomElement<T>(array: T[]): T | undefined;
|
|
|
127
127
|
|
|
128
128
|
/**
|
|
129
129
|
* Throws an error if the condition is true.
|
|
130
|
-
* @param
|
|
130
|
+
* @param condition - If true, an error will be thrown.
|
|
131
131
|
* @param exceptionMessage - The message for the error.
|
|
132
132
|
* @throws {Error} if the value is true
|
|
133
133
|
*/
|
|
134
|
-
declare function throwIf(
|
|
134
|
+
declare function throwIf(condition: boolean, exceptionMessage: string): asserts condition is false;
|
|
135
135
|
/**
|
|
136
136
|
* Throws an error if the value is null, undefined, or an empty array.
|
|
137
137
|
*
|
|
@@ -210,14 +210,54 @@ declare class ConstructorRegistry<T> {
|
|
|
210
210
|
*/
|
|
211
211
|
interface DataSource {
|
|
212
212
|
get(path: PathType): unknown;
|
|
213
|
+
/**
|
|
214
|
+
* Checks if a path valid.
|
|
215
|
+
* @param {PathType} path The path to the node.
|
|
216
|
+
* @returns {boolean} `true` if the node exists, otherwise `false`.
|
|
217
|
+
*/
|
|
213
218
|
has(path: PathType): boolean;
|
|
214
219
|
}
|
|
215
220
|
/**
|
|
216
|
-
* A write-only contract for any system that can accept data by path.
|
|
221
|
+
* A write-only contract for any system that can accept or mutate data by path.
|
|
222
|
+
*
|
|
223
|
+
* This interface is the counterpart to `DataSource` and represents the "write" side
|
|
224
|
+
* of a complete data storage system. It provides a standard set of methods for
|
|
225
|
+
* creating, updating, and deleting data, abstracting away the underlying
|
|
226
|
+
* implementation details.
|
|
227
|
+
*
|
|
228
|
+
* @interface
|
|
217
229
|
*/
|
|
218
230
|
interface DataSink {
|
|
231
|
+
/**
|
|
232
|
+
* Strictly updates the value at an *existing* path.
|
|
233
|
+
* This operation should typically fail or throw an error if no value exists at the path.
|
|
234
|
+
*
|
|
235
|
+
* @param path The path to the value to be updated.
|
|
236
|
+
* @param value The new value to set.
|
|
237
|
+
*/
|
|
219
238
|
set(path: PathType, value: unknown): void;
|
|
239
|
+
/**
|
|
240
|
+
* Strictly creates a new value at the specified path.
|
|
241
|
+
* This operation should typically fail or throw an error if a value already exists
|
|
242
|
+
* at the path.
|
|
243
|
+
*
|
|
244
|
+
* @param path The full path where the new value will be created.
|
|
245
|
+
* @param value The initial value to create.
|
|
246
|
+
*/
|
|
220
247
|
create(path: PathType, value: unknown): void;
|
|
248
|
+
/**
|
|
249
|
+
* Updates a value at a specified path if it exists, or creates it if it does not.
|
|
250
|
+
* This is a convenient and non-strict combination of the `set` and `create` operations.
|
|
251
|
+
*
|
|
252
|
+
* @param path The path to the value to be created or updated.
|
|
253
|
+
* @param value The value to set.
|
|
254
|
+
*/
|
|
255
|
+
upset(path: PathType, value: unknown): void;
|
|
256
|
+
/**
|
|
257
|
+
* Deletes the value at the specified path.
|
|
258
|
+
*
|
|
259
|
+
* @param path The path to the value to be deleted.
|
|
260
|
+
*/
|
|
221
261
|
delete(path: PathType): void;
|
|
222
262
|
}
|
|
223
263
|
/**
|
package/dist/index.js
CHANGED
|
@@ -126,8 +126,8 @@ function isPercentageString(val) {
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
// src/assertion.ts
|
|
129
|
-
function throwIf(
|
|
130
|
-
if (
|
|
129
|
+
function throwIf(condition, exceptionMessage) {
|
|
130
|
+
if (condition) {
|
|
131
131
|
throw new Error(exceptionMessage);
|
|
132
132
|
}
|
|
133
133
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -72,8 +72,8 @@ function isPercentageString(val) {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
// src/assertion.ts
|
|
75
|
-
function throwIf(
|
|
76
|
-
if (
|
|
75
|
+
function throwIf(condition, exceptionMessage) {
|
|
76
|
+
if (condition) {
|
|
77
77
|
throw new Error(exceptionMessage);
|
|
78
78
|
}
|
|
79
79
|
}
|
package/package.json
CHANGED