<commit_before>import * as _ from 'lodash';

import { IConverter } from '../converters';

export class AliasConverter<TDataType> implements IConverter<TDataType> {
	constructor(private alias: string
			, private composedConverter?: IConverter<TDataType>) { }

	fromServer: { (raw: any, parent: any): TDataType } = (raw: any, parent: any): TDataType => {
		if (!_.has(parent, this.alias)) {
			return null;
		}

		raw = parent[this.alias];

		if (this.composedConverter != null) {
			return this.composedConverter.fromServer(raw, parent);
		}

		return raw;
	}

	toServer: {(data: TDataType, parent: any): any} = (data: TDataType, parent: any): any => {<commit_msg>cleanup the value at the original key.<commit_after>import * as _ from 'lodash';

import { IConverter } from '../converters';

export class AliasConverter<TDataType> implements IConverter<TDataType> {
	constructor(private alias: string
			, private composedConverter?: IConverter<TDataType>) { }

	fromServer: { (raw: any, parent: any): TDataType } = (raw: any, parent: any): TDataType => {
		if (!_.has(parent, this.alias)) {
			return null;
		}

		raw = parent[this.alias];
		parent[this.alias] = null;

		if (this.composedConverter != null) {
			return this.composedConverter.fromServer(raw, parent);
		}

		return raw;
	}

	toServer: {(data: TDataType, parent: any): any} = (data: TDataType, parent: any): any => {
{'fraction_non_alphanumeric': 0.1476121562952243, 'fraction_numerical': 0.0, 'mean_word_length': 4.488095238095238, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, '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': '1567331', 'n_tokens_mistral': 471, 'n_tokens_neox': 445, 'n_words': 120}