acuminous/twiki-gherkish-feature-parser

View on GitHub
lib/Source.js

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
const nonSpace = /[\S]/;

export default class Source {

  #line;
  #lineNumber;
  #indentation;
  #uri;

  constructor({ line, lineNumber, uri }) {
    this.#line = line;
    this.#lineNumber = lineNumber;
    this.#indentation = nonSpace.test(line) ? line.search(nonSpace) : line.length;
    this.#uri = uri;
  }

  get line() {
    return this.#line;
  }

  get indentation() {
    return this.#indentation;
  }

  get location() {
    return `${this.#uri}:${this.#lineNumber}`;
  }
}