_recalibrate() {
        // Retrieve file inclusions
        let reference = this;
        let nested_data = this._get_included_files();
        let included_files = nested_data.files;
        let included_paths = nested_data.paths;

        // Remove old file pointers and references
        let current_pointers = {};
        this.#nested_pointers = this.#nested_pointers.filter((pointer) => {
            let verdict = true;
            let path = pointer.path;
            let line_position = pointer.line;
            let nested_file = reference.#file_store[path];

            let position_check = included_files[line_position];

            // Check whether a valid include call with matching exists at line position
            if (position_check == undefined || position_check.path !== path)
                verdict = false;

            // Decrease nested_file pointers to keep track of whether this nested file is still needed
            if (!verdict) {
                nested_file.pointers--;

                // Destroy nested file if it has no dependent pointers and the path is no longer included in nested data
                if (nested_file.pointers < 1 && !included_paths[path]) {
                    nested_file.destroy();
                    delete reference.#file_store[path];
                }
            }

            // Store current pointers in object faster referencing in next loop
            if (verdict) current_pointers[line_position] = path;

            return verdict;
        });

        // Create new file pointers and references
        let sort_pointers = false;
        Object.keys(included_files).forEach((line_position) => {
            let new_pointer = included_files[line_position];
            let pointer_check = current_pointers[line_position] === undefined;
            if (pointer_check) {
                let path = new_pointer.path;
                let spacing = new_pointer.spacing;

                // Create new nested file reference in file store if one does not exist
                if (reference.#file_store[path] == undefined) {
                    let nested_file = new NestedLiveFile({
                        path: path,
                        tags: reference.#tags,
                        watcher_pool: reference.#watcher_pool,
                        forbidden: reference.#forbidden,
                        hierarchy: reference.#hierarchy,
                    });

                    // Bind passthrough logger
                    nested_file.handle('logger', (message) =>
                        this.#handlers.logger(message)
                    );

                    // Bind passthrough error handler
                    nested_file.handle('error', (path, error) =>
                        reference.#handlers.error(path, error)
                    );

                    // Bind passthrough recalibrate handler
                    nested_file.handle('recalibrate', () =>
                        reference.#handlers.recalibrate()
                    );

                    // Initiate nested file into file store with 0 pointers
                    nested_file.pointers = 0;
                    reference.#file_store[path] = nested_file;
                }

                // Iterate nested file pointers to signify multiple inclusion calls
                reference.#file_store[path].pointers++;

                // Push pointer to nested pointers and mark for re-sorting
                sort_pointers = true;
                reference.#nested_pointers.push({
                    line: line_position,
                    path: path,
                    spacing: spacing,
                });
            }
        });

        // Sort pointers from lowest to highest line positions
        if (sort_pointers)
            this.#nested_pointers.sort((a, b) => a.line - b.line);

        if (!this.#initialized) {
            this.#initialized = true;
            this._log(`INITIALIZED -> ${this.#hierarchy}`);
        } else {
            this._log(`DETECTED_CHANGES -> ${this.#hierarchy}`);
        }

        this.#handlers.recalibrate();
    }
/**
     * INTERNAL METHOD!
     * This method recalibrates nested/contained files based on content.
     */
