function copyLayer(layer) {
  // create duplicate
  let layerCopy = layer.duplicate()

  // remove duplicate from parent
  layerCopy.removeFromParent()

  return layerCopy
}
Creates a copy of the provided layer.

@param {MSLayer} layer
@returns {MSLayer}