Skip to content
Snippets Groups Projects
Forked from an inaccessible project.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
requirement-line.pipe.ts 693 B
import { Pipe, PipeTransform } from '@angular/core';
import { ContentType } from '../models/audit/requirement';

@Pipe({ name: 'requirementLine' })
export class RequirementLinePipe implements PipeTransform {
  transform(lines: string[], type: ContentType['contentType']): string[] {
    switch (type) {
      case 'okSubrequirementTLine':
      case 'noSubrequirementTLine': {
        const singleLine = lines.join(' ').trim();
        const matches = singleLine.match(/^((IP)|(IN-P)|(PL)|(R)|(<>)|\+|\-|\*)+(?![a-zA-Z])/g);

        if (matches && matches.length > 0) {
          lines = [singleLine.substr(matches[0].length)];
        }
        break;
      }
    }

    return lines;
  }
}