{"size": 647, "ext": "js", "max_stars_repo_path": "node_modules/reduce-simplicial-complex/reduce.js", "max_stars_repo_name": "Saknet/SensorObservationFrontend", "max_stars_repo_stars_event_min_datetime": "2021-09-22T07:15:32.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-05T01:23:48.000Z", "max_issues_repo_path": "node_modules/reduce-simplicial-complex/reduce.js", "max_issues_repo_name": "latonaio/ui-frontend-for-vr-face-recognition", "max_issues_repo_issues_event_min_datetime": "2016-02-24T14:33:31.000Z", "max_issues_repo_issues_event_max_datetime": "2020-12-30T07:16:23.000Z", "max_forks_repo_path": "node_modules/reduce-simplicial-complex/reduce.js", "max_forks_repo_name": "latonaio/ui-frontend-for-vr-face-recognition", "max_forks_repo_forks_event_min_datetime": "2016-03-31T17:50:07.000Z", "max_forks_repo_forks_event_max_datetime": "2019-07-03T10:32:18.000Z"}
{"max_stars_count": 12, "max_issues_count": 197, "max_forks_count": 4, "avg_line_length": 20.21875, "max_line_length": 58, "alphanum_fraction": 0.5842349304}
'use strict'

var compareCell = require('compare-cell')
var compareOrientedCell = require('compare-oriented-cell')
var orientation = require('cell-orientation')

module.exports = reduceCellComplex

function reduceCellComplex(cells) {
  cells.sort(compareOrientedCell)
  var n = cells.length
  var ptr = 0
  for(var i=0; i<n; ++i) {
    var c = cells[i]
    var o = orientation(c)
    if(o === 0) {
      continue
    }
    if(ptr > 0) {
      var f = cells[ptr-1]
      if(compareCell(c, f) === 0 &&
         orientation(f)    !== o) {
        ptr -= 1
        continue
      }
    }
    cells[ptr++] = c
  }
  cells.length = ptr
  return cells
}
