<commit_before>import {Archer} from './units/archer';
import {Catapult} from './units/catapult';
import {Crystal} from './units/crystal';
import {DemonLord} from './units/demon-lord';
import {DireWolf} from './units/dire-wolf';
import {Dragon} from './units/dragon';
import {Elemental} from './units/elemental';
import {Galamar} from './units/galamar';
import {Golem} from './units/golem';
import {Saeth} from './units/saeth';
import {Skeleton} from './units/skeleton';
import {Soldier} from './units/soldier';
import {Sorceress} from './units/sorceress';
import {Valadorn} from './units/valadorn';
import {Wisp} from './units/wisp';

const map = {
    soldier: Soldier,
    archer: Archer,
    elemental: Elemental,
    sorceress: Sorceress,
    wisp: Wisp,
    'dire-wolf': DireWolf,
    golem: Golem,
    catapult: Catapult,
    dragon: Dragon,
    skeleton: Skeleton,
    crystal: Crystal,
    galamar: Galamar,
    'demon-lord': DemonLord,
    valadorn: Valadorn,
    saeth: Saeth
};

export function createUnit(data) {
    return new map[data.type](data);
}
<commit_msg>refactoring<commit_after>import {Archer} from './units/archer';
import {Catapult} from './units/catapult';
import {Crystal} from './units/crystal';
import {DemonLord} from './units/demon-lord';
import {DireWolf} from './units/dire-wolf';
import {Dragon} from './units/dragon';
import {Elemental} from './units/elemental';
import {Galamar} from './units/galamar';
import {Golem} from './units/golem';
import {Saeth} from './units/saeth';
import {Skeleton} from './units/skeleton';
import {Soldier} from './units/soldier';
import {Sorceress} from './units/sorceress';
import {Valadorn} from './units/valadorn';
import {Wisp} from './units/wisp';

const unitMap = {
    soldier: Soldier,
    archer: Archer,
    elemental: Elemental,
    sorceress: Sorceress,
    wisp: Wisp,
    'dire-wolf': DireWolf,
    golem: Golem,
    catapult: Catapult,
    dragon: Dragon,
    skeleton: Skeleton,
    crystal: Crystal,
    galamar: Galamar,
    'demon-lord': DemonLord,
    valadorn: Valadorn,
    saeth: Saeth
};

export function createUnit(data) {
    return new unitMap[data.type](data);
}

{'fraction_non_alphanumeric': 0.16126042632066728, 'fraction_numerical': 0.0, 'mean_word_length': 3.917995444191344, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2467871', 'n_tokens_mistral': 785, 'n_tokens_neox': 764, 'n_words': 196}