async _perform_write() {
        // Spread write_to configuration
        const {
            file_name,
            path,
            last_write,
            write_delay,
            pending,
            initial_write,
            relative_errors,
            runtime_relative_errors,
        } = this.#write_to;

        // Check for sufficient delay between last write
        let difference = Date.now() - last_write;
        if (difference < write_delay) {
            // Create a delayed timeout to perform a write after sufficient delay has passed
            if (!pending) {
                this.#write_to.pending = true;
                setTimeout(
                    (reference) => reference._perform_write(),
                    write_delay - difference,
                    this
                );
            }
            return;
        }

        // Write compiled file to specified path
        let reference = this;
        this.#write_to.pending = false;
        this.#write_to.last_write = Date.now();

        // Do not perform write on first recalibration as nested file discovery has not finished yet
        if (!initial_write) return (this.#write_to.initial_write = true);

        // Generate compiled content and write to specified file name
        let compiled_content = this.compiled;

        // Inject Compiler.log_relative_errors() call to compiled content beginning
        let relative_logger_code =
            "require('application-compiler').log_relative_errors();\n";
        if (relative_errors && runtime_relative_errors)
            compiled_content = relative_logger_code + compiled_content;

        // Perform compiled content write
        try {
            await this._write_file(path + file_name, compiled_content);

            // Perform post processing if relative errors have been requested
            if (relative_errors) {
                // Test for syntax errors
                try {
                    await reference._test_syntax();
                } catch (syntax_error) {
                    let relative_trace = reference._relativize_error(
                        syntax_error,
                        compiled_content,
                        false
                    );

                    relative_trace = relative_trace.split('\\').join('\\\\');

                    // Log Syntax Error
                    reference.#methods.logger(`SYNTAX_ERROR -> NO_HIERARCHY`);

                    // Overwrite compiled file with trace log
                    let trace_code = `console.error(\`${relative_trace}\`);
                    process.exit(1);`;
                    await this._write_file(path + file_name, trace_code);
                }
            }
        } catch (error) {
            return this.#methods.error(path, error);
        }
    }
/**
     * INTERNAL METHOD!
     * Triggers compiled file writing sequence based on write_to settings.
     *
     */
INTERNAL METHOD.
Triggers compiled file writing sequence based on write_to settings.
INTERNAL METHOD . Triggers compiled file writing sequence based on write_to settings .
async _perform_write() {
        const {
            file_name,
            path,
            last_write,
            write_delay,
            pending,
            initial_write,
            relative_errors,
            runtime_relative_errors,
        } = this.#write_to;
        let difference = Date.now() - last_write;
        if (difference < write_delay) {
            if (!pending) {
                this.#write_to.pending = true;
                setTimeout(
                    (reference) => reference._perform_write(),
                    write_delay - difference,
                    this
                );
            }
            return;
        }
        let reference = this;
        this.#write_to.pending = false;
        this.#write_to.last_write = Date.now();
        if (!initial_write) return (this.#write_to.initial_write = true);
        let compiled_content = this.compiled;
        let relative_logger_code =
            "require('application-compiler').log_relative_errors();\n";
        if (relative_errors && runtime_relative_errors)
            compiled_content = relative_logger_code + compiled_content;
        try {
            await this._write_file(path + file_name, compiled_content);
            if (relative_errors) {
                try {
                    await reference._test_syntax();
                } catch (syntax_error) {
                    let relative_trace = reference._relativize_error(
                        syntax_error,
                        compiled_content,
                        false
                    );
                    relative_trace = relative_trace.split('\\').join('\\\\');
                    reference.#methods.logger(`SYNTAX_ERROR -> NO_HIERARCHY`);
                    let trace_code = `console.error(\`${relative_trace}\`);
                    process.exit(1);`;
                    await this._write_file(path + file_name, trace_code);
                }
            }
        } catch (error) {
            return this.#methods.error(path, error);
        }
    }
async _perform_write ( ) { const { file_name , path , last_write , write_delay , pending , initial_write , relative_errors , runtime_relative_errors , } = this . #write_to ; let difference = Date . now ( ) - last_write ; if ( difference < write_delay ) { if ( ! pending ) { this . #write_to . pending = true ; setTimeout ( ( reference ) => reference . _perform_write ( ) , write_delay - difference , this ) ; } return ; } let reference = this ; this . #write_to . pending = false ; this . #write_to . last_write = Date . now ( ) ; if ( ! initial_write ) return ( this . #write_to . initial_write = true ) ; let compiled_content = this . compiled ; let relative_logger_code = "require('application-compiler').log_relative_errors();\n" ; if ( relative_errors && runtime_relative_errors ) compiled_content = relative_logger_code + compiled_content ; try { await this . _write_file ( path + file_name , compiled_content ) ; if ( relative_errors ) { try { await reference . _test_syntax ( ) ; } catch ( syntax_error ) { let relative_trace = reference . _relativize_error ( syntax_error , compiled_content , false ) ; relative_trace = relative_trace . split ( '\\' ) . join ( '\\\\' ) ; reference . #methods . logger ( ` ` ) ; let trace_code = ` \` ${ relative_trace } \` ` ; await this . _write_file ( path + file_name , trace_code ) ; } } } catch ( error ) { return this . #methods . error ( path , error ) ; } }
INTERNAL METHOD!
INTERNAL METHOD!
// Spread write_to configuration // Check for sufficient delay between last write // Create a delayed timeout to perform a write after sufficient delay has passed // Write compiled file to specified path // Do not perform write on first recalibration as nested file discovery has not finished yet // Generate compiled content and write to specified file name // Inject Compiler.log_relative_errors() call to compiled content beginning // Perform compiled content write // Perform post processing if relative errors have been requested // Test for syntax errors // Log Syntax Error // Overwrite compiled file with trace log