<commit_before>import { Link, LinkNotFound, LinkSet } from '../link';


/**
 * The Representation class is basically a 'body' of a request
 * or response.
 *
 * This is base class for a representation.
 */
export default abstract class Representation<T = string> {

  contentType: string;
  uri: string;

  protected body: T;
  protected links: LinkSet;

  constructor(uri: string, contentType: string, body: string | null, headerLinks: LinkSet) {

    this.uri = uri;
    this.contentType = contentType;
    this.links = headerLinks;
    if (body !== null) {
      this.setBody(this.parse(body));
    }

  }

  getLink(rel: string): Link {

    const links = this.links.get(rel);

    if (!links) {
      throw new LinkNotFound('Link with rel: ' + rel + ' not found on resource: ' + this.uri);
    }

    return links[0];

  }

  getLinks(rel?: string): Link[] {

    if (!rel) {<commit_msg>Dealing with 0 links in an array. Thnx @mattbishop<commit_after>import { Link, LinkNotFound, LinkSet } from '../link';


/**
 * The Representation class is basically a 'body' of a request
 * or response.
 *
 * This is base class for a representation.
 */
export default abstract class Representation<T = string> {

  contentType: string;
  uri: string;

  protected body: T;
  protected links: LinkSet;

  constructor(uri: string, contentType: string, body: string | null, headerLinks: LinkSet) {

    this.uri = uri;
    this.contentType = contentType;
    this.links = headerLinks;
    if (body !== null) {
      this.setBody(this.parse(body));
    }

  }

  getLink(rel: string): Link {

    const links = this.links.get(rel);

    if (!links || links.length === 0) {
      throw new LinkNotFound('Link with rel: ' + rel + ' not found on resource: ' + this.uri);
    }

    return links[0];

  }

  getLinks(rel?: string): Link[] {

    if (!rel) {
{'fraction_non_alphanumeric': 0.13239283776451438, 'fraction_numerical': 0.002170374389582203, 'mean_word_length': 3.035010940919037, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2191776', 'n_tokens_mistral': 592, 'n_tokens_neox': 562, 'n_words': 182}