<commit_before>var chain = require("continuable/chain")
var list = require("continuable-list")
var fs = require("fs")

var getProfile = require("./get-profile")
var ensureDirectory = require("./ensure-directory")

var jsonFileType = /\.json$/

module.exports = getProfiles

function getProfiles() {
    var files = chain(ensureDirectory(), function (loc) {
        return fs.readdir.bind(null, loc)
    })

    return chain(files, function (files) {
        var profiles = files.map(function (file) {
            var profileName = file.replace(jsonFileType, "")
            return getProfile(profileName)
        })

        return list(profiles)
    })
}<commit_msg>add sorting to get profiles to make tests determinstic<commit_after>var chain = require("continuable/chain")
var map = require("continuable/map")
var list = require("continuable-list")
var fs = require("fs")

var getProfile = require("./get-profile")
var ensureDirectory = require("./ensure-directory")

var jsonFileType = /\.json$/

module.exports = getProfiles

function getProfiles() {
    var files = chain(ensureDirectory(), function (loc) {
        return fs.readdir.bind(null, loc)
    })

    var profiles = chain(files, function (files) {
        var profiles = files.map(function (file) {
            var profileName = file.replace(jsonFileType, "")
            return getProfile(profileName)
        })

        return list(profiles)
    })

    return map(profiles, function (profiles) {
        return profiles.sort(byName)
    })
}

function byName(left, right) {
    return left.name < right.name ? -1 : 1
}
{'fraction_non_alphanumeric': 0.12964128382630585, 'fraction_numerical': 0.0012586532410320957, 'mean_word_length': 3.1952506596306067, 'pattern_counts': {'":': 0, '<': 4, '<?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': '2317387', 'n_tokens_mistral': 466, 'n_tokens_neox': 449, 'n_words': 116}