Fetching latest commit…
Cannot retrieve the latest commit at this time.
..
Failed to load latest commit information.
examples
CHANGELOG.md
README.md
classify.docs.js
classifyjs.com.html

README.md

classify v0.10.2

Classify

Classify.Class

Classify.Class.prototype

Classify.Namespace

Classify.Namespace.prototype

Classify.Observer

Classify.Observer.prototype

Classify

Classify()

The Main interface function that returns namespaces and creates objects.

Returns

Classify.Class

Example
<span class="comment">// Different ways to call Classify</span>

<span class="comment">// Calling Classify with a string returns a namespace</span>
<span class="comment">// @see Classify.getNamespace</span>
Classify(<span class="string">"Vehicles"</span>) === Classify.getNamespace(<span class="string">"Vehicles"</span>);

<span class="comment">// Calling Classify with a string ending in a "/" returns a namespace</span>
<span class="comment">// @see Classify.getNamespace</span>
Classify(<span class="string">"Vehicles"</span>) === Classify.getNamespace(<span class="string">"Vehicles"</span>);

<span class="comment">// Calling Classify with a string separated by "/" returns a defined</span>
<span class="comment">// class within a namespace</span>
<span class="comment">// @see Classify.Namespace.get</span>
Classify(<span class="string">"Vehicles/Ship"</span>) === Classify.getNamespace(<span class="string">"Vehicles"</span>).get(<span class="string">"Ship"</span>);

<span class="comment">// Calling Classify with 2 string parameters returns a defined class within</span>
<span class="comment">// a namespace</span>
<span class="comment">// @see Classify.Namespace.get</span>
Classify(<span class="string">"Vehicles"</span>, <span class="string">"Ship"</span>) === Classify.getNamespace(<span class="string">"Vehicles"</span>).get(<span class="string">"Ship"</span>);

<span class="comment">// Calling Classify with first parameter as a string, and second parameter as</span>
<span class="comment">// an object, creates a class within the namespace</span>
<span class="keyword">var</span> Ship = Classify(<span class="string">"Vehicles/Ship"</span>, {
    init : <span class="keyword">function</span>() {
    }
});
<span class="comment">// Calling Classify with first parameter as a string, second parameter as a string, and</span>
<span class="comment">// third parameter as an object, creates a class within the namespace</span>
<span class="keyword">var</span> Ship = Classify(<span class="string">"Vehicles"</span>, <span class="string">"Ship"</span>, {
    init : <span class="keyword">function</span>() {
    }
});
<span class="comment">// The above 2 statements are the same as the following statement to create classes</span>
<span class="comment">// @see Classify.Namespace.create</span>
<span class="keyword">var</span> Ship = Classify.getNamespace(<span class="string">"Vehicles"</span>).create(<span class="string">"Ship"</span>, {
    init : <span class="keyword">function</span>() {
    }
});

<span class="comment">// To inherit from other classes, the first parameter is the class name, second parameter</span>
<span class="comment">// is the parent (can be from other namespaces with "Namespace/Class"), third parameter</span>
<span class="comment">// is the descriptor</span>
<span class="keyword">var</span> Battleship = Classify(<span class="string">"Vehicles/Battleship"</span>, <span class="string">"Ship"</span>, {
    init : <span class="keyword">function</span>() {
    }
});
<span class="comment">// The same can be achieved with the following signature</span>
<span class="keyword">var</span> Battleship = Classify(<span class="string">"Vehicles"</span>, <span class="string">"Battleship"</span>, <span class="string">"Ship"</span>, {
    init : <span class="keyword">function</span>() {
    }
});
<span class="comment">// The above 2 statements are the same as the following statement to create classes</span>
<span class="comment">// @see Classify.Namespace.create</span>
<span class="keyword">var</span> Battleship = Classify.getNamespace(<span class="string">"Vehicles"</span>).create(<span class="string">"Battleship"</span>, <span class="string">"Ship"</span>, {
    init : <span class="keyword">function</span>() {
    }
});

<span class="comment">// Calling Classify with objects with create classes with the object descriptor.</span>
<span class="comment">// Using the Classify method in this manner is analogous to calling Classify.create()</span>
<span class="comment">// Please see Classify.create for documentation</span>
<span class="comment">// @see Classify.create</span>
<span class="keyword">var</span> Energy = Classify({
    init : <span class="keyword">function</span>() {
    }
});
<span class="comment">// The above statement is the same as</span>
<span class="keyword">var</span> Energy = Classify.create({
    init : <span class="keyword">function</span>() {
    }
});

