function clearLayer(layer) {
  // clear group layer
  if (Layers.isLayerGroup(layer)) {
    // clear artboard names
    let artboardLayers = Layers.findLayersInLayer('*', false, Layers.ARTBOARD, layer, false, null)
    artboardLayers.forEach(artboardLayer => {
      clearArtboard(artboardLayer)
    })

    // clear text layers
    let textLayers = Layers.findLayersInLayer('*', false, Layers.TEXT, layer, false, null)
    textLayers.forEach(textLayer => {
      clearTextLayer(textLayer)
    })

    // clear images
    let imageLayers = Layers.findLayersInLayer('{*}*', false, Layers.SHAPE, layer, false, null)
    imageLayers = imageLayers.concat(
      Layers.findLayersInLayer('{*}*', false, Layers.BITMAP, layer, false, null)
    )
    imageLayers.forEach(imageLayer => {
      clearImageLayer(imageLayer)
    })

    // clear symbols
    let symbolLayers = Layers.findLayersInLayer('*', false, Layers.SYMBOL, layer, false, null)
    symbolLayers.forEach(function (symbolLayer) {
      clearSymbolLayer(symbolLayer)
    })
  }

  // clear text layer
  else if (Layers.isLayerText(layer)) {
    clearTextLayer(layer)
  }

  // clear image layer
  else if (Layers.isLayerShapeGroup(layer) || Layers.isLayerBitmap(layer)) {
    // populate image placeholder
    if (layer.name().indexOf('{') > -1) {
      clearImageLayer(layer)
    }
  }

  // clear symbol
  else if (Layers.isSymbolInstance(layer)) {
    clearSymbolLayer(layer)
  }
}
Restores the original layer content and clears the metadata.

@param {MSLayer} layer