<commit_before>function copyAt1x(context) {
  scale = 1;
  onRun(context);
}

function copyAt2x(context) {
  scale = 2;
  onRun(context);
}

function copyAt3x(context) {
  scale = 3;
  onRun(context);
}

function onRun(context) {

  var doc = context.document;
  var selectedLayers = context.selection;
  var selectedCount = selectedLayers.count();

  if (selectedCount == 0) {
    [doc showMessage: "Select one or more layers to copy"];
    return false;
  } else {
    [doc showMessage: "Copying @ " + scale + "x"];
  }

  var i, len, layer, copy = "";
  for (i = 0, len = selectedLayers.length; i < len; i++) {
    layer = selectedLayers[i];

    switch(layer.class()) {
      // case MSLayerGroup:
      //   log("Group");
      //   break;
      case MSShapeGroup:
        if (isRectangle(layer) || isCircle(layer)) {
          copy = copy + layerWithPropertiesCode(layer);
        } else {
          copy = copy + layerCode(layer);
        }
        break;

      case MSTextLayer:
        copy = copy + textLayerCode(layer);
        break;

      default:
        copy = copy + layerCode(layer);
    }

  }

  clipboard.set(copy);

};

function topFill(style) {
  var fills = style.enabledFills();

  var i, len, fill = null;
  for (i = 0, len = fills.length; i < len; i++) {
    var fillType = fills[i].fillType();
    if (fillType == 0) {
      fill = fills[i]
    }
  }

  return fill;
}

function topBorder(style) {
  var borders = style.enabledBorders();

  var i, len, border = null;
  for (i = 0, len = borders.length; i < len; i++) {
    var fillType = borders[i].fillType();
    if (fillType == 0) {
      border = borders[i]
    }
  }
<commit_msg>Updated code to use more of new API<commit_after>function copyAt1x(context) {
  scale = 1;
  onRun(context);
}

function copyAt2x(context) {
  scale = 2;
  onRun(context);
}

function copyAt3x(context) {
  scale = 3;
  onRun(context);
}

function onRun(context) {

  var sketch = context.api();
  var document = sketch.selectedDocument;
  var selection = document.selectedLayers;

  if (selection.isEmpty) {
    sketch.message("Select one or more layers to copy");
    return false;
  }  else {
    sketch.message("Copying @ " + scale + "x");
  }

  var sketchObject, copy = "";

  selection.iterate(function(layer) {
    
    sketchObject = layer.sketchObject;

    switch(sketchObject.class()) {
      // case MSLayerGroup:
      //   log("Group");
      //   break;
      case MSShapeGroup:
        if (isRectangle(sketchObject) || isCircle(sketchObject)) {
          copy = copy + layerWithPropertiesCode(sketchObject);
        } else {
          copy = copy + layerCode(sketchObject);
        }
        break;

      case MSTextLayer:
        copy = copy + textLayerCode(sketchObject);
        break;

      default:
        copy = copy + layerCode(sketchObject);
    }

  });

  clipboard.set(copy);

};

function topFill(style) {
  var fills = style.enabledFills();

  var i, len, fill = null;
  for (i = 0, len = fills.length; i < len; i++) {
    var fillType = fills[i].fillType();
    if (fillType == 0) {
      fill = fills[i]
    }
  }

  return fill;
}

function topBorder(style) {
  var borders = style.enabledBorders();

  var i, len, border = null;
  for (i = 0, len = borders.length; i < len; i++) {
    var fillType = borders[i].fillType();
    if (fillType == 0) {
      border = borders[i]
    }
  }

{'fraction_non_alphanumeric': 0.13977541371158392, 'fraction_numerical': 0.0065011820330969266, 'mean_word_length': 2.515057113187954, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '677344', 'n_tokens_mistral': 1187, 'n_tokens_neox': 1132, 'n_words': 281}