A Key represents the unique identifier of an object. Our Key scheme is inspired by file systems and Google App Engine key model. Keys are meant to be unique across a system. Keys are hierarchical, incorporating more and more specific namespaces. Thus keys can be deemed 'children' or 'ancestors' of other keys:

  • new Key('/Comedy')
  • new Key('/Comedy/MontyPython') Also, every namespace can be parametrized to embed relevant object information. For example, the Key name (most specific namespace) could include the object type:
  • new Key('/Comedy/MontyPython/Actor:JohnCleese')
  • new Key('/Comedy/MontyPython/Sketch:CheeseShop')
  • new Key('/Comedy/MontyPython/Sketch:CheeseShop/Character:Mousebender')

Constructors

Properties

Accessors

Methods

  • Returns the "base" namespace of this key.

    Returns string

    Example

    new Key('/Comedy/MontyPython/Actor:JohnCleese').baseNamespace()
    // => 'Actor:JohnCleese'
  • Returns the child Key of this Key.

    Parameters

    • key: Key

      The child Key to add

    Returns Key

    Example

    new Key('/Comedy/MontyPython').child(new Key('Actor:JohnCleese'))
    // => Key('/Comedy/MontyPython/Actor:JohnCleese')
  • Returns an "instance" of this type key (appends value to namespace).

    Parameters

    • s: string

      The string to append.

    Returns Key

    Example

    new Key('/Comedy/MontyPython/Actor').instance('JohnClesse')
    // => Key('/Comedy/MontyPython/Actor:JohnCleese')
  • Returns whether this key is a prefix of other

    Parameters

    • other: Key

      The other key to test against

    Returns boolean

    Example

    new Key('/Comedy').isAncestorOf('/Comedy/MontyPython')
    // => true
  • Returns whether this key is a contains another as prefix.

    Parameters

    • other: Key

      The other Key to test against

    Returns boolean

    Example

    new Key('/Comedy/MontyPython').isDecendantOf('/Comedy')
    // => true
  • Returns the list representation of this key.

    Returns string[]

    Example

    new Key('/Comedy/MontyPython/Actor:JohnCleese').list()
    // => ['Comedy', 'MontyPythong', 'Actor:JohnCleese']
  • Returns the "name" of this key (field of last namespace).

    Returns string

    Example

    new Key('/Comedy/MontyPython/Actor:JohnCleese').name()
    // => 'JohnCleese'
  • Returns the parent Key of this Key.

    Returns Key

    Example

    new Key("/Comedy/MontyPython/Actor:JohnCleese").parent()
    // => Key("/Comedy/MontyPython")
  • Returns the "path" of this key (parent + type).

    Returns Key

    Example

    new Key('/Comedy/MontyPython/Actor:JohnCleese').path()
    // => Key('/Comedy/MontyPython/Actor')
  • Returns the key with all parts in reversed order.

    Returns Key

    Example

    new Key('/Comedy/MontyPython/Actor:JohnCleese').reverse()
    // => Key('/Actor:JohnCleese/MontyPython/Comedy')
  • Returns the "type" of this key (value of last namespace).

    Returns string

    Example

    new Key('/Comedy/MontyPython/Actor:JohnCleese').type()
    // => 'Actor'
  • Constructs a key out of a namespace array.

    Parameters

    • list: string[]

      The array of namespaces

    Returns Key

    Example

    Key.withNamespaces(['one', 'two'])
    // => Key('/one/two')