Classes that manage the namespaces. This class provides the ability to add or delete namespaces and manage elements. It also provides serialization and deserialization of the namespace repository.

Implements

Constructors

  • Create a Namespace Manager.

    Returns NamespaceManager

Properties

_elemTypes: any[]

Namespace element type list. If the element type is empty, the entire type is allowed.

_list: string[]

Namespace element list.

count: number

Total number of Namespace elements.

isOverlap: boolean

Set whether to allow duplicate element registration. Default is 'false' and does not allow duplication.

Methods

  • Protected

    Obtain a Namespace path object.

    Parameters

    • elem: string | object

      The element to obtain the path.

    Returns PathObject

    Namespace path object. {ns: '...', key: '...'}

  • Add an element to the Namespace path.

    Parameters

    • fullName: string

      The full path name of the namespace.

    • elem: any

      The element to add.

    Returns void

  • Add a path to the Namespace.

    Parameters

    • ns: string | string[]

      Names or array of names to add.

    Returns void

  • Delete an element from the Namespace path.

    Parameters

    • fullName: string

      The full path name of the namespace.

    Returns boolean

    Deletion successful.

  • Delete the path from the Namespace.

    Parameters

    • ns: string | string[]

      Names or array of names to delete.

    Returns void

  • Finds and returns the element in the Namespace path.

    Parameters

    • fullName: string

      The full path name of the namespace.

    Returns object | Function

    Found element or 'undefined'.

  • Gets the path from the element in the Namespace.

    Returns the path of the first element upon duplication.

    Parameters

    • elem: any

      The element to obtain the path.

    Returns string

    path or 'undefined'.

  • Verify that certain elements exist in the Namespace.

    Parameters

    • elem: any

      Path or element to check. The presence or absence of the element @returns{boolean}.

    Returns boolean

  • Initialize the namespace. This method empties the namespace repository and returns it to its initial state.

    Returns void

  • Pars the string and load it into the Namespace repository.

    Parameters

    • str: string

      Serialized string.

    • Optionalparse: Function

      JSON parser function. Default is 'JSON.parse'.

    Returns void

  • Serialize the Namespace repository as a string. You can specify a separate stringify function for JSON serialization.

    Parameters

    • Optionalstringify: Function

      JSON stringify function. Default is 'JSON.stringify'.

    • Optionalspace: string

      A blank string to apply to the JSON string.

    Returns string

    serialized string.

  • Obtain a path object from the Namespace.

    Parameters

    • ns: string | string[]

      Namespace name or array of names.

    Returns object

    Namespace path object.