Classify.version

The version number of this file.

String: The version number of this file

Classify.Classify

Circular reference to itself.

Function: Circular reference to itself

Classify.create([parent][, implement], definition)

Creates a new Classify class.

Arguments
  1. [parent] {Classify.Class}: Optional first parameter defines what object to inherit from
  2. [implement] {Object[]}: Optional second parameter defines where to implement traits from
  3. definition {Object}: The description of the class to be created
Returns

Classify.Class

Classify.getNamespace(namespace)

Retrieves a namespace and creates if it it doesn't already exist.

Arguments
  1. namespace {String}: Dot separated namespace string
Returns

Classify.Namespace

Classify.destroyNamespace(namespace)

Destroy an existing namespace.

Arguments
  1. namespace {String}: Dot separated namespace string

Classify.testNamespace(namespace)

Retrieves the first namespace that matches the namespace chain "Ns1.ns2.ns3.ns4".

Arguments
  1. namespace {String}: Dot separated namespace string
Returns

Classify.Namespace

Classify.getGlobalNamespace()

Retieves the globally named namespace.

Returns

Classify.Namespace

Classify.global

The globally named namespace.

Classify.Namespace: The globally named namespace

Classify.addMutator(name, mutator[, mutator.onCreate][, mutator.onPropAdd][, mutator.onPropRemove][, mutator.onInit])

Adds a global class mutator that modifies the defined classes at different points with hooks.

Arguments
  1. name {String}: The name of the mutator reference to add
  2. mutator {Object}: The mutator definition with optional hooks
  3. [mutator.onCreate] {Function}: The hook to be called when a class is defined
  4. [mutator.onPropAdd] {Function}: The hook to be called when a property with the $$name$$ prefix is added
  5. [mutator.onPropRemove] {Function}: The hook to be called when a property with the $$name$$ prefix is removed
  6. [mutator.onInit] {Function}: The hook to be called during each object's initialization

Classify.removeMutator(name)

Removes a global class mutator that modifies the defined classes at different points.

Arguments
  1. name {String}: The name of the mutator to be removed

Classify.extend(base, args)

Utility function to provide functionality to quickly add properties to objects.

Arguments
  1. base {Object}: The base object to copy properties into
  2. args {Object[]}: Set of objects to copy properties from
Returns

Object

Classify.provide(namespace, base)

Utility function to provide functionality to allow for name provisioning.

Arguments
  1. namespace {String}: The dot separated namespace tree to create
  2. base {Object}: The object to create the namespace tree within
Returns

Object

Classify.noConflict()

Utility function for web to avoid namespace issues with other libraries.

Returns

Classify

Example
(function(Classify) {
    // here you can use the Classify object and remove the global reference to it
    // this function is only available on browser environments
})(Classify.noConflict());

Classify.Class

Classify.Class()

Placeholder for class descriptors created with the create method.

Constructor method

Classify.Class.$$superclass

Reference to the parent that this object extends from.

Classify.Class: Reference to the parent that this object extends from

Classify.Class.$$subclass

Array containing a reference to all the children that inherit from this object.

Array: Array containing a reference to all the children that inherit from this object

Classify.Class.$$implement

Array containing all the objects and classes that this object implements methods and properties from.

Array: Array containing all the objects and classes that this object implements methods and properties from

Classify.Class.bindings

Array containing the list of all the bound properties that is wrapped during object initialization.

Array: Array containing the list of all the bound properties that is wrapped during object initialization

Classify.Class.$$isclass

Flag to determine if this object is created by Classify.create.

Boolean: Flag to determine if this object is created by Classify.create

Classify.Class.invoke()

Default invocation function when the defined class is called without the "new" keyword. The default behavior is to return a new instance of itself.

Returns

Classify.Class

Classify.Class.$$apply(args)

Create a new instance of the class using arguments passed in as an array.

Arguments
  1. args {Array}: Array of arguments to construct the object with
Returns

Classify.Class

Classify.Class.extend([implement], definition)

Creates a new class that is a child of the current class.

Arguments
  1. [implement] {Object[]}: Optional parameter defines where to implement traits from
  2. definition {Object}: The description of the class to be created
Returns

Classify.Class

Classify.Class.addProperty(name[, property][, prefix=""])

Adds a new property to the object's prototype of base.

