All files / rxmq.js/src/utils findTopicByName.js

100% Statements 6/6
100% Branches 4/4
100% Functions 2/2
100% Lines 5/5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17            2x 18x 18x 9x     9x        
/**
 * Find a specific subject by given name
 * @param  {Array}                  subjects    Array of subjects to search in
 * @param  {String}                 name        Name to search for
 * @return {(EndlessSubject|void)}              Found subject or void
 */
const findSubjectByName = (subjects, name) => {
  const res = subjects.filter(s => s.name === name);
  if (!res || res.length < 1) {
    return undefined;
  }
 
  return res[0];
};
 
export { findSubjectByName };