all files / src/ deltaUtils.js

100% Statements 13/13
100% Branches 4/4
100% Functions 5/5
100% Lines 9/9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18      18×     55×          
/*
  General utilities for handling processing of delta changes from eureka.
*/
export function arrayOrObj(mysteryValue) {
  return Array.isArray(mysteryValue) ? mysteryValue : [mysteryValue];
}
 
export function findInstance(a) {
  return b => a.hostName === b.hostName && a.port.$ === b.port.$;
}
 
export function normalizeDelta(appDelta) {
  return arrayOrObj(appDelta).map((app) => {
    app.instance = arrayOrObj(app.instance);
    return app;
  });
}