API Docs for: 0.0.1
Show:

Classes Class

Module: extra/classes.js
Parent Module: js-ext

Pollyfils for often used functionality for Functions Copyright (c) 2014 ITSA - https://github.com/itsa New BSD License - http://choosealicense.com/licenses/bsd-3-clause/

Methods

_destroy

() private chainable

Defined in src/js-ext/extra/classes.js:408

Available since 0.0.1

Transformed from destroy --> when destroy gets invoked, the instance will invoke _destroy through the whole chain. Defaults to NOOP, so that it can be always be invoked.

afterInit

() private chainable

Defined in src/js-ext/extra/classes.js:419

Available since 0.0.1

Transformed from destroy --> when destroy gets invoked, the instance will invoke _destroy through the whole chain. Defaults to NOOP, so that it can be always be invoked.

createBaseClass

() Class protected

Defined in src/js-ext/extra/classes.js:578

Available since 0.0.1

Creates the base Class: the highest Class in the hierarchy of all Classes. Will get extra properties merge into its prototype, which leads into the formation of BaseClass.

Returns:

Class:

createClass

(
  • [constructor]
  • [prototype]
)
Class

Returns a base class with the given constructor and prototype methods

Parameters:

  • [constructor] Function optional

    constructor for the class

  • [prototype] Object optional

    Hash map of prototype members of the new class

Returns:

Class:

the new class

defineProperties

(
  • [object]
  • [map]
  • [force=false]
)
protected

Defined in src/js-ext/extra/classes.js:69

Available since 0.0.1

Sugarmethod for using defineProperty for multiple properties at once.

Parameters:

  • [object] Object optional

    The object to define the property to

  • [map] Object optional

    object to be set

  • [force=false] Boolean optional

    to force assignment when the property already exists

defineProperty

(
  • [object]
  • [name]
  • [method]
  • [force=false]
)
protected

Defined in src/js-ext/extra/classes.js:47

Available since 0.0.1

Sugarmethod for Object.defineProperty creating an unenumerable property

Parameters:

  • [object] Object optional

    The object to define the property to

  • [name] String optional

    name of the property

  • [method] Any optional

    value of the property

  • [force=false] Boolean optional

    to force assignment when the property already exists

destroy

(
  • [notChained=false]
)
chainable

Defined in src/js-ext/extra/classes.js:430

Available since 0.0.1

Calls _destroy on through the class-chain on every level (bottom-up). _destroy gets defined when the itag defines destroy --> transformation under the hood.

Parameters:

  • [notChained=false] Boolean optional

    set this true to prevent calling destroy up through the chain

mergePrototypes

(
  • prototypes
  • force
)
chainable

Merges the given prototypes of properties into the prototype of the Class.

Note1 to be used on instances --> ONLY on Classes Note2 properties with getters and/or unwritable will NOT be merged

The members in the hash prototypes will become members with instances of the merged class.

By default, this method will not override existing prototype members, unless the second argument force is true.

Parameters:

  • prototypes Object

    Hash prototypes of properties to add to the prototype of this object

  • force Boolean

    If true, existing members will be overwritten

NOOP

() protected

Defined in src/js-ext/extra/classes.js:90

Available since 0.0.1

Empty function

removePrototypes

(
  • properties
)
chainable

Removes the specified prototypes from the Class.

Parameters:

  • properties String | Array

    Hash of properties to be removed from the Class

setConstructor

(
  • [constructorFn]
  • [prototypes]
  • [chainConstruct=true]
)
chainable

Redefines the constructor fo the Class

Parameters:

  • [constructorFn] Function optional

    The function that will serve as the new constructor for the class. If undefined defaults to NOOP

  • [prototypes] Object optional

    Hash map of properties to be added to the prototype of the new class.

  • [chainConstruct=true] Boolean optional

    Whether -during instance creation- to automaticly construct in the complete hierarchy with the given constructor arguments.

subClass

(
  • [constructor]
  • [prototypes]
  • [chainConstruct=true]
)

Returns a newly created class inheriting from this class using the given constructor with the prototypes listed in prototypes merged in.

The newly created class has the $$super static property available to access all of is ancestor's instance methods.

Further methods can be added via the mergePrototypes.

Parameters:

  • [constructor] Function optional

    The function that will serve as constructor for the new class. If undefined defaults to NOOP

  • [prototypes] Object optional

    Hash map of properties to be added to the prototype of the new class.

  • [chainConstruct=true] Boolean optional

    Whether -during instance creation- to automaticly construct in the complete hierarchy with the given constructor arguments.

Returns:

the new class.

Example:

var Circle = Shape.subClass( function (x, y, r) { // arguments will automaticly be passed through to Shape's constructor this.r = r; }, { area: function () { return this.r this.r Math.PI; } } );

Properties

BASE_MEMBERS

Object protected

Defined in src/js-ext/extra/classes.js:398

Available since 0.0.1

Base properties for every Class

BaseClass

Class

Defined in src/js-ext/extra/classes.js:593

Available since 0.0.1

The base BaseClass: the highest Class in the hierarchy of all Classes.

DEFAULT_CHAIN_CONSTRUCT

Boolean protected

Defined in src/js-ext/extra/classes.js:36

Available since 0.0.1

Defines whether Classes should call their constructor in a chained way top-down.

Default: true

PROTECTED_CLASS_METHODS

Object protected

Defined in src/js-ext/extra/classes.js:112

Available since 0.0.1

Internal hash containing protected members: those who cannot be merged into a Class

Default: {$super: true, $superProp: true, $orig: true}

REPLACE_CLASS_METHODS

Object protected

Defined in src/js-ext/extra/classes.js:99

Available since 0.0.1

Internal hash containing the names of members which names should be transformed

Default: {destroy: '_destroy'}