text: // https://github.com/mattdesl/triangulate-contours
  /* eslint-disable */
  var Tess2 = require('../tess2')
  var xtend = require('xtend')
  
  module.exports = function(contours, opt) {
      opt = opt||{}
      contours = contours.filter(function(c) {
          return c.length>2
      })
      
      if (contours.length === 0) {
          return { 
              positions: [],
              cells: []
          }
      }
  
      if (typeof opt.vertexSize !== 'number')
          opt.vertexSize = contours[0][0].length
  
      //flatten for tess2.js
      contours = contours.map(function(c) {
          return c.reduce(function(a, b) {
              return a.concat(b)
          })
      })
      
      const windingRule = opt.rule === 'evenodd'? Tess2.WINDING_ODD : Tess2.WINDING_NONZERO;
  
      // Tesselate
      var res = Tess2.tesselate(xtend({
          contours: contours,
          windingRule,
          elementType: Tess2.POLYGONS,
          polySize: 3,
          vertexSize: 2
      }, opt))
  
      var positions = []
      for (var i=0; i<res.vertices.length; i+=opt.vertexSize) {
          var pos = res.vertices.slice(i, i+opt.vertexSize)
          positions.push(pos)
      }
      
      var cells = []
      for (i=0; i<res.elements.length; i+=3) {
          var a = res.elements[i],
              b = res.elements[i+1],
              c = res.elements[i+2]
          cells.push([a, b, c])
      }
  
      //return a simplicial complex
      return {
          positions: positions,
          cells: cells
      }
  }