@milaboratories/pl-model-common 1.16.2 → 1.16.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/drivers/pframe/data_info.d.ts +6 -0
- package/dist/drivers/pframe/data_info.d.ts.map +1 -1
- package/dist/errors.d.ts +4 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +216 -188
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/drivers/pframe/data_info.ts +31 -0
- package/src/errors.ts +8 -0
package/package.json
CHANGED
|
@@ -189,6 +189,37 @@ export function mapDataInfo<B1, B2>(
|
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
+
/**
|
|
193
|
+
* @param dataInfo - The source DataInfo object
|
|
194
|
+
* @param cb - Callback, function that have access to every blob to visit them all
|
|
195
|
+
* @returns Nothing
|
|
196
|
+
*/
|
|
197
|
+
export function visitDataInfo<B>(
|
|
198
|
+
dataInfo: DataInfo<B>,
|
|
199
|
+
cb: (blob: B) => void,
|
|
200
|
+
): void {
|
|
201
|
+
switch (dataInfo.type) {
|
|
202
|
+
case 'Json':
|
|
203
|
+
// Json type doesn't contain blobs, so return as is
|
|
204
|
+
break;
|
|
205
|
+
case 'JsonPartitioned': {
|
|
206
|
+
// Visit each blob in parts
|
|
207
|
+
for (const [_, blob] of Object.entries(dataInfo.parts)) {
|
|
208
|
+
cb(blob);
|
|
209
|
+
}
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
case 'BinaryPartitioned': {
|
|
213
|
+
// Visit each index and values blob in parts
|
|
214
|
+
for (const [_, chunk] of Object.entries(dataInfo.parts)) {
|
|
215
|
+
cb(chunk.index);
|
|
216
|
+
cb(chunk.values);
|
|
217
|
+
}
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
192
223
|
//
|
|
193
224
|
// Lightway representation for ExplicitJsonData
|
|
194
225
|
//
|
package/src/errors.ts
CHANGED
|
@@ -36,6 +36,14 @@ export function isPFrameError(error: unknown): error is PFrameError {
|
|
|
36
36
|
return error instanceof Error && error.name === 'PFrameError';
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
export class PFrameDriverError extends PFrameError {
|
|
40
|
+
name = 'PFrameError.Driver';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function isPFrameDriverError(error: unknown): error is PFrameDriverError {
|
|
44
|
+
return error instanceof Error && error.name === 'PFrameError.Driver';
|
|
45
|
+
}
|
|
46
|
+
|
|
39
47
|
function stringifyValue(value: unknown): string {
|
|
40
48
|
if (typeof value === 'string') {
|
|
41
49
|
return `String value was thrown: ${value}`;
|