All files Token.class.js

100% Statements 14/14
100% Branches 2/2
100% Functions 8/8
100% Lines 14/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 381x   82x 82x 82x     115x     81x     69x     81x     45x     81x     81x 81x 81x 81x                  
module.exports = class Token {
  constructor(type, content) {
    this.type = type
    this.content = content
    this.attributes = Object.create(null)
  }
  setType(type) {
    this.type = type
  }
  getType() {
    return this.type
  }
  setContent(content) {
    this.content = content
  }
  getContent() {
    return this.content
  }
  setAttribute(name, value) {
    this.attributes[name] = value
  }
  getAttributes() {
    return this.attributes
  }
  getLog() {
    const type = this.getType()
    const content = this.getContent()
    const attributes = this.getAttributes()
    return JSON.stringify(Object.keys(attributes).length === 0 ? {
      type,
      content
    } : {
      type,
      content,
      attributes
    })
  }
}