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:
- Properties.js, line 69
Methods
-
<static> addAccessor(propertyName, getter, setter, isEnumerable, isConfigurable)
-
Adds single accessor property to the context.
This:
Parameters:
Name Type Argument Description propertyNamestring Property name. getterfunction <optional>
Property getter. setterfunction <optional>
Property setter. isEnumerableboolean <optional>
isConfigurableboolean <optional>
- Source:
- Properties.js, line 168
-
<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 propertiesobject | function Property object or its generator function. isWritableboolean <optional>
isEnumerableboolean <optional>
isConfigurableboolean <optional>
- Source:
- Properties.js, line 193
Returns:
- Type
- troop.Base
-
<static> addProperty(propertyName, value, isWritable, isEnumerable, isConfigurable)
-
Adds single value property to the context.
This:
Parameters:
Name Type Argument Description propertyNamestring Property name. value* Property value to be assigned. isWritableboolean <optional>
isEnumerableboolean <optional>
isConfigurableboolean <optional>
- Source:
- Properties.js, line 144
-
<static> getOwnerOf(propertyName, host) → {object|undefined}
-
Retrieves the object from the host's prototype chain that owns the specified property.
Parameters:
Name Type Description propertyNamestring hostobject - Source:
- Properties.js, line 81
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 hostobject propertyNamestring - Source:
- Properties.js, line 127
- 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 hostobject baseobject <optional>
Object.prototype - Source:
- Properties.js, line 99