<commit_before>function properties(obj) {
  let key, lst = [];
  for (key in obj) {
    if (obj.hasOwnProperty(key)) {
      lst.push(key);
    }
  }
  return lst;
}

function isImmutable(data) {
  return data === undefined ||
         data === null ||
         typeof data == "string" ||
         typeof data == "number";
}

function createNativeGetter(key) {
  return function getter(data) {
    if (key) {
      if (isImmutable(data)) {
        return undefined;
      } else {
        return data[key];
      }
    } else {
      return data;
    }
  };
}

function createImmutableGetter(key) {
  let getter = createNativeGetter(key);
  return function immutableGetter(data) {
    if (key) {
      if (isImmutable(data)) {
        return undefined;
      }
      else if (data.get instanceof Function) {
        return data.get(key);
      } else {
        return getter(data);
      }
    } else {
      return data;
    }
  };
}

function createNativeSetter(key) {
  return function setter(data, value) {
    if (key) {
      if (isImmutable(data)) {
        return data;
      } else {
        let copy = properties(data).reduce((memo, val) => {
          memo[val] = data[val];
          return memo;
        }, {});
        copy[key] = value;
        return copy;
      }
    } else {
      return data;
    }
  };
}

function createImmutableSetter(key) {
  let setter = createNativeSetter(key);
  return function immutableSetter(data, value) {
    if (key) {
      if (isImmutable(data)) {
        return data;
      }
      else if (data.set instanceof Function) {
        return data.set(key, value);
      } else {
        return setter(data, value);
      }
    } else {
      return data;
    }
  };
}

function Lens(getter, setter) {
  return {
    get: getter,

    set: setter,

    modify(data, func) {
      let val = this.get(data);
      return this.set(data, func(val));
    },

    compose(nextLens) {
      return Lens(
        (data)        => nextLens.get(this.get(data)),
        (data, value) => this.set(data, nextLens.set(this.get(data), value))
      );
    }
  };
}
<commit_msg>Tiny refactor for cleaner code<commit_after>function properties(obj) {
  let key, lst = [];
  for (key in obj) {
    if (obj.hasOwnProperty(key)) {
      lst.push(key);
    }
  }
  return lst;
}

function isImmutable(data) {
  return data === undefined ||
         data === null ||
         typeof data == "string" ||
         typeof data == "number";
}

function createNativeGetter(key) {
  return function getter(data) {
    if (key) {
      if (isImmutable(data)) {
        return undefined;
      } else {
        return data[key];
      }
    } else {
      return data;
    }
  };
}

function createImmutableGetter(key) {
  return function immutableGetter(data) {
    if (key) {
      if (isImmutable(data)) {
        return undefined;
      }
      else if (data.get instanceof Function) {
        return data.get(key);
      } else {
        return createNativeGetter(key)(data);
      }
    } else {
      return data;
    }
  };
}

function createNativeSetter(key) {
  return function setter(data, value) {
    if (key) {
      if (isImmutable(data)) {
        return data;
      } else {
        let copy = properties(data).reduce((memo, val) => {
          memo[val] = data[val];
          return memo;
        }, {});
        copy[key] = value;
        return copy;
      }
    } else {
      return data;
    }
  };
}

function createImmutableSetter(key) {
  return function immutableSetter(data, value) {
    if (key) {
      if (isImmutable(data)) {
        return data;
      }
      else if (data.set instanceof Function) {
        return data.set(key, value);
      } else {
        return createNativeSetter(key)(data, value);
      }
    } else {
      return data;
    }
  };
}

function Lens(getter, setter) {
  return {
    get: getter,

    set: setter,

    modify(data, func) {
      let val = this.get(data);
      return this.set(data, func(val));
    },

    compose(nextLens) {
      return Lens(
        (data)        => nextLens.get(this.get(data)),
        (data, value) => this.set(data, nextLens.set(this.get(data), value))
      );
    }
  };
}

{'fraction_non_alphanumeric': 0.13498688290007155, 'fraction_numerical': 0.0, 'mean_word_length': 1.985053380782918, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1591132', 'n_tokens_mistral': 1378, 'n_tokens_neox': 1374, 'n_words': 308}