Skip to content

⬅️ Back to Table of Contents

📄 DataMap.js

📊 Analysis Summary

Metric Count
🔧 Functions 4
🧱 Classes 1
📊 Variables & Constants 1

📚 Table of Contents

🛠️ File Location:

📂 src/renderers/common/DataMap.js

Variables & Constants

Name Type Kind Value Exported
map any let/var null

Functions

DataMap.get(object: any): any

JSDoc:

/**
     * Returns the dictionary for the given object.
     *
     * @param {Object} object - The object.
     * @return {Object} The dictionary.
     */

Parameters:

  • object any

Returns: any

Calls:

  • this.data.get
  • this.data.set
Code
get( object ) {

        let map = this.data.get( object );

        if ( map === undefined ) {

            map = {};
            this.data.set( object, map );

        }

        return map;

    }

DataMap.delete(object: any): any

JSDoc:

/**
     * Deletes the dictionary for the given object.
     *
     * @param {Object} object - The object.
     * @return {?Object} The deleted dictionary.
     */

Parameters:

  • object any

Returns: any

Calls:

  • this.data.has
  • this.data.get
  • this.data.delete
Code
delete( object ) {

        let map = null;

        if ( this.data.has( object ) ) {

            map = this.data.get( object );

            this.data.delete( object );

        }

        return map;

    }

DataMap.has(object: any): boolean

JSDoc:

/**
     * Returns `true` if the given object has a dictionary defined.
     *
     * @param {Object} object - The object to test.
     * @return {boolean} Whether a dictionary is defined or not.
     */

Parameters:

  • object any

Returns: boolean

Calls:

  • this.data.has
Code
has( object ) {

        return this.data.has( object );

    }

DataMap.dispose(): void

JSDoc:

/**
     * Frees internal resources.
     */

Returns: void

Code
dispose() {

        this.data = new WeakMap();

    }

Classes

DataMap

Class Code
class DataMap {

    /**
     * Constructs a new data map.
     */
    constructor() {

        /**
         * `DataMap` internally uses a weak map
         * to manage its data.
         *
         * @type {WeakMap}
         */
        this.data = new WeakMap();

    }

    /**
     * Returns the dictionary for the given object.
     *
     * @param {Object} object - The object.
     * @return {Object} The dictionary.
     */
    get( object ) {

        let map = this.data.get( object );

        if ( map === undefined ) {

            map = {};
            this.data.set( object, map );

        }

        return map;

    }

    /**
     * Deletes the dictionary for the given object.
     *
     * @param {Object} object - The object.
     * @return {?Object} The deleted dictionary.
     */
    delete( object ) {

        let map = null;

        if ( this.data.has( object ) ) {

            map = this.data.get( object );

            this.data.delete( object );

        }

        return map;

    }

    /**
     * Returns `true` if the given object has a dictionary defined.
     *
     * @param {Object} object - The object to test.
     * @return {boolean} Whether a dictionary is defined or not.
     */
    has( object ) {

        return this.data.has( object );

    }

    /**
     * Frees internal resources.
     */
    dispose() {

        this.data = new WeakMap();

    }

}

Methods

get(object: any): any
Code
get( object ) {

        let map = this.data.get( object );

        if ( map === undefined ) {

            map = {};
            this.data.set( object, map );

        }

        return map;

    }
delete(object: any): any
Code
delete( object ) {

        let map = null;

        if ( this.data.has( object ) ) {

            map = this.data.get( object );

            this.data.delete( object );

        }

        return map;

    }
has(object: any): boolean
Code
has( object ) {

        return this.data.has( object );

    }
dispose(): void
Code
dispose() {

        this.data = new WeakMap();

    }