<commit_before>function Thing(){
    this.config = {};
}

Thing.prototype.copy = function(){
    var anotherThing = new Thing();
    anotherThing.config = this.config;
    return anotherThing;
};

Thing.prototype.on = function( key ){
    var transientThing = this.copy();

    transientThing.currentKey = key;
    if( transientThing.config[ key ] === undefined ){
        transientThing.config[ key ] = {};
    }
    return transientThing;
};

Thing.prototype.set = function( key ){
    var object;

    if( this.currentKey ){
        object = this.config[this.currentKey];
    }else{
        object = this.config;
    }

    object[ key ] = true;
};

var myThing = new Thing();
myThing.set( 'Hair' );
myThing.on('Cheese').set('Stink');
myThing.set('Beard');

console.log( myThing );

var myOtherThing = new Thing();
myOtherThing.on( 'Toast ').set('Marmalade');
console.log( myOtherThing );<commit_msg>another version of this implementation<commit_after>function Thing(){
    this.config = {};
}

Thing.prototype.set = function( key ){
    this.config[ key ] = true;
};

Thing.prototype.on = function( key ){
    var transientThing = new TransientThing( this );

    transientThing.currentKey = key;
    if( transientThing.config[ key ] === undefined ){
        transientThing.config[ key ] = {};
    }
    return transientThing;
};

function TransientThing( fromThing ){
    Thing.call( this );
    this.config = fromThing.config;
}


TransientThing.prototype.set = function( key ){
    var object;

    if( this.currentKey ){
        object = this.config[this.currentKey];
    }else{
        object = this.config;
    }

    object[ key ] = true;
};

var myThing = new Thing();
myThing.set( 'Hair' );
myThing.on('Cheese').set('Stink');
myThing.set('Beard');

console.log( myThing );

var myOtherThing = new Thing();
myOtherThing.on( 'Toast ').set('Marmalade');
console.log( myOtherThing );
{'fraction_non_alphanumeric': 0.15380549682875264, 'fraction_numerical': 0.0, 'mean_word_length': 3.331807780320366, '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': '851557', 'n_tokens_mistral': 657, 'n_tokens_neox': 635, 'n_words': 135}