ultimate-comparisons/ultimate-comparison-BASE

View on GitHub
lib/gulp/model/data/data.js

Summary

Maintainability
A
0 mins
Test Coverage
import { DataElement } from "./dataElement";

class Data {
  constructor(dataElements) {
    this.dataElements = dataElements;
  }

  static loadJson(json, configuration) {
    const dataElements = (json || [])
      .filter(obj => obj.type === "header")
      .map(obj => DataElement.loadJson(obj, configuration));

    return new Data(dataElements);
  }

  json() {
    return this.dataElements.map(element => element.json());
  }

  markdown() {
    return this.dataElements.map(element => element.markdown());
  }
}

export { Data };