src/generator.js
function addModelCell (propertyName, model, cellDefinitions) {
  const cell = {}

  var defName = propertyName
  var counter = 1

  while (defName in cellDefinitions) {
    defName = `${propertyName}${counter}`
    counter++
  }

  cellDefinitions[defName] = cell

  const props = getPropertyOrder(model.properties)
  const children = props.map((propName) => {
    // we have a circular dependency
    /* eslint-disable no-use-before-define */
    return addModel(propName, model.properties[propName], cellDefinitions)
    /* eslint-enable no-use-before-define */
  })

  if (model.dependencies) {
    _.forIn(model.dependencies, (dep, depName) => {
      const depProps = getPropertyOrder(dep.properties)
      const depChildren = depProps.map((propName) => {
        // we have a circular dependency
        /* eslint-disable no-use-before-define */
        return addDependentModel(propName, depName, dep.properties[propName], cellDefinitions)
        /* eslint-enable no-use-before-define */
      })
      children.push.apply(children, depChildren)
    })
  }
  cell.children = children
  return defName
}
function addModelCell (propertyName, model, cellDefinitions) {
  const cell = {}

  var defName = propertyName
  var counter = 1

  while (defName in cellDefinitions) {
    defName = `${propertyName}${counter}`
    counter++
  }

  cellDefinitions[defName] = cell

  const props = getPropertyOrder(model.properties)
  const children = props.map((propName) => {
    // we have a circular dependency
    /* eslint-disable no-use-before-define */
    return addModel(propName, model.properties[propName], cellDefinitions)
    /* eslint-enable no-use-before-define */
  })

  if (model.dependencies) {
    _.forIn(model.dependencies, (dep, depName) => {
      const depProps = getPropertyOrder(dep.properties)
      const depChildren = depProps.map((propName) => {
        // we have a circular dependency
        /* eslint-disable no-use-before-define */
        return addDependentModel(propName, depName, dep.properties[propName], cellDefinitions)
        /* eslint-enable no-use-before-define */
      })
      children.push.apply(children, depChildren)
    })
  }
  cell.children = children
  return defName
}
function addModelCell ( propertyName , model , cellDefinitions ) { const cell = { } var defName = propertyName var counter = 1 while ( defName in cellDefinitions ) { defName = ` ${ propertyName } ${ counter } ` counter ++ } cellDefinitions [ defName ] = cell const props = getPropertyOrder ( model . properties ) const children = props . map ( ( propName ) => { // we have a circular dependency /* eslint-disable no-use-before-define */ return addModel ( propName , model . properties [ propName ] , cellDefinitions ) /* eslint-enable no-use-before-define */ } ) if ( model . dependencies ) { _ . forIn ( model . dependencies , ( dep , depName ) => { const depProps = getPropertyOrder ( dep . properties ) const depChildren = depProps . map ( ( propName ) => { // we have a circular dependency /* eslint-disable no-use-before-define */ return addDependentModel ( propName , depName , dep . properties [ propName ] , cellDefinitions ) /* eslint-enable no-use-before-define */ } ) children . push . apply ( children , depChildren ) } ) } cell . children = children return defName }
Add a model cell for the given model
@param {String} propertyName - the name of the property that holds the model
@param {BunsenModel} model - the model to add a cell for
@param {BunsenCell[]} cellDefinitions - the cells set to add the model cell to
@returns {String} the cell name
Add a model cell for the given model