- Source:
- namespace.js, line 6
Classes
Members
-
<static> messy :boolean
-
When true, all properties are writable, so they can be modified through assignment.
- Source:
- Properties.js, line 507
-
<static> privatePrefix :string
-
Prefix applied to names of private properties and methods.
- Source:
- Properties.js, line 500
-
<static> testing :boolean
-
Whether Troop is in testing mode (application state)
- Source:
- Feature.js, line 75
-
<static> writable :boolean
-
Whether methods should be writable (environmental)
- Source:
- Feature.js, line 69
Methods
-
<static> amendPostponed(host, propertyName, modifier)
-
Applies a modifier to the postponed property to be called AFTER the property is resolved. Amendments are resolved in the order they were applied. Amendments should not expect other amendments to be applied.
Parameters:
Name Type Description host
object Host object. propertyName
string Property name. modifier
function Amends property value. Arguments: host object, property name, plus all extra arguments passed to .amendPostponed(). Return value is discarded. - Source:
- Postpone.js, line 141
Example
var ns = {}; troop.postpone(ns, 'foo', function () { ns.foo = {hello: "World"}; }); //... troop.amendPostponed(ns, 'foo', function () { ns.foo.howdy = "Fellas"; }); // howdy is not added until first access to `ns.foo`
-
<static> postpone(host, propertyName, generator)
-
Postpones a property definition on the specified object until first access. Initially assigns a special getter to the property, then, when the property is accessed for the first time, the property is assigned the return value of the generator function, unless a value has been assigned from within the generator.
Parameters:
Name Type Description host
object Host object. propertyName
string Property name. generator
function Generates (and returns) property value. Arguments: host object, property name, plus all extra arguments passed to .postpone(). - Source:
- Postpone.js, line 58
Example
var obj = {}; troop.postpone(obj, 'foo', function () { return "bar"; }); obj.foo // runs generator and alerts "bar"