INTERNAL METHOD.
This method recalibrates nested/contained files based on content.
INTERNAL METHOD . This method recalibrates nested / contained files based on content .
_recalibrate() {
        let reference = this;
        let nested_data = this._get_included_files();
        let included_files = nested_data.files;
        let included_paths = nested_data.paths;
        let current_pointers = {};
        this.#nested_pointers = this.#nested_pointers.filter((pointer) => {
            let verdict = true;
            let path = pointer.path;
            let line_position = pointer.line;
            let nested_file = reference.#file_store[path];
            let position_check = included_files[line_position];
            if (position_check == undefined || position_check.path !== path)
                verdict = false;
            if (!verdict) {
                nested_file.pointers--;
                if (nested_file.pointers < 1 && !included_paths[path]) {
                    nested_file.destroy();
                    delete reference.#file_store[path];
                }
            }
            if (verdict) current_pointers[line_position] = path;
            return verdict;
        });
        let sort_pointers = false;
        Object.keys(included_files).forEach((line_position) => {
            let new_pointer = included_files[line_position];
            let pointer_check = current_pointers[line_position] === undefined;
            if (pointer_check) {
                let path = new_pointer.path;
                let spacing = new_pointer.spacing;
                if (reference.#file_store[path] == undefined) {
                    let nested_file = new NestedLiveFile({
                        path: path,
                        tags: reference.#tags,
                        watcher_pool: reference.#watcher_pool,
                        forbidden: reference.#forbidden,
                        hierarchy: reference.#hierarchy,
                    });
                    nested_file.handle('logger', (message) =>
                        this.#handlers.logger(message)
                    );
                    nested_file.handle('error', (path, error) =>
                        reference.#handlers.error(path, error)
                    );
                    nested_file.handle('recalibrate', () =>
                        reference.#handlers.recalibrate()
                    );
                    nested_file.pointers = 0;
                    reference.#file_store[path] = nested_file;
                }
                reference.#file_store[path].pointers++;
                sort_pointers = true;
                reference.#nested_pointers.push({
                    line: line_position,
                    path: path,
                    spacing: spacing,
                });
            }
        });
        if (sort_pointers)
            this.#nested_pointers.sort((a, b) => a.line - b.line);
        if (!this.#initialized) {
            this.#initialized = true;
            this._log(`INITIALIZED -> ${this.#hierarchy}`);
        } else {
            this._log(`DETECTED_CHANGES -> ${this.#hierarchy}`);
        }
        this.#handlers.recalibrate();
    }
_recalibrate ( ) { let reference = this ; let nested_data = this . _get_included_files ( ) ; let included_files = nested_data . files ; let included_paths = nested_data . paths ; let current_pointers = { } ; this . #nested_pointers = this . #nested_pointers . filter ( ( pointer ) => { let verdict = true ; let path = pointer . path ; let line_position = pointer . line ; let nested_file = reference . #file_store [ path ] ; let position_check = included_files [ line_position ] ; if ( position_check == undefined || position_check . path !== path ) verdict = false ; if ( ! verdict ) { nested_file . pointers -- ; if ( nested_file . pointers < 1 && ! included_paths [ path ] ) { nested_file . destroy ( ) ; delete reference . #file_store [ path ] ; } } if ( verdict ) current_pointers [ line_position ] = path ; return verdict ; } ) ; let sort_pointers = false ; Object . keys ( included_files ) . forEach ( ( line_position ) => { let new_pointer = included_files [ line_position ] ; let pointer_check = current_pointers [ line_position ] === undefined ; if ( pointer_check ) { let path = new_pointer . path ; let spacing = new_pointer . spacing ; if ( reference . #file_store [ path ] == undefined ) { let nested_file = new NestedLiveFile ( { path : path , tags : reference . #tags , watcher_pool : reference . #watcher_pool , forbidden : reference . #forbidden , hierarchy : reference . #hierarchy , } ) ; nested_file . handle ( 'logger' , ( message ) => this . #handlers . logger ( message ) ) ; nested_file . handle ( 'error' , ( path , error ) => reference . #handlers . error ( path , error ) ) ; nested_file . handle ( 'recalibrate' , ( ) => reference . #handlers . recalibrate ( ) ) ; nested_file . pointers = 0 ; reference . #file_store [ path ] = nested_file ; } reference . #file_store [ path ] . pointers ++ ; sort_pointers = true ; reference . #nested_pointers . push ( { line : line_position , path : path , spacing : spacing , } ) ; } } ) ; if ( sort_pointers ) this . #nested_pointers . sort ( ( a , b ) => a . line - b . line ) ; if ( ! this . #initialized ) { this . #initialized = true ; this . _log ( ` ${ this . #hierarchy } ` ) ; } else { this . _log ( ` ${ this . #hierarchy } ` ) ; } this . #handlers . recalibrate ( ) ; }
INTERNAL METHOD!
INTERNAL METHOD!
// Retrieve file inclusions // Remove old file pointers and references // Check whether a valid include call with matching exists at line position // Decrease nested_file pointers to keep track of whether this nested file is still needed // Destroy nested file if it has no dependent pointers and the path is no longer included in nested data // Store current pointers in object faster referencing in next loop // Create new file pointers and references // Create new nested file reference in file store if one does not exist // Bind passthrough logger // Bind passthrough error handler // Bind passthrough recalibrate handler // Initiate nested file into file store with 0 pointers // Iterate nested file pointers to signify multiple inclusion calls // Push pointer to nested pointers and mark for re-sorting // Sort pointers from lowest to highest line positions