<commit_before>import React from 'react';
import {output, highlightedOutput} from '../styles';
import {
  slice, map, filter, compose, addIndex, equals, allPass, last, concat, sortBy,
  path,
} from 'ramda';

// map files/dirs to virtual dom nodes
const mapOutput = style => addIndex(map)((file, i) =>
  <span key={i} style={style}>
    {file}
  </span>
);

const hasSameRoot = (currentPath, file) => equals(
  slice(0, currentPath.length, file),
  currentPath
);

const isChildren = (currentPath, file) => equals(
  file.length,
  currentPath.length + 1
);

// sort final span tags by alphabetical order
const sortByName = sortBy(path(['props', 'children']));

const sortAndConcat = compose(sortByName, concat);

const ls = self => {
  const {currentPath, fileSystem} = self.state;
  const {directories, files} = fileSystem;

  const getFiles = compose(
    map(last),
    filter(file => allPass([isChildren, hasSameRoot])(currentPath, file))
  );

  const mapFiles = mapOutput(output);
  const mapDirs = mapOutput(highlightedOutput);

  return (
    <div>
      {sortAndConcat(
        mapFiles(getFiles(files)),
        mapDirs(getFiles(directories))
      )}
    </div>
  );
};

export default ls;<commit_msg>fix retarded filter implementation :cry:<commit_after>import React from 'react';
import {output, highlightedOutput} from '../styles';
import {
  map, filter, compose, addIndex, equals, last, concat, sortBy,
  path, init,
} from 'ramda';

// map files/dirs to virtual dom nodes
const mapOutput = style => addIndex(map)((file, i) =>
  <span key={i} style={style}>
    {file}
  </span>
);

// sort final span tags by alphabetical order
const sortByName = sortBy(path(['props', 'children']));

const sortAndConcat = compose(sortByName, concat);

const ls = self => {
  const {currentPath, fileSystem} = self.state;
  const {directories, files} = fileSystem;

  const getFiles = compose(
    map(last),
    filter(file => equals(currentPath, init(file)))
  );

  const mapFiles = mapOutput(output);
  const mapDirs = mapOutput(highlightedOutput);

  return (
    <div>
      {sortAndConcat(
        mapFiles(getFiles(files)),
        mapDirs(getFiles(directories))
      )}
    </div>
  );
};

export default ls;
{'fraction_non_alphanumeric': 0.14324324324324325, 'fraction_numerical': 0.0009009009009009009, 'mean_word_length': 4.002252252252252, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 21, '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': '7513970', 'n_tokens_mistral': 728, 'n_tokens_neox': 707, 'n_words': 194}