<commit_before>var _ = require('lodash'),
    fs = require('fs'),
    path = require('path');

var CmofParser = require('cmof-parser');

var Helper = require('../../../helper');


function Builder() {

  var desc;

  var hooks = {
    'preSerialize': []
  };

  function getPackage() {
    var elementsById = desc.byId;
    return elementsById['_0'];
  }

  function findProperty(properties, name) {
    var property = _.find(properties, function(d) {
      return d.name === name;
    });

    return property && {
      property: property,
      idx: properties.indexOf(property)
    };
  }

  function reorderProperties(desc, propertyNames) {
    var properties = desc.properties;

    var last;

    _.forEach(propertyNames, function(name) {

      var descriptor = findProperty(properties, name);

      if (last && descriptor) {
        // remove from old position
        properties.splice(descriptor.idx, 1);<commit_msg>feat(builder): handle non-existing property with error<commit_after>var _ = require('lodash'),
    fs = require('fs'),
    path = require('path');

var CmofParser = require('cmof-parser');

var Helper = require('../../../helper');


function Builder() {

  var desc;

  var hooks = {
    'preSerialize': []
  };

  function getPackage() {
    var elementsById = desc.byId;
    return elementsById['_0'];
  }

  function findProperty(properties, name) {
    var property = _.find(properties, function(d) {
      return d.name === name;
    });

    return property && {
      property: property,
      idx: properties.indexOf(property)
    };
  }

  function reorderProperties(desc, propertyNames) {
    var properties = desc.properties;

    var last;

    _.forEach(propertyNames, function(name) {

      var descriptor = findProperty(properties, name);

      if (!descriptor) {
        throw new Error('property <' + name + '> does not exist');
      }

      if (last) {
        // remove from old position
        properties.splice(descriptor.idx, 1);
{'fraction_non_alphanumeric': 0.14112903225806453, 'fraction_numerical': 0.0020161290322580645, 'mean_word_length': 2.839458413926499, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '6592955', 'n_tokens_mistral': 590, 'n_tokens_neox': 564, 'n_words': 142}