deserialize = (options, stl) => {
  const defaults = {
    filename: 'stl',
    version: packageVersion,
    addMetaData: true,
    output: 'script'
  }
  options = Object.assign({}, defaults, options)

  options && options.statusCallback && options.statusCallback({ progress: 0 })

  const { filename, version, output, addMetaData } = options

  // if provided an ArrayBuffer then convert to String
  stl = isBuffer(stl) ? bufferToBinaryString(stl) : stl

  const isBinary = isDataBinaryRobust(stl)

  options && options.statusCallback && options.statusCallback({ progress: 33 })

  const elementFormatterJscad = ({ vertices, triangles, normals, colors, index }) => toScript(vertices, triangles, null, colors, index)
  const elementFormatterObject = ({ vertices, triangles, normals, colors }) => toPolyhedron(vertices, triangles, null, colors)

  options && options.statusCallback && options.statusCallback({ progress: 66 })

  const deserializer = isBinary ? deserializeBinarySTL : deserializeAsciiSTL
  const elementFormatter = output === 'script' ? elementFormatterJscad : elementFormatterObject
  const outputFormatter = output === 'script' ? formatAsJscad : formatAsCsg

  const result = outputFormatter(deserializer(stl, filename, version, elementFormatter), addMetaData, version, filename)

  options && options.statusCallback && options.statusCallback({ progress: 100 })
  return result

  /*
  TODO if (err) src += '// WARNING: import errors: ' + err + ' (some triangles might be misaligned or missing)\n'
  */
}
Parse the given STL data and return either a JSCAD script or a list of geometries
@param {Object} options - options used during deserializing, REQUIRED
@param {string} [options.filename='stl'] - filename of original STL source
@param {string} [options.version='0.0.0'] - version number to add to the metadata
@param {boolean} [options.addMetadata=true] - toggle injection of metadata at the start of the script
@param {string} [options.output='script'] - either 'script' or 'geometry' to set desired output
@param {string} input - stl data
@return {[objects]|string} a list of objects (geometry) or a string (script)
@alias module:io/stl-deserializer.deserialize