Fork me on GitHub

AFrameJS

- Javascript MVC Library

static class AFrame

The AFrame base namespace. Provides some useful utility functions. The most commonly used functions are Class and create.

Methods

Methods Returns Description
array( itemToCheck ) boolean

Check whether an item is an array

// returns true
var isArray = AFrame.array( [] );

// returns true
isArray = AFrame.array( new Array() );

// returns false
isArray = AFrame.array( '' );

Parameters:

  • itemToCheck <variant>
    • Returns:

      • <boolean>

        true if item is an array, false otw.

create( constructor, config ) void
deprecated

Parameters:

  • constructor <function>
    • constructor to create
  • config <object>

    (optional) - configuration.

  • config.plugins <array>

    (optional) - Any plugins to attach

defined( itemToCheck ) boolean

Check whether an item is defined

 var isDefined = AFrame.func( valueToCheck );

Parameters:

  • itemToCheck <variant>
    • Returns:

      • <boolean>

        true if item is defined, false otw.

extendsFrom( subClass, superClass ) boolean

Checks whether the subClass is a sub-class of superClass, as is done using AFrame.extend or AFrame.Class.

var SubClass = AFrame.Class( AFrame.AObject );

// extendsFrom will be true;
var extendsFrom = AFrame.extendsFrom( SubClass, AFrame.AObject );

Parameters:

  • subClass <function>
    • the potential subclass
  • superClass <function>
    • the potential superclass
    • Returns:

      • <boolean>

        true if subClass is a subclass of superClass, false otw.

func( itemToCheck ) boolean

Check whether an item is a function

 var isFunc = AFrame.func( valueToCheck );

Parameters:

  • itemToCheck <variant>
    • Returns:

      • <boolean>

        true if item is a function, false otw.

getUniqueID( ) id

Get a unique ID

 var uniqueID = AFrame.getUniqueID();

Returns:

  • <id>

    a unique id

log( message ) void

If the console is available, log a message.

AFrame.log( 'message to log' );

Parameters:

  • message <string>
    • message to display
mixin( toExtend, mixin ) void

extend an object with the members of another object.

var objectToMixinTo = {
     name: 'AFrame'
};
AFrame.mixin( objectToMixinTo, '{ version: 1.0 } );

Parameters:

  • toExtend <object>
    • object to extend
  • mixin <object>

    (optional) - object with optional functions to extend bc with

remove( object, key ) void

Remove an item from an object freeing the reference to the item.

 var obj = {
    name: 'AFrame'
 };
 AFrame.remove( obj, 'name' );

Parameters:

  • object <object>

    to remove item from.

  • key <string>

    of item to remove

string( itemToCheck ) boolean

Check whether an item is a string

var isString = AFrame.string( valueToCheck );

Parameters:

  • itemToCheck <variant>
    • Returns:

      • <boolean>

        true if item is a string, false otw.