All files / metadata/src/utilities/metadataProvider dataLookup.ts

100% Statements 11/11
100% Branches 0/0
100% Functions 3/3
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40              640x 28530x 28530x         128x 128x   128x     384x           384x   384x   384x             384x    
import { MetadataModules } from '../../enums';
import { addTypedProvider, metadataModuleProvider } from '../../metaData';
 
/**
 * Creates a function that looks up the given dataType and provides it as "data"
 */
export function dataLookup(dataType: string) {
  return (next, query, data, options) => {
    data ||= metadataModuleProvider(dataType, query, options?.[dataType]);
    return next(query, data, options);
  };
}
 
/** The data lookup for the instance module */
export const instanceLookup = dataLookup(MetadataModules.INSTANCE);
export const naturalLookup = dataLookup(MetadataModules.NATURALIZED);
 
export const DATA_PRIORITY = { priority: 5000 };
 
export function registerDataLookup() {
  addTypedProvider(
    MetadataModules.INSTANCE,
    dataLookup(MetadataModules.NATURALIZED),
    DATA_PRIORITY
  );
 
  addTypedProvider(MetadataModules.IMAGE_PLANE, instanceLookup, DATA_PRIORITY);
 
  addTypedProvider(MetadataModules.CALIBRATION, instanceLookup, DATA_PRIORITY);
 
  addTypedProvider(
    MetadataModules.COMPRESSED_FRAME_DATA,
    naturalLookup,
    DATA_PRIORITY
  );
 
  // Scaling uses NATURALIZED (multiframe, no per-frame scaling); provider receives data from this lookup
  addTypedProvider(MetadataModules.SCALING, naturalLookup, DATA_PRIORITY);
}