Arguments
  1. name {String|Object}: The property name to add or if object is passed in then it will iterate through it to add properties
  2. [property] {Object}: The property to add to the class
  3. [prefix=""] {String}: Prefix of the property name if any
Returns

Classify.Class

Classify.Class.removeProperty(name)

Removes a property from the object's prototype or base.

Arguments
  1. name {String}: The name of the property to remove
Returns

Classify.Class

Classify.Class.addStaticProperty(name, property)

Adds a static property to the object's base.

Arguments
  1. name {String}: The name of the property to add
  2. property {Object}: The property to store into the object's base
Returns

Classify.Class

Classify.Class.removeStaticProperty(name)

Removes a static property from the object's base.

Arguments
  1. name {String}: The name of the property to remove
Returns

Classify.Class

Classify.Class.addBoundProperty(name, property)

Adds a context bound property to the object's prototype.

Arguments
  1. name {String}: The name of the property to add
  2. property {Function}: The property to always bind the object's context with
Returns

Classify.Class

Classify.Class.removeBoundProperty(name)

Removes a context bound property from the object's base.

Arguments
  1. name {String}: The name of the property to remove
Returns

Classify.Class

Classify.Class.addAliasedProperty(name, property)

Adds a aliased property to the object's prototype based on a existing prototype method.

Arguments
  1. name {String}: The name of the alias for the new property
  2. property {String}: The name of the property alias
Returns

Classify.Class

Classify.Class.addUnwrappedProperty(name, property)

Adds a property to the object's prototype that is not wrapped in the parent method wrapper.

Arguments
  1. name {String}: The name of the new property
  2. property {String}: The name of the property to add
Returns

Classify.Class

Classify.Class.prototype

Classify.Class.prototype

Prototype chain for Classify.Class.

Object: Prototype chain for Classify.Class

Classify.Class.prototype.constructor

Reference to the constructor function of this object.

Classify.Class: Reference to the constructor function of this object

Classify.Class.prototype.init()

True constructor method for this object, will be called when object is called with the "new" keyword.

Returns

Classify.Class

Classify.Class.prototype.$$parent()

Internal reference property for methods that override a parent method, allow for access to the parent version of the function.

Returns

Object

Classify.Class.prototype.extend([implement], definition)

Creates a new class that is a child of the current class.

Arguments
  1. [implement] {Object[]}: Optional parameter defines where to implement traits from
  2. definition {Object}: The description of the class to be created
Returns

Classify.Class

Classify.Class.prototype.$$apply(name, args)

Magic method that can invoke any of the parent methods with an array of arguments.

Arguments
  1. name {Object}: The name of the parent method to invoke
  2. args {Array}: The arguments to pass through to invoke
Returns

Object

Classify.Class.prototype.$$call(name, [arg1, [arg2...]])

Magic method that can invoke any of the parent methods with a series of arguments.

Arguments
  1. name {Object}: The name of the parent method to invoke
  2. [arg1] {Object}: Optional argument
  3. [arg2] {Object}: Optional argument
Returns

Object

Classify.Namespace

Classify.Namespace(name)

Namespace container that hold a tree of classes.

Constructor method
Extends Classify.Class
Arguments
  1. name {String}: The name of the namespace to construct with

Classify.Namespace.prototype

Classify.Namespace.prototype

Prototype chain for Classify.Namespace.

Classify.Class: Prototype chain for Classify.Namespace

Classify.Namespace.prototype.name

The name of the namespace.

String: The name of the namespace

Classify.Namespace.prototype.ref

Hashtable containing references to all the classes created within this namespace.

Object: Hashtable containing references to all the classes created within this namespace

Classify.Namespace.prototype.create(name[, parent][, implement], definition)

Creates a new class within this namespace.

Arguments
  1. name {String}: The name of the created class within the namespace
  2. [parent] {String|Classify.Class}: Optional second parameter defines what object to inherit from, can be a string referencing a class within any namespace
  3. [implement] {Object[]}: Optional third parameter defines where to implement traits from
  4. definition {Object}: The description of the class to be created
Returns

Classify.Class

Classify.Namespace.prototype.destroy(classname)

Removes a defined class from this namespace and it's children classes.

Arguments
  1. classname {String}: Name of class to remove from this namespace
Returns

Classify.Namespace

Classify.Namespace.prototype.exists(classname)

Checks if a class exists within this namespace.

Arguments
  1. classname {String}: Name of class to check if it has already been defined
Returns

Boolean

Classify.Namespace.prototype.get(name)

Attempt to retrieve a class within this namespace or the global one.

