Class: Properties

troop. Properties

Allows properties to be added to arbitrary objects as if they were Troop classes. The Troop base class uses these methods internally. They are exposed however due to their usefulness in testing.
Source:

Methods

<static> addAccessor(propertyName, getter, setter, isEnumerable, isConfigurable)

Adds single accessor property to the context.
This:
Parameters:
Name Type Argument Description
propertyName string Property name.
getter function <optional>
Property getter.
setter function <optional>
Property setter.
isEnumerable boolean <optional>
isConfigurable boolean <optional>
Source:

<static> addProperties(properties, isWritable, isEnumerable, isConfigurable) → {troop.Base}

Adds a block of properties to the context having the specified attributes.
This:
Parameters:
Name Type Argument Description
properties object | function Property object or its generator function.
isWritable boolean <optional>
isEnumerable boolean <optional>
isConfigurable boolean <optional>
Source:
Returns:
Type
troop.Base

<static> addProperty(propertyName, value, isWritable, isEnumerable, isConfigurable)

Adds single value property to the context.
This:
Parameters:
Name Type Argument Description
propertyName string Property name.
value * Property value to be assigned.
isWritable boolean <optional>
isEnumerable boolean <optional>
isConfigurable boolean <optional>
Source:

<static> getOwnerOf(propertyName, host) → {object|undefined}

Retrieves the object from the host's prototype chain that owns the specified property.
Parameters:
Name Type Description
propertyName string
host object
Source:
Returns:
Type
object | undefined

<static> getPropertyDescriptor(host, propertyName) → {object|undefined}

Retrieves the property descriptor of the specified property regardless of its position on the prototype chain.
Parameters:
Name Type Description
host object
propertyName string
Source:
See:
  • Object.getOwnPropertyDescriptor
Returns:
Type
object | undefined

<static> getPropertyNames(host, base)

Collects all property names (including non-enumerable ones) from the entire prototype chain. Always excludes the properties of Object.prototype.
Parameters:
Name Type Argument Default Description
host object
base object <optional>
Object.prototype
Source: