<commit_before>"use strict";

const dataMap = new WeakMap();

class ExtensibleFunction extends Function {
    constructor( func ) {
        return Object.setPrototypeOf( func, new.target.prototype );
    }
}

class Prall extends ExtensibleFunction {
    constructor( data ) {
        super( ( ...args ) => data.call( args ) );
        dataMap.set( this, data );
    }
    apply( context, args ) {
        return dataMap.get( this )
            .withContext( context )
            .call( args );
    }
    bind( context ) {
        const data = dataMap.get( this );
        const newData = data.withContext( context, true );
        return data === newData ? this : new Prall( newData );
    }
    call( context, ...args ) {
        return this.apply( context, args );
    }
    catch( handler ) {
        return this().catch( handler );
    }
    filter( adapt ) {
        const data = dataMap.get( this );
        const newData = data.withAdapt( adapt );
        return data === newData ? this : new Prall( newData );
    }
    on( context ) {
        const data = dataMap.get( this );
        const newData = data.withContext( context );
        return data === newData ? this : new Prall( newData );
    }
    then( resolveHandler, rejectHandler ) {
        return this().then( resolveHandler, rejectHandler );
    }
    with( ...args ) {
        const data = dataMap.get( this );
        const newData = data.withArgs( args );
        return data === newData ? this : new Prall( newData );
    }
}

module.exports = Prall;<commit_msg>Uses a symbol rather than a weak map for private data management<commit_after>"use strict";

const dataSymbol = Symbol( `prall-data` );

class ExtensibleFunction extends Function {
    constructor( func ) {
        return Object.setPrototypeOf( func, new.target.prototype );
    }
}

class Prall extends ExtensibleFunction {
    constructor( data ) {
        super( ( ...args ) => data.call( args ) );
        this[ dataSymbol ] = data;
    }
    apply( context, args ) {
        return this[ dataSymbol ].withContext( context ).call( args );
    }
    bind( context ) {
        const data = this[ dataSymbol ];
        const newData = data.withContext( context, true );
        return data === newData ? this : new Prall( newData );
    }
    call( context, ...args ) {
        return this.apply( context, args );
    }
    catch( handler ) {
        return this().catch( handler );
    }
    filter( adapt ) {
        const data = this[ dataSymbol ];
        const newData = data.withAdapt( adapt );
        return data === newData ? this : new Prall( newData );
    }
    on( context ) {
        const data = this[ dataSymbol ];
        const newData = data.withContext( context );
        return data === newData ? this : new Prall( newData );
    }
    then( resolveHandler, rejectHandler ) {
        return this().then( resolveHandler, rejectHandler );
    }
    with( ...args ) {
        const data = this[ dataSymbol ];
        const newData = data.withArgs( args );
        return data === newData ? this : new Prall( newData );
    }
}

module.exports = Prall;
{'fraction_non_alphanumeric': 0.12258687258687259, 'fraction_numerical': 0.0, 'mean_word_length': 2.1756894790602654, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7337684', 'n_tokens_mistral': 879, 'n_tokens_neox': 874, 'n_words': 268}