Arguments
  1. name {String}: The name of the class to retrieve

Classify.Namespace.prototype.load(name)

Default loader function that loads the internal classes from.

Arguments
  1. name {String}: The name of the class to load
Returns

Classify.Namespace

Classify.Namespace.prototype.setAutoloader(callback)

Sets the internal autoloader by overriding the Classify.Namespace.prototype.load method.

Arguments
  1. callback {Function}: The function to call when a class that doesn't exist needs to be loaded
Returns

Classify.Namespace

Classify.Namespace.prototype.getName()

Gets the name of this namespace.

Classify.Namespace.prototype.toString()

Gets the translated toString name of this object "[namespace Name]".

Classify.Observer

Classify.Observer(value, value.value[, value.writable=true][, value.delay=0][, value.getter][, value.setter])

Wrapper object that allows for getter/setter/event listeners of object properties.

Constructor method
Extends Classify.Class
Arguments
  1. value {Object}: The internal value can be either an object or a value
  2. value.value {Object}: The internal value if the parameter was passed in as an object
  3. [value.writable=true] {Boolean}: Marks this object as writable or readonly
  4. [value.delay=0] {Number}: Only fire the event emitter after a delay of value.delay ms
  5. [value.getter] {Function}: The internal get modifier
  6. [value.setter] {Function}: The internal set modifier

Classify.Observer.prototype

Classify.Observer.prototype

Prototype chain for Classify.Observer.

Classify.Class: Prototype chain for Classify.Observer

Classify.Observer.prototype.context

The context that this object is created within.

Classify.Class: The context that this object is created within

Classify.Observer.prototype.name

The name of the property that this object observes.

String: The name of the property that this object observes

Classify.Observer.prototype.writable

Flag to check if this property is writable.

Boolean: Flag to check if this property is writable

Classify.Observer.prototype.delay

Number of seconds to delay the event emitter, 0 will disable delays.

Number: Number of seconds to delay the event emitter, 0 will disable delays

Classify.Observer.prototype._debounce

Flag to hold the delay timer.

Number: Flag to hold the delay timer

Classify.Observer.prototype.value

The internal value of this object.

Object: The internal value of this object

Classify.Observer.prototype.events

Array containing all the event listeners for when this value changes.

Array: Array containing all the event listeners for when this value changes

Classify.Observer.prototype.getter(value)

Internal getter method that modifies the internal value being returned by the Classify.Observer.prototype.get method.

Arguments
  1. value {Object}: The internal value of this object
Returns

Object

Classify.Observer.prototype.setter(value, original)

Internal setter method that modifies the internal value being set by the Classify.Observer.prototype.set method.

Arguments
  1. value {Object}: The new value that will be set
  2. original {Object}: The original internal value of this object
Returns

Object

Classify.Observer.prototype.get()

Gets the value of the internal property.

Returns

Object

Classify.Observer.prototype.set(value)

Sets the value of the internal property.

Arguments
  1. value {Object}: Mixed value to store internally
Returns

Classify.Class

Classify.Observer.prototype.emit()

Starts the timers to call the registered event listeners.

Returns

Classify.Class

Classify.Observer.prototype._triggerEmit(args)

Fires the event listeners in the order they were added.

Arguments
  1. args {Array}: Array of arguments to pass to the bound event listeners

Classify.Observer.prototype.addListener(listener)

Add an event listener for when the internal value is changed.

Arguments
  1. listener {Function}: The event listener to add
Returns

Classify.Class

Classify.Observer.prototype.on(listener)

Add an event listener for when the internal value is changed, alias to addListener.

Arguments
  1. listener {Function}: The event listener to add
Returns

Classify.Class

Classify.Observer.prototype.once(listener)

Add an event listener to be called only once when the internal value is changed.

Arguments
  1. listener {Function}: The event listener to add
Returns

Classify.Class

Classify.Observer.prototype.removeListener(listener)

Remove an event listener from being fired when the internal value is changed.

Arguments
  1. listener {Function}: The event listener to remove
Returns

Classify.Class

Classify.Observer.prototype.removeAllListeners()

Remove all event listeners from this object.

Returns

Classify.Class

Classify.Observer.prototype.listeners()

Returns the array of internal listeners.

Returns

Array

Classify.Observer.prototype.toValue()

Returns the internal value of this object in the scalar form.

Returns

Boolean|Number|String

Classify.Observer.prototype.toString()

Returns the special name of this object.

Returns

String