@milaboratories/pl-model-common 1.16.3 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milaboratories/pl-model-common",
3
- "version": "1.16.3",
3
+ "version": "1.16.4",
4
4
  "description": "Platforma SDK Model",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",
@@ -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
  //