objectmakr
Advanced tools
Comparing version 0.6.1 to 0.6.3
@@ -1,1 +0,1 @@ | ||
var typedoc = typedoc || {};typedoc.search = typedoc.search || {};typedoc.search.data = {"kinds":{"1":"External module","128":"Class","256":"Interface","512":"Constructor","1024":"Property","2048":"Method"},"rows":[{"id":0,"kind":1,"name":"\"IObjectMakr\"","url":"modules/_iobjectmakr_.html","classes":"tsd-kind-external-module"},{"id":1,"kind":256,"name":"IClassInheritance","url":"interfaces/_iobjectmakr_.iclassinheritance.html","classes":"tsd-kind-interface tsd-parent-kind-external-module","parent":"\"IObjectMakr\""},{"id":2,"kind":256,"name":"IClassProperties","url":"interfaces/_iobjectmakr_.iclassproperties.html","classes":"tsd-kind-interface tsd-parent-kind-external-module","parent":"\"IObjectMakr\""},{"id":3,"kind":256,"name":"IClassFunctions","url":"interfaces/_iobjectmakr_.iclassfunctions.html","classes":"tsd-kind-interface tsd-parent-kind-external-module","parent":"\"IObjectMakr\""},{"id":4,"kind":256,"name":"IClassFunction","url":"interfaces/_iobjectmakr_.iclassfunction.html","classes":"tsd-kind-interface tsd-parent-kind-external-module","parent":"\"IObjectMakr\""},{"id":5,"kind":512,"name":"constructor","url":"interfaces/_iobjectmakr_.iclassfunction.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-interface","parent":"\"IObjectMakr\".IClassFunction"},{"id":6,"kind":256,"name":"IOnMakeFunction","url":"interfaces/_iobjectmakr_.ionmakefunction.html","classes":"tsd-kind-interface tsd-parent-kind-external-module","parent":"\"IObjectMakr\""},{"id":7,"kind":256,"name":"IObjectMakrSettings","url":"interfaces/_iobjectmakr_.iobjectmakrsettings.html","classes":"tsd-kind-interface tsd-parent-kind-external-module","parent":"\"IObjectMakr\""},{"id":8,"kind":1024,"name":"inheritance","url":"interfaces/_iobjectmakr_.iobjectmakrsettings.html#inheritance","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"IObjectMakr\".IObjectMakrSettings"},{"id":9,"kind":1024,"name":"properties","url":"interfaces/_iobjectmakr_.iobjectmakrsettings.html#properties","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"IObjectMakr\".IObjectMakrSettings"},{"id":10,"kind":1024,"name":"doPropertiesFull","url":"interfaces/_iobjectmakr_.iobjectmakrsettings.html#dopropertiesfull","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"IObjectMakr\".IObjectMakrSettings"},{"id":11,"kind":1024,"name":"indexMap","url":"interfaces/_iobjectmakr_.iobjectmakrsettings.html#indexmap","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"IObjectMakr\".IObjectMakrSettings"},{"id":12,"kind":1024,"name":"onMake","url":"interfaces/_iobjectmakr_.iobjectmakrsettings.html#onmake","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"IObjectMakr\".IObjectMakrSettings"},{"id":13,"kind":1024,"name":"functions","url":"interfaces/_iobjectmakr_.iobjectmakrsettings.html#functions","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"IObjectMakr\".IObjectMakrSettings"},{"id":14,"kind":1024,"name":"scope","url":"interfaces/_iobjectmakr_.iobjectmakrsettings.html#scope","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"IObjectMakr\".IObjectMakrSettings"},{"id":15,"kind":256,"name":"IObjectMakr","url":"interfaces/_iobjectmakr_.iobjectmakr.html","classes":"tsd-kind-interface tsd-parent-kind-external-module","parent":"\"IObjectMakr\""},{"id":16,"kind":1024,"name":"inheritance","url":"interfaces/_iobjectmakr_.iobjectmakr.html#inheritance","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"IObjectMakr\".IObjectMakr"},{"id":17,"kind":1024,"name":"properties","url":"interfaces/_iobjectmakr_.iobjectmakr.html#properties","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"IObjectMakr\".IObjectMakr"},{"id":18,"kind":1024,"name":"functions","url":"interfaces/_iobjectmakr_.iobjectmakr.html#functions","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"IObjectMakr\".IObjectMakr"},{"id":19,"kind":1024,"name":"doPropertiesFull","url":"interfaces/_iobjectmakr_.iobjectmakr.html#dopropertiesfull","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"IObjectMakr\".IObjectMakr"},{"id":20,"kind":1024,"name":"propertiesFull","url":"interfaces/_iobjectmakr_.iobjectmakr.html#propertiesfull","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"IObjectMakr\".IObjectMakr"},{"id":21,"kind":1024,"name":"indexMap","url":"interfaces/_iobjectmakr_.iobjectmakr.html#indexmap","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"IObjectMakr\".IObjectMakr"},{"id":22,"kind":1024,"name":"onMake","url":"interfaces/_iobjectmakr_.iobjectmakr.html#onmake","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"IObjectMakr\".IObjectMakr"},{"id":23,"kind":1024,"name":"scope","url":"interfaces/_iobjectmakr_.iobjectmakr.html#scope","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"IObjectMakr\".IObjectMakr"},{"id":24,"kind":2048,"name":"getPropertiesOf","url":"interfaces/_iobjectmakr_.iobjectmakr.html#getpropertiesof","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"\"IObjectMakr\".IObjectMakr"},{"id":25,"kind":2048,"name":"getFullPropertiesOf","url":"interfaces/_iobjectmakr_.iobjectmakr.html#getfullpropertiesof","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"\"IObjectMakr\".IObjectMakr"},{"id":26,"kind":2048,"name":"getFunction","url":"interfaces/_iobjectmakr_.iobjectmakr.html#getfunction","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"\"IObjectMakr\".IObjectMakr"},{"id":27,"kind":2048,"name":"hasFunction","url":"interfaces/_iobjectmakr_.iobjectmakr.html#hasfunction","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"\"IObjectMakr\".IObjectMakr"},{"id":28,"kind":2048,"name":"make","url":"interfaces/_iobjectmakr_.iobjectmakr.html#make","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"\"IObjectMakr\".IObjectMakr"},{"id":29,"kind":1,"name":"\"ObjectMakr\"","url":"modules/_objectmakr_.html","classes":"tsd-kind-external-module"},{"id":30,"kind":128,"name":"ObjectMakr","url":"classes/_objectmakr_.objectmakr.html","classes":"tsd-kind-class tsd-parent-kind-external-module","parent":"\"ObjectMakr\""},{"id":31,"kind":1024,"name":"inheritance","url":"classes/_objectmakr_.objectmakr.html#inheritance","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"ObjectMakr\".ObjectMakr"},{"id":32,"kind":1024,"name":"properties","url":"classes/_objectmakr_.objectmakr.html#properties","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"ObjectMakr\".ObjectMakr"},{"id":33,"kind":1024,"name":"functions","url":"classes/_objectmakr_.objectmakr.html#functions","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"ObjectMakr\".ObjectMakr"},{"id":34,"kind":1024,"name":"doPropertiesFull","url":"classes/_objectmakr_.objectmakr.html#dopropertiesfull","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"ObjectMakr\".ObjectMakr"},{"id":35,"kind":1024,"name":"propertiesFull","url":"classes/_objectmakr_.objectmakr.html#propertiesfull","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"ObjectMakr\".ObjectMakr"},{"id":36,"kind":1024,"name":"indexMap","url":"classes/_objectmakr_.objectmakr.html#indexmap","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"ObjectMakr\".ObjectMakr"},{"id":37,"kind":1024,"name":"onMake","url":"classes/_objectmakr_.objectmakr.html#onmake","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"ObjectMakr\".ObjectMakr"},{"id":38,"kind":1024,"name":"scope","url":"classes/_objectmakr_.objectmakr.html#scope","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"ObjectMakr\".ObjectMakr"},{"id":39,"kind":512,"name":"constructor","url":"classes/_objectmakr_.objectmakr.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"\"ObjectMakr\".ObjectMakr"},{"id":40,"kind":2048,"name":"getPropertiesOf","url":"classes/_objectmakr_.objectmakr.html#getpropertiesof","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"ObjectMakr\".ObjectMakr"},{"id":41,"kind":2048,"name":"getFullPropertiesOf","url":"classes/_objectmakr_.objectmakr.html#getfullpropertiesof","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"ObjectMakr\".ObjectMakr"},{"id":42,"kind":2048,"name":"getFunction","url":"classes/_objectmakr_.objectmakr.html#getfunction","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"ObjectMakr\".ObjectMakr"},{"id":43,"kind":2048,"name":"hasFunction","url":"classes/_objectmakr_.objectmakr.html#hasfunction","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"ObjectMakr\".ObjectMakr"},{"id":44,"kind":2048,"name":"make","url":"classes/_objectmakr_.objectmakr.html#make","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"ObjectMakr\".ObjectMakr"},{"id":45,"kind":2048,"name":"processProperties","url":"classes/_objectmakr_.objectmakr.html#processproperties","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-private","parent":"\"ObjectMakr\".ObjectMakr"},{"id":46,"kind":2048,"name":"processPropertyArray","url":"classes/_objectmakr_.objectmakr.html#processpropertyarray","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-private","parent":"\"ObjectMakr\".ObjectMakr"},{"id":47,"kind":2048,"name":"processFunctions","url":"classes/_objectmakr_.objectmakr.html#processfunctions","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-private","parent":"\"ObjectMakr\".ObjectMakr"},{"id":48,"kind":2048,"name":"proliferate","url":"classes/_objectmakr_.objectmakr.html#proliferate","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-private","parent":"\"ObjectMakr\".ObjectMakr"}]}; | ||
var typedoc = typedoc || {};typedoc.search = typedoc.search || {};typedoc.search.data = {"kinds":{"1":"External module","128":"Class","256":"Interface","512":"Constructor","1024":"Property","2048":"Method"},"rows":[{"id":0,"kind":1,"name":"\"IObjectMakr\"","url":"modules/_iobjectmakr_.html","classes":"tsd-kind-external-module"},{"id":1,"kind":256,"name":"IClassInheritance","url":"interfaces/_iobjectmakr_.iclassinheritance.html","classes":"tsd-kind-interface tsd-parent-kind-external-module","parent":"\"IObjectMakr\""},{"id":2,"kind":256,"name":"IClassProperties","url":"interfaces/_iobjectmakr_.iclassproperties.html","classes":"tsd-kind-interface tsd-parent-kind-external-module","parent":"\"IObjectMakr\""},{"id":3,"kind":256,"name":"IClassFunctions","url":"interfaces/_iobjectmakr_.iclassfunctions.html","classes":"tsd-kind-interface tsd-parent-kind-external-module","parent":"\"IObjectMakr\""},{"id":4,"kind":256,"name":"IClassParentNames","url":"interfaces/_iobjectmakr_.iclassparentnames.html","classes":"tsd-kind-interface tsd-parent-kind-external-module","parent":"\"IObjectMakr\""},{"id":5,"kind":256,"name":"IClass","url":"interfaces/_iobjectmakr_.iclass.html","classes":"tsd-kind-interface tsd-parent-kind-external-module","parent":"\"IObjectMakr\""},{"id":6,"kind":512,"name":"constructor","url":"interfaces/_iobjectmakr_.iclass.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-interface","parent":"\"IObjectMakr\".IClass"},{"id":7,"kind":256,"name":"IOnMakeFunction","url":"interfaces/_iobjectmakr_.ionmakefunction.html","classes":"tsd-kind-interface tsd-parent-kind-external-module tsd-has-type-parameter","parent":"\"IObjectMakr\""},{"id":8,"kind":256,"name":"IObjectMakrSettings","url":"interfaces/_iobjectmakr_.iobjectmakrsettings.html","classes":"tsd-kind-interface tsd-parent-kind-external-module","parent":"\"IObjectMakr\""},{"id":9,"kind":1024,"name":"inheritance","url":"interfaces/_iobjectmakr_.iobjectmakrsettings.html#inheritance","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"IObjectMakr\".IObjectMakrSettings"},{"id":10,"kind":1024,"name":"properties","url":"interfaces/_iobjectmakr_.iobjectmakrsettings.html#properties","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"IObjectMakr\".IObjectMakrSettings"},{"id":11,"kind":1024,"name":"doPropertiesFull","url":"interfaces/_iobjectmakr_.iobjectmakrsettings.html#dopropertiesfull","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"IObjectMakr\".IObjectMakrSettings"},{"id":12,"kind":1024,"name":"indexMap","url":"interfaces/_iobjectmakr_.iobjectmakrsettings.html#indexmap","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"IObjectMakr\".IObjectMakrSettings"},{"id":13,"kind":1024,"name":"onMake","url":"interfaces/_iobjectmakr_.iobjectmakrsettings.html#onmake","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"IObjectMakr\".IObjectMakrSettings"},{"id":14,"kind":1024,"name":"functions","url":"interfaces/_iobjectmakr_.iobjectmakrsettings.html#functions","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"IObjectMakr\".IObjectMakrSettings"},{"id":15,"kind":256,"name":"IObjectMakr","url":"interfaces/_iobjectmakr_.iobjectmakr.html","classes":"tsd-kind-interface tsd-parent-kind-external-module","parent":"\"IObjectMakr\""},{"id":16,"kind":2048,"name":"getPropertiesOf","url":"interfaces/_iobjectmakr_.iobjectmakr.html#getpropertiesof","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"\"IObjectMakr\".IObjectMakr"},{"id":17,"kind":2048,"name":"getFullPropertiesOf","url":"interfaces/_iobjectmakr_.iobjectmakr.html#getfullpropertiesof","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"\"IObjectMakr\".IObjectMakr"},{"id":18,"kind":2048,"name":"getClass","url":"interfaces/_iobjectmakr_.iobjectmakr.html#getclass","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"\"IObjectMakr\".IObjectMakr"},{"id":19,"kind":2048,"name":"hasClass","url":"interfaces/_iobjectmakr_.iobjectmakr.html#hasclass","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"\"IObjectMakr\".IObjectMakr"},{"id":20,"kind":2048,"name":"make","url":"interfaces/_iobjectmakr_.iobjectmakr.html#make","classes":"tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter","parent":"\"IObjectMakr\".IObjectMakr"},{"id":21,"kind":1,"name":"\"ObjectMakr\"","url":"modules/_objectmakr_.html","classes":"tsd-kind-external-module"},{"id":22,"kind":128,"name":"ObjectMakr","url":"classes/_objectmakr_.objectmakr.html","classes":"tsd-kind-class tsd-parent-kind-external-module","parent":"\"ObjectMakr\""},{"id":23,"kind":1024,"name":"inheritance","url":"classes/_objectmakr_.objectmakr.html#inheritance","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-private","parent":"\"ObjectMakr\".ObjectMakr"},{"id":24,"kind":1024,"name":"properties","url":"classes/_objectmakr_.objectmakr.html#properties","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-private","parent":"\"ObjectMakr\".ObjectMakr"},{"id":25,"kind":1024,"name":"propertiesFull","url":"classes/_objectmakr_.objectmakr.html#propertiesfull","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-private","parent":"\"ObjectMakr\".ObjectMakr"},{"id":26,"kind":1024,"name":"classes","url":"classes/_objectmakr_.objectmakr.html#classes","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-private","parent":"\"ObjectMakr\".ObjectMakr"},{"id":27,"kind":1024,"name":"classParentNames","url":"classes/_objectmakr_.objectmakr.html#classparentnames","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-private","parent":"\"ObjectMakr\".ObjectMakr"},{"id":28,"kind":1024,"name":"indexMap","url":"classes/_objectmakr_.objectmakr.html#indexmap","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-private","parent":"\"ObjectMakr\".ObjectMakr"},{"id":29,"kind":1024,"name":"onMake","url":"classes/_objectmakr_.objectmakr.html#onmake","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-private","parent":"\"ObjectMakr\".ObjectMakr"},{"id":30,"kind":512,"name":"constructor","url":"classes/_objectmakr_.objectmakr.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"\"ObjectMakr\".ObjectMakr"},{"id":31,"kind":2048,"name":"getPropertiesOf","url":"classes/_objectmakr_.objectmakr.html#getpropertiesof","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"ObjectMakr\".ObjectMakr"},{"id":32,"kind":2048,"name":"getFullPropertiesOf","url":"classes/_objectmakr_.objectmakr.html#getfullpropertiesof","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"ObjectMakr\".ObjectMakr"},{"id":33,"kind":2048,"name":"getClass","url":"classes/_objectmakr_.objectmakr.html#getclass","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"ObjectMakr\".ObjectMakr"},{"id":34,"kind":2048,"name":"hasClass","url":"classes/_objectmakr_.objectmakr.html#hasclass","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"ObjectMakr\".ObjectMakr"},{"id":35,"kind":2048,"name":"make","url":"classes/_objectmakr_.objectmakr.html#make","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"\"ObjectMakr\".ObjectMakr"},{"id":36,"kind":2048,"name":"createClass","url":"classes/_objectmakr_.objectmakr.html#createclass","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-private","parent":"\"ObjectMakr\".ObjectMakr"},{"id":37,"kind":2048,"name":"extendClass","url":"classes/_objectmakr_.objectmakr.html#extendclass","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-private","parent":"\"ObjectMakr\".ObjectMakr"},{"id":38,"kind":2048,"name":"processIndexMappedProperties","url":"classes/_objectmakr_.objectmakr.html#processindexmappedproperties","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-private","parent":"\"ObjectMakr\".ObjectMakr"},{"id":39,"kind":2048,"name":"generateClassParentNames","url":"classes/_objectmakr_.objectmakr.html#generateclassparentnames","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-private","parent":"\"ObjectMakr\".ObjectMakr"},{"id":40,"kind":2048,"name":"proliferate","url":"classes/_objectmakr_.objectmakr.html#proliferate","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-private","parent":"\"ObjectMakr\".ObjectMakr"}]}; |
/** | ||
* A tree representing class inheritances, where each key represents | ||
* a class, and its children inherit from that class. | ||
* A tree representing class inheritances, where keys are class names. | ||
*/ | ||
@@ -9,3 +8,3 @@ export interface IClassInheritance { | ||
/** | ||
* Properties for a class prototype, which may be of any type. | ||
* Properties for each class, keyed by class name. | ||
*/ | ||
@@ -16,11 +15,17 @@ export interface IClassProperties { | ||
/** | ||
* Listing of class Functions, keyed by name. | ||
* Generated classes, keyed by name. | ||
*/ | ||
export interface IClassFunctions { | ||
[i: string]: IClassFunction; | ||
[i: string]: IClass; | ||
} | ||
/** | ||
* Root abstract definition for class Functions. | ||
* Parent names for each class. | ||
*/ | ||
export interface IClassFunction { | ||
export interface IClassParentNames { | ||
[i: string]: string; | ||
} | ||
/** | ||
* Root abstract definition for generated classes. | ||
*/ | ||
export interface IClass { | ||
new (): any; | ||
@@ -30,5 +35,11 @@ } | ||
* Member callback for when an output onMake is a Function. | ||
* | ||
* @param output Generated class instance. | ||
* @param name Name of the class. | ||
* @param settings Settings used to instantiate this instance. | ||
* @param defaults Defaults for the class. | ||
* @type T Type of the generated class instance. | ||
*/ | ||
export interface IOnMakeFunction { | ||
(output: any, name: string, settings: any, defaults: any): any; | ||
export interface IOnMakeFunction<T> { | ||
(this: T, output: T, name: string, settings: any, defaults: any): any; | ||
} | ||
@@ -63,72 +74,36 @@ /** | ||
functions?: IClassFunctions; | ||
/** | ||
* A scope to call onMake functions in, if not this IObjectMakr. | ||
*/ | ||
scope?: any; | ||
} | ||
/** | ||
* A abstract factory for dynamic attribute-based JavaScript classes. | ||
* An abstract factory for dynamic attribute-based classes. | ||
*/ | ||
export interface IObjectMakr { | ||
/** | ||
* The sketch of class inheritance. | ||
* @param name Name of a class. | ||
* @returns The properties for a the class. | ||
*/ | ||
readonly inheritance: IClassInheritance; | ||
getPropertiesOf(name: string): any; | ||
/** | ||
* Properties for each class. | ||
* @param name Name of a class. | ||
* @returns Full properties for a the class, if doPropertiesFull is true. | ||
*/ | ||
readonly properties: IClassProperties; | ||
getFullPropertiesOf(name: string): any; | ||
/** | ||
* The actual Functions for the classes to be made. | ||
* @param name Name of a class. | ||
* @returns The class. | ||
*/ | ||
readonly functions: IClassFunctions; | ||
getClass(name: string): IClass; | ||
/** | ||
* Whether a full property mapping should be made for each type. | ||
*/ | ||
readonly doPropertiesFull: boolean; | ||
/** | ||
* If doPropertiesFull is true, a version of properties that contains the | ||
* sum properties for each type (rather than missing inherited ones). | ||
*/ | ||
readonly propertiesFull?: IClassProperties; | ||
/** | ||
* How properties can be mapped from an Array to indices. | ||
*/ | ||
readonly indexMap?: string[]; | ||
/** | ||
* An index for each generated Object's Function to be run when made. | ||
*/ | ||
readonly onMake?: string; | ||
/** | ||
* A scope to call onMake functions in, if not this. | ||
*/ | ||
readonly scope?: any; | ||
/** | ||
* @returns The properties for a particular class. | ||
*/ | ||
getPropertiesOf(title: string): any; | ||
/** | ||
* @returns Full properties for a particular class, if | ||
* doPropertiesFull is true. | ||
*/ | ||
getFullPropertiesOf(title: string): any; | ||
/** | ||
* @param name The name of a class to retrieve. | ||
* @returns The constructor for the given class. | ||
*/ | ||
getFunction(name: string): IClassFunction; | ||
/** | ||
* @param type The name of a class to check for. | ||
* @param name Name of a class. | ||
* @returns Whether that class exists. | ||
*/ | ||
hasFunction(name: string): boolean; | ||
hasClass(name: string): boolean; | ||
/** | ||
* Creates a new instance of the specified type and returns it. | ||
* If desired, any settings are applied to it (deep copy using proliferate). | ||
* Creates a new instance of the specified class. | ||
* | ||
* @param name The name of the type to initialize a new instance of. | ||
* @param [settings] Additional attributes to add to the new instance. | ||
* @returns A newly created instance of the specified type. | ||
* @param name Name of the class. | ||
* @param settings Additional attributes to deep copy onto the new instance. | ||
* @type T Type of class being created. | ||
* @returns A newly created instance of the specified class. | ||
*/ | ||
make(name: string, settings?: any): any; | ||
make<T extends any>(name: string, settings?: any): T; | ||
} |
@@ -1,40 +0,35 @@ | ||
import { IClassFunction, IClassFunctions, IClassInheritance, IClassProperties, IObjectMakr, IObjectMakrSettings } from "./IObjectMakr"; | ||
import { IClass, IObjectMakr, IObjectMakrSettings } from "./IObjectMakr"; | ||
/** | ||
* A abstract factory for dynamic attribute-based JavaScript classes. | ||
* An abstract factory for dynamic attribute-based classes. | ||
*/ | ||
export declare class ObjectMakr implements IObjectMakr { | ||
/** | ||
* The sketch of class inheritance. | ||
* Class inheritances, where keys are class names. | ||
*/ | ||
readonly inheritance: IClassInheritance; | ||
private readonly inheritance; | ||
/** | ||
* Properties for each class. | ||
* Properties for each class, keyed by class name. | ||
*/ | ||
readonly properties: IClassProperties; | ||
private readonly properties; | ||
/** | ||
* The actual Functions for the classes to be made. | ||
* If requested, each class' entire prototype chain of properties. | ||
*/ | ||
readonly functions: IClassFunctions; | ||
private readonly propertiesFull?; | ||
/** | ||
* Whether a full property mapping should be made for each type. | ||
* Generated classes, keyed by name. | ||
*/ | ||
readonly doPropertiesFull: boolean; | ||
private readonly classes; | ||
/** | ||
* If doPropertiesFull is true, a version of properties that contains the | ||
* sum properties for each type (rather than missing inherited ones). | ||
* Parent names for each class. | ||
*/ | ||
readonly propertiesFull?: IClassProperties; | ||
private readonly classParentNames; | ||
/** | ||
* How properties can be mapped from an Array to indices. | ||
*/ | ||
readonly indexMap?: string[]; | ||
private readonly indexMap?; | ||
/** | ||
* An index for each generated Object's Function to be run when made. | ||
*/ | ||
readonly onMake?: string; | ||
private readonly onMake?; | ||
/** | ||
* A scope to call onMake functions in, if not this. | ||
*/ | ||
readonly scope?: any; | ||
/** | ||
* Initializes a new instance of the ObjectMakr class. | ||
@@ -46,61 +41,65 @@ * | ||
/** | ||
* @returns The properties for a particular class. | ||
* @param name Name of a class. | ||
* @returns The properties for a the class. | ||
*/ | ||
getPropertiesOf(title: string): any; | ||
getPropertiesOf(name: string): any; | ||
/** | ||
* @returns Full properties for a particular class, if | ||
* doPropertiesFull is true. | ||
* @param name Name of a class. | ||
* @returns Full properties for a the class, if doPropertiesFull is true. | ||
*/ | ||
getFullPropertiesOf(title: string): any; | ||
getFullPropertiesOf(name: string): any; | ||
/** | ||
* @param name The name of a class to retrieve. | ||
* @returns The constructor for the given class. | ||
* @param name Name of a class. | ||
* @returns The class. | ||
*/ | ||
getFunction(name: string): IClassFunction; | ||
getClass(name: string): IClass; | ||
/** | ||
* @param type The name of a class to check for. | ||
* @param name Name of a class. | ||
* @returns Whether that class exists. | ||
*/ | ||
hasFunction(name: string): boolean; | ||
hasClass(name: string): boolean; | ||
/** | ||
* Creates a new instance of the specified type and returns it. | ||
* If desired, any settings are applied to it (deep copy using proliferate). | ||
* Creates a new instance of the specified class. | ||
* | ||
* @param name The name of the type to initialize a new instance of. | ||
* @param settings Additional attributes to add to the new instance. | ||
* @returns A newly created instance of the specified type. | ||
* @param name Name of the class. | ||
* @param settings Additional attributes to deep copy onto the new instance. | ||
* @type T Type of class being created. | ||
* @returns A newly created instance of the specified class. | ||
*/ | ||
make(name: string, settings?: any): any; | ||
make<T extends any>(name: string, settings?: any): T; | ||
/** | ||
* Parser that calls processPropertyArray on all properties given as arrays | ||
* Creates a class from the recorded properties. | ||
* | ||
* @param properties Type properties for classes to create. | ||
* @param name Name of the class. | ||
* @returns The newly created class. | ||
*/ | ||
private processProperties(properties); | ||
private createClass(name); | ||
/** | ||
* Extends a class from a parent. | ||
* | ||
* @param newClass Child class being created. | ||
* @param name Name of the child class. | ||
* @param parentName Name of the parent class. | ||
*/ | ||
private extendClass(newClass, name, parentName); | ||
/** | ||
* Creates an output properties object with the mapping shown in indexMap | ||
* | ||
* @param properties An Array with indiced versions of properties | ||
* @param properties An Array with indiced versions of properties. | ||
*/ | ||
private processPropertyArray(indexMap); | ||
private processIndexMappedProperties(indexMap); | ||
/** | ||
* Recursive parser to generate each Function, starting from the base. | ||
* Recursively records the parent names for classes in an inheritance. | ||
* | ||
* @param base An object whose keys are the names of Functions to | ||
* made, and whose values are objects whose keys are | ||
* for children that inherit from these Functions | ||
* @param parent The parent class Function of the classes about to be made. | ||
* @param parentName The name of the parent class to be inherited from, | ||
* if it is a generated one (and not Object itself). | ||
* @param inheritance A tree representing class inheritances. | ||
* @param parentClassName Parent class of the current iteration. | ||
*/ | ||
private processFunctions(base, parent, parentName?); | ||
private generateClassParentNames(inheritance, parentClassName); | ||
/** | ||
* Proliferates all members of the donor to the recipient recursively, as | ||
* a deep copy. | ||
* Deep copies all members of the donor to the recipient recursively. | ||
* | ||
* @param recipient An object receiving the donor's members. | ||
* @param donor An object whose members are copied to recipient. | ||
* @param noOverride If recipient properties may be overriden (by default, false). | ||
*/ | ||
private proliferate(recipient, donor, noOverride?); | ||
private proliferate(recipient, donor); | ||
} |
@@ -1,2 +0,2 @@ | ||
define(["require","exports"],function(t,r){"use strict";var i=function(){function t(t){void 0===t&&(t={}),this.inheritance=t.inheritance||{},this.properties=t.properties||{},this.doPropertiesFull=!!t.doPropertiesFull,this.indexMap=t.indexMap,this.onMake=t.onMake,this.functions=this.proliferate({},t.functions),this.scope=t.scope||this,this.doPropertiesFull&&(this.propertiesFull={}),this.indexMap&&this.processProperties(this.properties),this.processFunctions(this.inheritance,Object,"Object")}return t.prototype.getPropertiesOf=function(t){return this.properties[t]},t.prototype.getFullPropertiesOf=function(t){return this.doPropertiesFull?this.propertiesFull[t]:void 0},t.prototype.getFunction=function(t){return this.functions[t]},t.prototype.hasFunction=function(t){return t in this.functions},t.prototype.make=function(t,r){if(!this.functions.hasOwnProperty(t))throw new Error("Unknown type given to ObjectMakr: '"+t+"'.");var i=new this.functions[t];return r&&this.proliferate(i,r),this.onMake&&i[this.onMake]&&i[this.onMake].call(this.scope,i,t,r,(this.doPropertiesFull?this.propertiesFull:this.properties)[t]),i},t.prototype.processProperties=function(t){for(var r in t)t.hasOwnProperty(r)&&t[r]instanceof Array&&(t[r]=this.processPropertyArray(t[r]))},t.prototype.processPropertyArray=function(t){if(!this.indexMap)throw new Error("Cannot process property arrays without an indexMap.");for(var r={},i=0;i<t.length;i+=1)r[this.indexMap[i]]=t[i];return r},t.prototype.processFunctions=function(t,r,i){for(var e in t)if(t.hasOwnProperty(e)){this.functions[e]||(this.functions[e]=function(){function t(){}return t}(),this.functions[e].prototype=new r,this.functions[e].prototype.constructor=this.functions[e]);for(var o in this.properties[e])this.properties[e].hasOwnProperty(o)&&(this.functions[e].prototype[o]=this.properties[e][o]);if(this.doPropertiesFull){if(this.propertiesFull[e]={},i)for(var o in this.propertiesFull[i])this.propertiesFull[i].hasOwnProperty(o)&&(this.propertiesFull[e][o]=this.propertiesFull[i][o]);for(var o in this.properties[e])this.properties[e].hasOwnProperty(o)&&(this.propertiesFull[e][o]=this.properties[e][o])}this.processFunctions(t[e],this.functions[e],e)}},t.prototype.proliferate=function(t,r,i){for(var e in r)if(!i||!t.hasOwnProperty(e)){var o=r[e];"object"==typeof o?(t.hasOwnProperty(e)||(t[e]=new o.constructor),this.proliferate(t[e],o,i)):t[e]=o}return t},t}();r.ObjectMakr=i}); | ||
define(["require","exports"],function(t,e){"use strict";var s=function(){function t(t){void 0===t&&(t={}),this.inheritance=t.inheritance||{},this.properties=t.properties||{},this.indexMap=t.indexMap,this.onMake=t.onMake,this.classes={Object:Object},this.classParentNames={},this.generateClassParentNames(this.inheritance,"Object"),t.doPropertiesFull&&(this.propertiesFull={})}return t.prototype.getPropertiesOf=function(t){return this.properties[t]},t.prototype.getFullPropertiesOf=function(t){return this.propertiesFull?this.propertiesFull[t]:void 0},t.prototype.getClass=function(t){return this.classes[t]},t.prototype.hasClass=function(t){return t in this.classes},t.prototype.make=function(t,e){if(!(t in this.classes)){if(!(t in this.classParentNames))throw new Error("Unknown type given to ObjectMakr: '"+t+"'.");this.classes[t]=this.createClass(t)}var s=new this.classes[t];return e&&this.proliferate(s,e),this.onMake&&s[this.onMake]&&s[this.onMake].call(s,s,t,e,(this.propertiesFull?this.propertiesFull:this.properties)[t]),s},t.prototype.createClass=function(t){var e=function(){function t(){}return t}(),s=this.classParentNames[t];this.propertiesFull&&(this.propertiesFull[t]={}),s&&this.extendClass(e,t,s),this.indexMap&&this.properties[t]instanceof Array&&(this.properties[t]=this.processIndexMappedProperties(this.properties[t]));for(var r in this.properties[t])e.prototype[r]=this.properties[t][r];if(this.propertiesFull)for(var r in this.properties[t])this.propertiesFull[t][r]=this.properties[t][r];return e},t.prototype.extendClass=function(t,e,s){var r=this.classes[s]?this.classes[s]:this.createClass(s);if(t.prototype=new r,t.prototype.constructor=t,this.propertiesFull)for(var i in this.propertiesFull[s])this.propertiesFull[e][i]=this.propertiesFull[s][i]},t.prototype.processIndexMappedProperties=function(t){for(var e={},s=0;s<t.length;s+=1)e[this.indexMap[s]]=t[s];return e},t.prototype.generateClassParentNames=function(t,e){for(var s in t)this.classParentNames[s]=e,this.generateClassParentNames(t[s],s)},t.prototype.proliferate=function(t,e){for(var s in e){var r=e[s];"object"==typeof r?(this.hasOwnProperty.call(t,s)||(t[s]=new r.constructor),this.proliferate(t[s],r)):t[s]=r}},t}();e.ObjectMakr=s}); | ||
//# sourceMappingURL=ObjectMakr.js.map |
{ | ||
"name": "objectmakr", | ||
"description": "An abstract factory for dynamic attribute-based JavaScript classes.", | ||
"version": "0.6.1", | ||
"description": "An abstract factory for dynamic attribute-based classes.", | ||
"version": "0.6.3", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Josh Goldberg", |
@@ -21,2 +21,2 @@ # ObjectMakr | ||
See [Build Details](https://github.com/FullScreenShenanigans/Documentation/blob/master/Build%20Details.md) for detailed Gulp usage. | ||
See [gulp-shenanigans](https://github.com/FullScreenShenanigans/gulp-shenanigans) for detailed Gulp usage. |
{ | ||
"package": { | ||
"description": "An abstract factory for dynamic attribute-based JavaScript classes.", | ||
"description": "An abstract factory for dynamic attribute-based classes.", | ||
"name": "ObjectMakr", | ||
"version": "0.6.1" | ||
"version": "0.6.3" | ||
} | ||
} |
/** | ||
* A tree representing class inheritances, where each key represents | ||
* a class, and its children inherit from that class. | ||
* A tree representing class inheritances, where keys are class names. | ||
*/ | ||
@@ -9,3 +8,3 @@ export interface IClassInheritance { | ||
/** | ||
* Properties for a class prototype, which may be of any type. | ||
* Properties for each class, keyed by class name. | ||
*/ | ||
@@ -16,11 +15,17 @@ export interface IClassProperties { | ||
/** | ||
* Listing of class Functions, keyed by name. | ||
* Generated classes, keyed by name. | ||
*/ | ||
export interface IClassFunctions { | ||
[i: string]: IClassFunction; | ||
[i: string]: IClass; | ||
} | ||
/** | ||
* Root abstract definition for class Functions. | ||
* Parent names for each class. | ||
*/ | ||
export interface IClassFunction { | ||
export interface IClassParentNames { | ||
[i: string]: string; | ||
} | ||
/** | ||
* Root abstract definition for generated classes. | ||
*/ | ||
export interface IClass { | ||
new (): any; | ||
@@ -30,5 +35,11 @@ } | ||
* Member callback for when an output onMake is a Function. | ||
* | ||
* @param output Generated class instance. | ||
* @param name Name of the class. | ||
* @param settings Settings used to instantiate this instance. | ||
* @param defaults Defaults for the class. | ||
* @type T Type of the generated class instance. | ||
*/ | ||
export interface IOnMakeFunction { | ||
(output: any, name: string, settings: any, defaults: any): any; | ||
export interface IOnMakeFunction<T> { | ||
(this: T, output: T, name: string, settings: any, defaults: any): any; | ||
} | ||
@@ -63,72 +74,36 @@ /** | ||
functions?: IClassFunctions; | ||
/** | ||
* A scope to call onMake functions in, if not this IObjectMakr. | ||
*/ | ||
scope?: any; | ||
} | ||
/** | ||
* A abstract factory for dynamic attribute-based JavaScript classes. | ||
* An abstract factory for dynamic attribute-based classes. | ||
*/ | ||
export interface IObjectMakr { | ||
/** | ||
* The sketch of class inheritance. | ||
* @param name Name of a class. | ||
* @returns The properties for a the class. | ||
*/ | ||
readonly inheritance: IClassInheritance; | ||
getPropertiesOf(name: string): any; | ||
/** | ||
* Properties for each class. | ||
* @param name Name of a class. | ||
* @returns Full properties for a the class, if doPropertiesFull is true. | ||
*/ | ||
readonly properties: IClassProperties; | ||
getFullPropertiesOf(name: string): any; | ||
/** | ||
* The actual Functions for the classes to be made. | ||
* @param name Name of a class. | ||
* @returns The class. | ||
*/ | ||
readonly functions: IClassFunctions; | ||
getClass(name: string): IClass; | ||
/** | ||
* Whether a full property mapping should be made for each type. | ||
*/ | ||
readonly doPropertiesFull: boolean; | ||
/** | ||
* If doPropertiesFull is true, a version of properties that contains the | ||
* sum properties for each type (rather than missing inherited ones). | ||
*/ | ||
readonly propertiesFull?: IClassProperties; | ||
/** | ||
* How properties can be mapped from an Array to indices. | ||
*/ | ||
readonly indexMap?: string[]; | ||
/** | ||
* An index for each generated Object's Function to be run when made. | ||
*/ | ||
readonly onMake?: string; | ||
/** | ||
* A scope to call onMake functions in, if not this. | ||
*/ | ||
readonly scope?: any; | ||
/** | ||
* @returns The properties for a particular class. | ||
*/ | ||
getPropertiesOf(title: string): any; | ||
/** | ||
* @returns Full properties for a particular class, if | ||
* doPropertiesFull is true. | ||
*/ | ||
getFullPropertiesOf(title: string): any; | ||
/** | ||
* @param name The name of a class to retrieve. | ||
* @returns The constructor for the given class. | ||
*/ | ||
getFunction(name: string): IClassFunction; | ||
/** | ||
* @param type The name of a class to check for. | ||
* @param name Name of a class. | ||
* @returns Whether that class exists. | ||
*/ | ||
hasFunction(name: string): boolean; | ||
hasClass(name: string): boolean; | ||
/** | ||
* Creates a new instance of the specified type and returns it. | ||
* If desired, any settings are applied to it (deep copy using proliferate). | ||
* Creates a new instance of the specified class. | ||
* | ||
* @param name The name of the type to initialize a new instance of. | ||
* @param [settings] Additional attributes to add to the new instance. | ||
* @returns A newly created instance of the specified type. | ||
* @param name Name of the class. | ||
* @param settings Additional attributes to deep copy onto the new instance. | ||
* @type T Type of class being created. | ||
* @returns A newly created instance of the specified class. | ||
*/ | ||
make(name: string, settings?: any): any; | ||
make<T extends any>(name: string, settings?: any): T; | ||
} |
/** | ||
* A tree representing class inheritances, where each key represents | ||
* a class, and its children inherit from that class. | ||
* A tree representing class inheritances, where keys are class names. | ||
*/ | ||
@@ -10,3 +9,3 @@ export interface IClassInheritance { | ||
/** | ||
* Properties for a class prototype, which may be of any type. | ||
* Properties for each class, keyed by class name. | ||
*/ | ||
@@ -18,12 +17,19 @@ export interface IClassProperties { | ||
/** | ||
* Listing of class Functions, keyed by name. | ||
* Generated classes, keyed by name. | ||
*/ | ||
export interface IClassFunctions { | ||
[i: string]: IClassFunction; | ||
[i: string]: IClass; | ||
} | ||
/** | ||
* Root abstract definition for class Functions. | ||
* Parent names for each class. | ||
*/ | ||
export interface IClassFunction { | ||
export interface IClassParentNames { | ||
[i: string]: string; | ||
} | ||
/** | ||
* Root abstract definition for generated classes. | ||
*/ | ||
export interface IClass { | ||
new (): any; | ||
@@ -34,5 +40,11 @@ } | ||
* Member callback for when an output onMake is a Function. | ||
* | ||
* @param output Generated class instance. | ||
* @param name Name of the class. | ||
* @param settings Settings used to instantiate this instance. | ||
* @param defaults Defaults for the class. | ||
* @type T Type of the generated class instance. | ||
*/ | ||
export interface IOnMakeFunction { | ||
(output: any, name: string, settings: any, defaults: any): any; | ||
export interface IOnMakeFunction<T> { | ||
(this: T, output: T, name: string, settings: any, defaults: any): any; | ||
} | ||
@@ -73,86 +85,42 @@ | ||
functions?: IClassFunctions; | ||
/** | ||
* A scope to call onMake functions in, if not this IObjectMakr. | ||
*/ | ||
scope?: any; | ||
} | ||
/** | ||
* A abstract factory for dynamic attribute-based JavaScript classes. | ||
* An abstract factory for dynamic attribute-based classes. | ||
*/ | ||
export interface IObjectMakr { | ||
/** | ||
* The sketch of class inheritance. | ||
*/ | ||
readonly inheritance: IClassInheritance; | ||
/** | ||
* Properties for each class. | ||
* @param name Name of a class. | ||
* @returns The properties for a the class. | ||
*/ | ||
readonly properties: IClassProperties; | ||
getPropertiesOf(name: string): any; | ||
/** | ||
* The actual Functions for the classes to be made. | ||
* @param name Name of a class. | ||
* @returns Full properties for a the class, if doPropertiesFull is true. | ||
*/ | ||
readonly functions: IClassFunctions; | ||
getFullPropertiesOf(name: string): any; | ||
/** | ||
* Whether a full property mapping should be made for each type. | ||
* @param name Name of a class. | ||
* @returns The class. | ||
*/ | ||
readonly doPropertiesFull: boolean; | ||
getClass(name: string): IClass; | ||
/** | ||
* If doPropertiesFull is true, a version of properties that contains the | ||
* sum properties for each type (rather than missing inherited ones). | ||
*/ | ||
readonly propertiesFull?: IClassProperties; | ||
/** | ||
* How properties can be mapped from an Array to indices. | ||
*/ | ||
readonly indexMap?: string[]; | ||
/** | ||
* An index for each generated Object's Function to be run when made. | ||
*/ | ||
readonly onMake?: string; | ||
/** | ||
* A scope to call onMake functions in, if not this. | ||
*/ | ||
readonly scope?: any; | ||
/** | ||
* @returns The properties for a particular class. | ||
*/ | ||
getPropertiesOf(title: string): any; | ||
/** | ||
* @returns Full properties for a particular class, if | ||
* doPropertiesFull is true. | ||
*/ | ||
getFullPropertiesOf(title: string): any; | ||
/** | ||
* @param name The name of a class to retrieve. | ||
* @returns The constructor for the given class. | ||
*/ | ||
getFunction(name: string): IClassFunction; | ||
/** | ||
* @param type The name of a class to check for. | ||
* @param name Name of a class. | ||
* @returns Whether that class exists. | ||
*/ | ||
hasFunction(name: string): boolean; | ||
hasClass(name: string): boolean; | ||
/** | ||
* Creates a new instance of the specified type and returns it. | ||
* If desired, any settings are applied to it (deep copy using proliferate). | ||
* Creates a new instance of the specified class. | ||
* | ||
* @param name The name of the type to initialize a new instance of. | ||
* @param [settings] Additional attributes to add to the new instance. | ||
* @returns A newly created instance of the specified type. | ||
* @param name Name of the class. | ||
* @param settings Additional attributes to deep copy onto the new instance. | ||
* @type T Type of class being created. | ||
* @returns A newly created instance of the specified class. | ||
*/ | ||
make(name: string, settings?: any): any; | ||
make<T extends any>(name: string, settings?: any): T; | ||
} |
@@ -1,40 +0,35 @@ | ||
import { IClassFunction, IClassFunctions, IClassInheritance, IClassProperties, IObjectMakr, IObjectMakrSettings } from "./IObjectMakr"; | ||
import { IClass, IObjectMakr, IObjectMakrSettings } from "./IObjectMakr"; | ||
/** | ||
* A abstract factory for dynamic attribute-based JavaScript classes. | ||
* An abstract factory for dynamic attribute-based classes. | ||
*/ | ||
export declare class ObjectMakr implements IObjectMakr { | ||
/** | ||
* The sketch of class inheritance. | ||
* Class inheritances, where keys are class names. | ||
*/ | ||
readonly inheritance: IClassInheritance; | ||
private readonly inheritance; | ||
/** | ||
* Properties for each class. | ||
* Properties for each class, keyed by class name. | ||
*/ | ||
readonly properties: IClassProperties; | ||
private readonly properties; | ||
/** | ||
* The actual Functions for the classes to be made. | ||
* If requested, each class' entire prototype chain of properties. | ||
*/ | ||
readonly functions: IClassFunctions; | ||
private readonly propertiesFull?; | ||
/** | ||
* Whether a full property mapping should be made for each type. | ||
* Generated classes, keyed by name. | ||
*/ | ||
readonly doPropertiesFull: boolean; | ||
private readonly classes; | ||
/** | ||
* If doPropertiesFull is true, a version of properties that contains the | ||
* sum properties for each type (rather than missing inherited ones). | ||
* Parent names for each class. | ||
*/ | ||
readonly propertiesFull?: IClassProperties; | ||
private readonly classParentNames; | ||
/** | ||
* How properties can be mapped from an Array to indices. | ||
*/ | ||
readonly indexMap?: string[]; | ||
private readonly indexMap?; | ||
/** | ||
* An index for each generated Object's Function to be run when made. | ||
*/ | ||
readonly onMake?: string; | ||
private readonly onMake?; | ||
/** | ||
* A scope to call onMake functions in, if not this. | ||
*/ | ||
readonly scope?: any; | ||
/** | ||
* Initializes a new instance of the ObjectMakr class. | ||
@@ -46,61 +41,65 @@ * | ||
/** | ||
* @returns The properties for a particular class. | ||
* @param name Name of a class. | ||
* @returns The properties for a the class. | ||
*/ | ||
getPropertiesOf(title: string): any; | ||
getPropertiesOf(name: string): any; | ||
/** | ||
* @returns Full properties for a particular class, if | ||
* doPropertiesFull is true. | ||
* @param name Name of a class. | ||
* @returns Full properties for a the class, if doPropertiesFull is true. | ||
*/ | ||
getFullPropertiesOf(title: string): any; | ||
getFullPropertiesOf(name: string): any; | ||
/** | ||
* @param name The name of a class to retrieve. | ||
* @returns The constructor for the given class. | ||
* @param name Name of a class. | ||
* @returns The class. | ||
*/ | ||
getFunction(name: string): IClassFunction; | ||
getClass(name: string): IClass; | ||
/** | ||
* @param type The name of a class to check for. | ||
* @param name Name of a class. | ||
* @returns Whether that class exists. | ||
*/ | ||
hasFunction(name: string): boolean; | ||
hasClass(name: string): boolean; | ||
/** | ||
* Creates a new instance of the specified type and returns it. | ||
* If desired, any settings are applied to it (deep copy using proliferate). | ||
* Creates a new instance of the specified class. | ||
* | ||
* @param name The name of the type to initialize a new instance of. | ||
* @param settings Additional attributes to add to the new instance. | ||
* @returns A newly created instance of the specified type. | ||
* @param name Name of the class. | ||
* @param settings Additional attributes to deep copy onto the new instance. | ||
* @type T Type of class being created. | ||
* @returns A newly created instance of the specified class. | ||
*/ | ||
make(name: string, settings?: any): any; | ||
make<T extends any>(name: string, settings?: any): T; | ||
/** | ||
* Parser that calls processPropertyArray on all properties given as arrays | ||
* Creates a class from the recorded properties. | ||
* | ||
* @param properties Type properties for classes to create. | ||
* @param name Name of the class. | ||
* @returns The newly created class. | ||
*/ | ||
private processProperties(properties); | ||
private createClass(name); | ||
/** | ||
* Extends a class from a parent. | ||
* | ||
* @param newClass Child class being created. | ||
* @param name Name of the child class. | ||
* @param parentName Name of the parent class. | ||
*/ | ||
private extendClass(newClass, name, parentName); | ||
/** | ||
* Creates an output properties object with the mapping shown in indexMap | ||
* | ||
* @param properties An Array with indiced versions of properties | ||
* @param properties An Array with indiced versions of properties. | ||
*/ | ||
private processPropertyArray(indexMap); | ||
private processIndexMappedProperties(indexMap); | ||
/** | ||
* Recursive parser to generate each Function, starting from the base. | ||
* Recursively records the parent names for classes in an inheritance. | ||
* | ||
* @param base An object whose keys are the names of Functions to | ||
* made, and whose values are objects whose keys are | ||
* for children that inherit from these Functions | ||
* @param parent The parent class Function of the classes about to be made. | ||
* @param parentName The name of the parent class to be inherited from, | ||
* if it is a generated one (and not Object itself). | ||
* @param inheritance A tree representing class inheritances. | ||
* @param parentClassName Parent class of the current iteration. | ||
*/ | ||
private processFunctions(base, parent, parentName?); | ||
private generateClassParentNames(inheritance, parentClassName); | ||
/** | ||
* Proliferates all members of the donor to the recipient recursively, as | ||
* a deep copy. | ||
* Deep copies all members of the donor to the recipient recursively. | ||
* | ||
* @param recipient An object receiving the donor's members. | ||
* @param donor An object whose members are copied to recipient. | ||
* @param noOverride If recipient properties may be overriden (by default, false). | ||
*/ | ||
private proliferate(recipient, donor, noOverride?); | ||
private proliferate(recipient, donor); | ||
} |
define(["require", "exports"], function (require, exports) { | ||
"use strict"; | ||
/** | ||
* A abstract factory for dynamic attribute-based JavaScript classes. | ||
* An abstract factory for dynamic attribute-based classes. | ||
*/ | ||
@@ -16,63 +16,60 @@ var ObjectMakr = (function () { | ||
this.properties = settings.properties || {}; | ||
this.doPropertiesFull = !!settings.doPropertiesFull; | ||
this.indexMap = settings.indexMap; | ||
this.onMake = settings.onMake; | ||
this.functions = this.proliferate({}, settings.functions); | ||
this.scope = settings.scope || this; | ||
if (this.doPropertiesFull) { | ||
this.classes = { Object: Object }; | ||
this.classParentNames = {}; | ||
this.generateClassParentNames(this.inheritance, "Object"); | ||
if (settings.doPropertiesFull) { | ||
this.propertiesFull = {}; | ||
} | ||
if (this.indexMap) { | ||
this.processProperties(this.properties); | ||
} | ||
this.processFunctions(this.inheritance, Object, "Object"); | ||
} | ||
/** | ||
* @returns The properties for a particular class. | ||
* @param name Name of a class. | ||
* @returns The properties for a the class. | ||
*/ | ||
ObjectMakr.prototype.getPropertiesOf = function (title) { | ||
return this.properties[title]; | ||
ObjectMakr.prototype.getPropertiesOf = function (name) { | ||
return this.properties[name]; | ||
}; | ||
/** | ||
* @returns Full properties for a particular class, if | ||
* doPropertiesFull is true. | ||
* @param name Name of a class. | ||
* @returns Full properties for a the class, if doPropertiesFull is true. | ||
*/ | ||
ObjectMakr.prototype.getFullPropertiesOf = function (title) { | ||
return this.doPropertiesFull ? this.propertiesFull[title] : undefined; | ||
ObjectMakr.prototype.getFullPropertiesOf = function (name) { | ||
return this.propertiesFull ? this.propertiesFull[name] : undefined; | ||
}; | ||
/** | ||
* @param name The name of a class to retrieve. | ||
* @returns The constructor for the given class. | ||
* @param name Name of a class. | ||
* @returns The class. | ||
*/ | ||
ObjectMakr.prototype.getFunction = function (name) { | ||
return this.functions[name]; | ||
ObjectMakr.prototype.getClass = function (name) { | ||
return this.classes[name]; | ||
}; | ||
/** | ||
* @param type The name of a class to check for. | ||
* @param name Name of a class. | ||
* @returns Whether that class exists. | ||
*/ | ||
ObjectMakr.prototype.hasFunction = function (name) { | ||
return name in this.functions; | ||
ObjectMakr.prototype.hasClass = function (name) { | ||
return name in this.classes; | ||
}; | ||
/** | ||
* Creates a new instance of the specified type and returns it. | ||
* If desired, any settings are applied to it (deep copy using proliferate). | ||
* Creates a new instance of the specified class. | ||
* | ||
* @param name The name of the type to initialize a new instance of. | ||
* @param settings Additional attributes to add to the new instance. | ||
* @returns A newly created instance of the specified type. | ||
* @param name Name of the class. | ||
* @param settings Additional attributes to deep copy onto the new instance. | ||
* @type T Type of class being created. | ||
* @returns A newly created instance of the specified class. | ||
*/ | ||
ObjectMakr.prototype.make = function (name, settings) { | ||
// Make sure the type actually exists in Functions | ||
if (!this.functions.hasOwnProperty(name)) { | ||
throw new Error("Unknown type given to ObjectMakr: '" + name + "'."); | ||
if (!(name in this.classes)) { | ||
if (!(name in this.classParentNames)) { | ||
throw new Error("Unknown type given to ObjectMakr: '" + name + "'."); | ||
} | ||
this.classes[name] = this.createClass(name); | ||
} | ||
// Create the new object, copying any given settings | ||
var output = new this.functions[name](); | ||
var output = new this.classes[name](); | ||
if (settings) { | ||
this.proliferate(output, settings); | ||
} | ||
// onMake triggers are handled respecting doPropertiesFull. | ||
if (this.onMake && output[this.onMake]) { | ||
output[this.onMake].call(this.scope, output, name, settings, (this.doPropertiesFull ? this.propertiesFull : this.properties)[name]); | ||
output[this.onMake].call(output, output, name, settings, (this.propertiesFull ? this.propertiesFull : this.properties)[name]); | ||
} | ||
@@ -82,26 +79,58 @@ return output; | ||
/** | ||
* Parser that calls processPropertyArray on all properties given as arrays | ||
* Creates a class from the recorded properties. | ||
* | ||
* @param properties Type properties for classes to create. | ||
* @param name Name of the class. | ||
* @returns The newly created class. | ||
*/ | ||
ObjectMakr.prototype.processProperties = function (properties) { | ||
// For each of the given properties: | ||
for (var name_1 in properties) { | ||
if (properties.hasOwnProperty(name_1)) { | ||
// If it's an Array, replace it with a mapped version | ||
if (properties[name_1] instanceof Array) { | ||
properties[name_1] = this.processPropertyArray(properties[name_1]); | ||
} | ||
ObjectMakr.prototype.createClass = function (name) { | ||
var newClass = (function () { | ||
function class_1() { | ||
} | ||
return class_1; | ||
}()); | ||
var parentName = this.classParentNames[name]; | ||
if (this.propertiesFull) { | ||
this.propertiesFull[name] = {}; | ||
} | ||
if (parentName) { | ||
this.extendClass(newClass, name, parentName); | ||
} | ||
if (this.indexMap && this.properties[name] instanceof Array) { | ||
this.properties[name] = this.processIndexMappedProperties(this.properties[name]); | ||
} | ||
for (var i in this.properties[name]) { | ||
newClass.prototype[i] = this.properties[name][i]; | ||
} | ||
if (this.propertiesFull) { | ||
for (var i in this.properties[name]) { | ||
this.propertiesFull[name][i] = this.properties[name][i]; | ||
} | ||
} | ||
return newClass; | ||
}; | ||
/** | ||
* Extends a class from a parent. | ||
* | ||
* @param newClass Child class being created. | ||
* @param name Name of the child class. | ||
* @param parentName Name of the parent class. | ||
*/ | ||
ObjectMakr.prototype.extendClass = function (newClass, name, parentName) { | ||
var parentClass = this.classes[parentName] | ||
? this.classes[parentName] | ||
: this.createClass(parentName); | ||
newClass.prototype = new parentClass(); | ||
newClass.prototype.constructor = newClass; | ||
if (this.propertiesFull) { | ||
for (var i in this.propertiesFull[parentName]) { | ||
this.propertiesFull[name][i] = this.propertiesFull[parentName][i]; | ||
} | ||
} | ||
}; | ||
/** | ||
* Creates an output properties object with the mapping shown in indexMap | ||
* | ||
* @param properties An Array with indiced versions of properties | ||
* @param properties An Array with indiced versions of properties. | ||
*/ | ||
ObjectMakr.prototype.processPropertyArray = function (indexMap) { | ||
if (!this.indexMap) { | ||
throw new Error("Cannot process property arrays without an indexMap."); | ||
} | ||
ObjectMakr.prototype.processIndexMappedProperties = function (indexMap) { | ||
var output = {}; | ||
@@ -114,82 +143,32 @@ for (var i = 0; i < indexMap.length; i += 1) { | ||
/** | ||
* Recursive parser to generate each Function, starting from the base. | ||
* Recursively records the parent names for classes in an inheritance. | ||
* | ||
* @param base An object whose keys are the names of Functions to | ||
* made, and whose values are objects whose keys are | ||
* for children that inherit from these Functions | ||
* @param parent The parent class Function of the classes about to be made. | ||
* @param parentName The name of the parent class to be inherited from, | ||
* if it is a generated one (and not Object itself). | ||
* @param inheritance A tree representing class inheritances. | ||
* @param parentClassName Parent class of the current iteration. | ||
*/ | ||
ObjectMakr.prototype.processFunctions = function (base, parent, parentName) { | ||
// For each name in the current object: | ||
for (var name_2 in base) { | ||
if (!base.hasOwnProperty(name_2)) { | ||
continue; | ||
} | ||
if (!this.functions[name_2]) { | ||
this.functions[name_2] = (function () { | ||
function class_1() { | ||
} | ||
return class_1; | ||
}()); | ||
// This sets the Function as inheriting from the parent | ||
this.functions[name_2].prototype = new parent(); | ||
this.functions[name_2].prototype.constructor = this.functions[name_2]; | ||
} | ||
// Add each property from properties to the Function prototype | ||
for (var ref in this.properties[name_2]) { | ||
if (this.properties[name_2].hasOwnProperty(ref)) { | ||
this.functions[name_2].prototype[ref] = this.properties[name_2][ref]; | ||
} | ||
} | ||
// If the entire property tree is being mapped, copy everything | ||
// from both this and its parent to its equivalent | ||
if (this.doPropertiesFull) { | ||
this.propertiesFull[name_2] = {}; | ||
if (parentName) { | ||
for (var ref in this.propertiesFull[parentName]) { | ||
if (this.propertiesFull[parentName].hasOwnProperty(ref)) { | ||
this.propertiesFull[name_2][ref] = this.propertiesFull[parentName][ref]; | ||
} | ||
} | ||
} | ||
for (var ref in this.properties[name_2]) { | ||
if (this.properties[name_2].hasOwnProperty(ref)) { | ||
this.propertiesFull[name_2][ref] = this.properties[name_2][ref]; | ||
} | ||
} | ||
} | ||
this.processFunctions(base[name_2], this.functions[name_2], name_2); | ||
ObjectMakr.prototype.generateClassParentNames = function (inheritance, parentClassName) { | ||
for (var i in inheritance) { | ||
this.classParentNames[i] = parentClassName; | ||
this.generateClassParentNames(inheritance[i], i); | ||
} | ||
}; | ||
/** | ||
* Proliferates all members of the donor to the recipient recursively, as | ||
* a deep copy. | ||
* Deep copies all members of the donor to the recipient recursively. | ||
* | ||
* @param recipient An object receiving the donor's members. | ||
* @param donor An object whose members are copied to recipient. | ||
* @param noOverride If recipient properties may be overriden (by default, false). | ||
*/ | ||
ObjectMakr.prototype.proliferate = function (recipient, donor, noOverride) { | ||
// For each attribute of the donor: | ||
ObjectMakr.prototype.proliferate = function (recipient, donor) { | ||
for (var i in donor) { | ||
// If noOverride is specified, don't override if it already exists | ||
if (noOverride && recipient.hasOwnProperty(i)) { | ||
continue; | ||
} | ||
// If it's an object, recurse on a new version of it | ||
var setting = donor[i]; | ||
if (typeof setting === "object") { | ||
if (!recipient.hasOwnProperty(i)) { | ||
if (!this.hasOwnProperty.call(recipient, i)) { | ||
recipient[i] = new setting.constructor(); | ||
} | ||
this.proliferate(recipient[i], setting, noOverride); | ||
this.proliferate(recipient[i], setting); | ||
} | ||
else { | ||
// Regular primitives are easy to copy otherwise | ||
recipient[i] = setting; | ||
} | ||
} | ||
return recipient; | ||
}; | ||
@@ -201,2 +180,2 @@ return ObjectMakr; | ||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIk9iamVjdE1ha3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7SUFLQTs7T0FFRztJQUNIO1FBMENJOzs7O1dBSUc7UUFDSCxvQkFBbUIsUUFBa0M7WUFBbEMseUJBQUEsRUFBQSxhQUFrQztZQUNqRCxJQUFJLENBQUMsV0FBVyxHQUFHLFFBQVEsQ0FBQyxXQUFXLElBQUksRUFBRSxDQUFDO1lBQzlDLElBQUksQ0FBQyxVQUFVLEdBQUcsUUFBUS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gICAgICAgICAgICBwcm9wZXJ0aWVzW25hbWVdID0gdGhpcy5wcm9jZXNzUHJvcGVydHlBcnJheShwcm9wZXJ0aWVzW25hbWVdKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIENyZWF0ZXMgYW4gb3V0cHV0IHByb3BlcnRpZXMgb2JqZWN0IHdpdGggdGhlIG1hcHBpbmcgc2hvd24gaW4gaW5kZXhNYXBcclxuICAgICAqIFxyXG4gICAgICogQHBhcmFtIHByb3BlcnRpZXMgICBBbiBBcnJheSB3aXRoIGluZGljZWQgdmVyc2lvbnMgb2YgcHJvcGVydGllc1xyXG4gICAgICovXHJcbiAgICBwcml2YXRlIHByb2Nlc3NQcm9wZXJ0eUFycmF5KGluZGV4TWFwOiBzdHJpbmdbXSk6IGFueSB7XHJcbiAgICAgICAgaWYgKCF0aGlzLmluZGV4TWFwKSB7XHJcbiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcIkNhbm5vdCBwcm9jZXNzIHByb3BlcnR5IGFycmF5cyB3aXRob3V0IGFuIGluZGV4TWFwLlwiKTtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIGNvbnN0IG91dHB1dDogYW55ID0ge307XHJcblxyXG4gICAgICAgIGZvciAobGV0IGk6IG51bWJlciA9IDA7IGkgPCBpbmRleE1hcC5sZW5ndGg7IGkgKz0gMSkge1xyXG4gICAgICAgICAgICBvdXRwdXRbdGhpcy5pbmRleE1hcFtpXV0gPSBpbmRleE1hcFtpXTtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIHJldHVybiBvdXRwdXQ7XHJcbiAgICB9XHJcblxyXG4gICAgLyoqXHJcbiAgICAgKiBSZWN1cnNpdmUgcGFyc2VyIHRvIGdlbmVyYXRlIGVhY2ggRnVuY3Rpb24sIHN0YXJ0aW5nIGZyb20gdGhlIGJhc2UuXHJcbiAgICAgKiBc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bbmFtZV0gPSB7fTtcclxuXHJcbiAgICAgICAgICAgICAgICBpZiAocGFyZW50TmFtZSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcmVmIGluIHRoaXMucHJvcGVydGllc0Z1bGwhW3BhcmVudE5hbWVdKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnByb3BlcnRpZXNGdWxsIVtwYXJlbnROYW1lXS5oYXNPd25Qcm9wZXJ0eShyZWYpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnByb3BlcnRpZXNGdWxsIVtuYW1lXVtyZWZdID0gdGhpcy5wcm9wZXJ0aWVzRnVsbCFbcGFyZW50TmFtZV1bcmVmXTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlZiBpbiB0aGlzLnByb3BlcnRpZXNbbmFtZV0pIHtcclxuICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5wcm9wZXJ0aWVzW25hbWVdLmhhc093blByb3BlcnR5KHJlZikpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wcm9wZXJ0aWVzRnVsbCFbbmFtZV1bcmVmXSA9IHRoaXMucHJvcGVydGllc1tuYW1lXVtyZWZdO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgdGhpcy5wcm9jZXNzRnVuY3Rpb25zKGJhc2VbbmFtZV0sIHRoaXMuZnVuY3Rpb25zW25hbWVdLCBuYW1lKTtcclxuICAgICAgICB9XHJcbiAgICB9XHJcblxyXG4gICAgLyoqXHJcbiAgICAgKiBQcm9saWZlcmF0ZXMgYWxsIG1lbWJlcnMgb2YgdGhlIGRvbm9yIHRvIHRoZSByZW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gICAgICAgICAgICBpZiAoIXJlY2lwaWVudC5oYXNPd25Qcm9wZXJ0eShpKSkge1xyXG4gICAgICAgICAgICAgICAgICAgIHJlY2lwaWVudFtpXSA9IG5ldyBzZXR0aW5nLmNvbnN0cnVjdG9yKCk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB0aGlzLnByb2xpZmVyYXRlKHJlY2lwaWVudFtpXSwgc2V0dGluZywgbm9PdmVycmlkZSk7XHJcbiAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAvLyBSZWd1bGFyIHByaW1pdGl2ZXMgYXJlIGVhc3kgdG8gY29weSBvdGhlcndpc2VcclxuICAgICAgICAgICAgICAgIHJlY2lwaWVudFtpXSA9IHNldHRpbmc7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIHJldHVybiByZWNpcGllbnQ7XHJcbiAgICB9XHJcbn1cclxuIl19 | ||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIk9iamVjdE1ha3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7SUFLQTs7T0FFRztJQUNIO1FBb0NJOzs7O1dBSUc7UUFDSCxvQkFBbUIsUUFBa0M7WUFBbEMseUJBQUEsRUFBQSxhQUFrQztZQUNqRCxJQUFJLENBQUMsV0FBVyxHQUFHLFFBQVEsQ0FBQyxXQUFXLElBQUksRUFBRSxDQUFDO1lBQzlDLElBQUksQ0FBQyxVQUFVLEdBQUcsUUFBUSxDQUFDLFVBQVUsSUFBSSxFQUFFLENBQUM7WUFDNUMsSUFBSSxDQUFDLFFBQVEsR0FBRyxRQUFRLENBQUMsUUFBUSxDQUFDO1lBQ2xDLElBQUksQ0FBQyxNQUFNLEdBQUcsUUFBUSxDQUFDLE1BQU0sQ0FBQztZQUU5QixJQUFJLENBQUMsT0FBTyxHQUFHLEVBQUUsTUFBTS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F0ZShvdXRwdXQsIHNldHRpbmdzKTtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIGlmICh0aGlzLm9uTWFrZSAmJiBvdXRwdXRbdGhpcy5vbk1ha2VdKSB7XHJcbiAgICAgICAgICAgIChvdXRwdXRbdGhpcy5vbk1ha2VdIGFzIElPbk1ha2VGdW5jdGlvbjxUPikuY2FsbChcclxuICAgICAgICAgICAgICAgIG91dHB1dCxcclxuICAgICAgICAgICAgICAgIG91dHB1dCxcclxuICAgICAgICAgICAgICAgIG5hbWUsXHJcbiAgICAgICAgICAgICAgICBzZXR0aW5ncyxcclxuICAgICAgICAgICAgICAgICh0aGlzLnByb3BlcnRpZXNGdWxsID8gdGhpcy5wcm9wZXJ0aWVzRnVsbCEgOiB0aGlzLnByb3BlcnRpZXMpW25hbWVdKTtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIHJldHVybiBvdXRwdXQ7XHJcbiAgICB9XHJcblxyXG4gICAgLyoqXHJcbiAgICAgKiBDcmVhdGVzIGEgY2xhc3MgZnJvbSB0aGUgcmVjb3JkZWQgcHJvcGVydGllcy5cclxuICAgICAqIFxyXG4gICAgICogQHBhcmFtIG5hbWUgICBOYW1lIG9mIHRoZSBjbGFzcy5cclxuICAgICAqIEByZXR1cm5zIFRoZSBuZXdseSBjcmVhdGVkIGNsYXNzLlxyXG4gICAgICovXHJcbiAgICBwcml2YXRlIGNyZWF0ZUNsYXNzKG5hbWU6IHN0cmluZyk6IElDbGFzcyB7XHJcbiAgICAgICAgY29uc3QgbmV3Q2xhc3M6IElDbGFzcyA9IGNsYXNzIHsgfTtcclxuICAgICAgICBjb25zdCBwYXJlbnROYW1lOiBzdHJpbmcgfCB1bmRlZmluZWQgPSB0aGlzLmNsYXNzUGFyZW50TmFtZXNbbmFtZV07XHJcblxyXG4gICAgICAgIGlmICh0aGlzLnByb3BlcnRpZXNGdWxsKSB7XHJcbiAgICAgICAgICAgIHRoaXMucHJvcGVydGllc0Z1bGxbbmFtZV0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aW5oZXJpdGFuY2VbaV0sIGkpO1xyXG4gICAgICAgIH1cclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIERlZXAgY29waWVzIGFsbCBtZW1iZXJzIG9mIHRoZSBkb25vciB0byB0aGUgcmVjaXBpZW50IHJlY3Vyc2l2ZWx5LlxyXG4gICAgICogXHJcbiAgICAgKiBAcGFyYW0gcmVjaXBpZW50ICAgQW4gb2JqZWN0IHJlY2VpdmluZyB0aGUgZG9ub3IncyBtZW1iZXJzLlxyXG4gICAgICogQHBhcmFtIGRvbm9yICAgQW4gb2JqZWN0IHdob3NlIG1lbWJlcnMgYXJlIGNvcGllZCB0byByZWNpcGllbnQuXHJcbiAgICAgKi9cclxuICAgIHByaXZhdGUgcHJvbGlmZXJhdGUocmVjaXBpZW50OiBhbnksIGRvbm9yOiBhbnkpOiB2b2lkIHtcclxuICAgICAgICBmb3IgKGNvbnN0IGkgaW4gZG9ub3IpIHtcclxuICAgICAgICAgICAgY29uc3Qgc2V0dGluZzogYW55ID0gZG9ub3JbaV07XHJcblxyXG4gICAgICAgICAgICBpZiAodHlwZW9mIHNldHRpbmcgPT09IFwib2JqZWN0XCIpIHtcclxuICAgICAgICAgICAgICAgIGlmICghdGhpcy5oYXNPd25Qcm9wZXJ0eS5jYWxsKHJlY2lwaWVudCwgaSkpIHtcclxuICAgICAgICAgICAgICAgICAgICByZWNpcGllbnRbaV0gPSBuZXcgc2V0dGluZy5jb25zdHJ1Y3RvcigpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIHRoaXMucHJvbGlmZXJhdGUocmVjaXBpZW50W2ldLCBzZXR0aW5nKTtcclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgIHJlY2lwaWVudFtpXSA9IHNldHRpbmc7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcbiAgICB9XHJcbn1cclxuIl19 |
import { | ||
IClassFunction, IClassFunctions, IClassInheritance, IClassProperties, | ||
IClass, IClassFunctions, IClassInheritance, IClassParentNames, IClassProperties, | ||
IObjectMakr, IObjectMakrSettings, IOnMakeFunction | ||
@@ -7,30 +7,29 @@ } from "./IObjectMakr"; | ||
/** | ||
* A abstract factory for dynamic attribute-based JavaScript classes. | ||
* An abstract factory for dynamic attribute-based classes. | ||
*/ | ||
export class ObjectMakr implements IObjectMakr { | ||
/** | ||
* The sketch of class inheritance. | ||
* Class inheritances, where keys are class names. | ||
*/ | ||
public readonly inheritance: IClassInheritance; | ||
private readonly inheritance: IClassInheritance; | ||
/** | ||
* Properties for each class. | ||
* Properties for each class, keyed by class name. | ||
*/ | ||
public readonly properties: IClassProperties; | ||
private readonly properties: IClassProperties; | ||
/** | ||
* The actual Functions for the classes to be made. | ||
* If requested, each class' entire prototype chain of properties. | ||
*/ | ||
public readonly functions: IClassFunctions; | ||
private readonly propertiesFull?: IClassProperties; | ||
/** | ||
* Whether a full property mapping should be made for each type. | ||
* Generated classes, keyed by name. | ||
*/ | ||
public readonly doPropertiesFull: boolean; | ||
private readonly classes: IClassFunctions; | ||
/** | ||
* If doPropertiesFull is true, a version of properties that contains the | ||
* sum properties for each type (rather than missing inherited ones). | ||
* Parent names for each class. | ||
*/ | ||
public readonly propertiesFull?: IClassProperties; | ||
private readonly classParentNames: IClassParentNames; | ||
@@ -40,3 +39,3 @@ /** | ||
*/ | ||
public readonly indexMap?: string[]; | ||
private readonly indexMap?: string[]; | ||
@@ -46,10 +45,5 @@ /** | ||
*/ | ||
public readonly onMake?: string; | ||
private readonly onMake?: string; | ||
/** | ||
* A scope to call onMake functions in, if not this. | ||
*/ | ||
public readonly scope?: any; | ||
/** | ||
* Initializes a new instance of the ObjectMakr class. | ||
@@ -62,66 +56,64 @@ * | ||
this.properties = settings.properties || {}; | ||
this.doPropertiesFull = !!settings.doPropertiesFull; | ||
this.indexMap = settings.indexMap; | ||
this.onMake = settings.onMake; | ||
this.functions = this.proliferate({}, settings.functions); | ||
this.scope = settings.scope || this; | ||
if (this.doPropertiesFull) { | ||
this.classes = { Object }; | ||
this.classParentNames = {}; | ||
this.generateClassParentNames(this.inheritance, "Object"); | ||
if (settings.doPropertiesFull) { | ||
this.propertiesFull = {}; | ||
} | ||
if (this.indexMap) { | ||
this.processProperties(this.properties); | ||
} | ||
this.processFunctions(this.inheritance, Object, "Object"); | ||
} | ||
/** | ||
* @returns The properties for a particular class. | ||
* @param name Name of a class. | ||
* @returns The properties for a the class. | ||
*/ | ||
public getPropertiesOf(title: string): any { | ||
return this.properties[title]; | ||
public getPropertiesOf(name: string): any { | ||
return this.properties[name]; | ||
} | ||
/** | ||
* @returns Full properties for a particular class, if | ||
* doPropertiesFull is true. | ||
* @param name Name of a class. | ||
* @returns Full properties for a the class, if doPropertiesFull is true. | ||
*/ | ||
public getFullPropertiesOf(title: string): any { | ||
return this.doPropertiesFull ? this.propertiesFull![title] : undefined; | ||
public getFullPropertiesOf(name: string): any { | ||
return this.propertiesFull ? this.propertiesFull[name] : undefined; | ||
} | ||
/** | ||
* @param name The name of a class to retrieve. | ||
* @returns The constructor for the given class. | ||
* @param name Name of a class. | ||
* @returns The class. | ||
*/ | ||
public getFunction(name: string): IClassFunction { | ||
return this.functions[name]; | ||
public getClass(name: string): IClass { | ||
return this.classes[name]; | ||
} | ||
/** | ||
* @param type The name of a class to check for. | ||
* @param name Name of a class. | ||
* @returns Whether that class exists. | ||
*/ | ||
public hasFunction(name: string): boolean { | ||
return name in this.functions; | ||
public hasClass(name: string): boolean { | ||
return name in this.classes; | ||
} | ||
/** | ||
* Creates a new instance of the specified type and returns it. | ||
* If desired, any settings are applied to it (deep copy using proliferate). | ||
* Creates a new instance of the specified class. | ||
* | ||
* @param name The name of the type to initialize a new instance of. | ||
* @param settings Additional attributes to add to the new instance. | ||
* @returns A newly created instance of the specified type. | ||
* @param name Name of the class. | ||
* @param settings Additional attributes to deep copy onto the new instance. | ||
* @type T Type of class being created. | ||
* @returns A newly created instance of the specified class. | ||
*/ | ||
public make(name: string, settings?: any): any { | ||
// Make sure the type actually exists in Functions | ||
if (!this.functions.hasOwnProperty(name)) { | ||
throw new Error(`Unknown type given to ObjectMakr: '${name}'.`); | ||
public make<T extends any>(name: string, settings?: any): T { | ||
if (!(name in this.classes)) { | ||
if (!(name in this.classParentNames)) { | ||
throw new Error(`Unknown type given to ObjectMakr: '${name}'.`); | ||
} | ||
this.classes[name] = this.createClass(name); | ||
} | ||
// Create the new object, copying any given settings | ||
const output: any = new this.functions[name](); | ||
const output: T = new this.classes[name](); | ||
if (settings) { | ||
@@ -131,10 +123,9 @@ this.proliferate(output, settings); | ||
// onMake triggers are handled respecting doPropertiesFull. | ||
if (this.onMake && output[this.onMake]) { | ||
(output[this.onMake] as IOnMakeFunction).call( | ||
this.scope, | ||
(output[this.onMake] as IOnMakeFunction<T>).call( | ||
output, | ||
output, | ||
name, | ||
settings, | ||
(this.doPropertiesFull ? this.propertiesFull! : this.properties)[name]); | ||
(this.propertiesFull ? this.propertiesFull! : this.properties)[name]); | ||
} | ||
@@ -146,32 +137,68 @@ | ||
/** | ||
* Parser that calls processPropertyArray on all properties given as arrays | ||
* Creates a class from the recorded properties. | ||
* | ||
* @param properties Type properties for classes to create. | ||
* @param name Name of the class. | ||
* @returns The newly created class. | ||
*/ | ||
private processProperties(properties: any): void { | ||
// For each of the given properties: | ||
for (const name in properties) { | ||
if (properties.hasOwnProperty(name)) { | ||
// If it's an Array, replace it with a mapped version | ||
if (properties[name] instanceof Array) { | ||
properties[name] = this.processPropertyArray(properties[name]); | ||
} | ||
private createClass(name: string): IClass { | ||
const newClass: IClass = class { }; | ||
const parentName: string | undefined = this.classParentNames[name]; | ||
if (this.propertiesFull) { | ||
this.propertiesFull[name] = {}; | ||
} | ||
if (parentName) { | ||
this.extendClass(newClass, name, parentName); | ||
} | ||
if (this.indexMap && this.properties[name] instanceof Array) { | ||
this.properties[name] = this.processIndexMappedProperties(this.properties[name]); | ||
} | ||
for (const i in this.properties[name]) { | ||
newClass.prototype[i] = this.properties[name][i]; | ||
} | ||
if (this.propertiesFull) { | ||
for (const i in this.properties[name]) { | ||
this.propertiesFull[name][i] = this.properties[name][i]; | ||
} | ||
} | ||
return newClass; | ||
} | ||
/** | ||
* Creates an output properties object with the mapping shown in indexMap | ||
* Extends a class from a parent. | ||
* | ||
* @param properties An Array with indiced versions of properties | ||
* @param newClass Child class being created. | ||
* @param name Name of the child class. | ||
* @param parentName Name of the parent class. | ||
*/ | ||
private processPropertyArray(indexMap: string[]): any { | ||
if (!this.indexMap) { | ||
throw new Error("Cannot process property arrays without an indexMap."); | ||
private extendClass(newClass: IClass, name: string, parentName: string): void { | ||
const parentClass: IClass = this.classes[parentName] | ||
? this.classes[parentName] | ||
: this.createClass(parentName); | ||
newClass.prototype = new parentClass(); | ||
newClass.prototype.constructor = newClass; | ||
if (this.propertiesFull) { | ||
for (const i in this.propertiesFull[parentName]) { | ||
this.propertiesFull[name][i] = this.propertiesFull[parentName][i]; | ||
} | ||
} | ||
} | ||
/** | ||
* Creates an output properties object with the mapping shown in indexMap | ||
* | ||
* @param properties An Array with indiced versions of properties. | ||
*/ | ||
private processIndexMappedProperties(indexMap: string[]): any { | ||
const output: any = {}; | ||
for (let i: number = 0; i < indexMap.length; i += 1) { | ||
output[this.indexMap[i]] = indexMap[i]; | ||
output[this.indexMap![i]] = indexMap[i]; | ||
} | ||
@@ -183,54 +210,11 @@ | ||
/** | ||
* Recursive parser to generate each Function, starting from the base. | ||
* Recursively records the parent names for classes in an inheritance. | ||
* | ||
* @param base An object whose keys are the names of Functions to | ||
* made, and whose values are objects whose keys are | ||
* for children that inherit from these Functions | ||
* @param parent The parent class Function of the classes about to be made. | ||
* @param parentName The name of the parent class to be inherited from, | ||
* if it is a generated one (and not Object itself). | ||
* @param inheritance A tree representing class inheritances. | ||
* @param parentClassName Parent class of the current iteration. | ||
*/ | ||
private processFunctions(base: any, parent: IClassFunction, parentName?: string): void { | ||
// For each name in the current object: | ||
for (const name in base) { | ||
if (!base.hasOwnProperty(name)) { | ||
continue; | ||
} | ||
if (!this.functions[name]) { | ||
this.functions[name] = class { }; | ||
// This sets the Function as inheriting from the parent | ||
this.functions[name].prototype = new parent(); | ||
this.functions[name].prototype.constructor = this.functions[name]; | ||
} | ||
// Add each property from properties to the Function prototype | ||
for (const ref in this.properties[name]) { | ||
if (this.properties[name].hasOwnProperty(ref)) { | ||
this.functions[name].prototype[ref] = this.properties[name][ref]; | ||
} | ||
} | ||
// If the entire property tree is being mapped, copy everything | ||
// from both this and its parent to its equivalent | ||
if (this.doPropertiesFull) { | ||
this.propertiesFull![name] = {}; | ||
if (parentName) { | ||
for (const ref in this.propertiesFull![parentName]) { | ||
if (this.propertiesFull![parentName].hasOwnProperty(ref)) { | ||
this.propertiesFull![name][ref] = this.propertiesFull![parentName][ref]; | ||
} | ||
} | ||
} | ||
for (const ref in this.properties[name]) { | ||
if (this.properties[name].hasOwnProperty(ref)) { | ||
this.propertiesFull![name][ref] = this.properties[name][ref]; | ||
} | ||
} | ||
} | ||
this.processFunctions(base[name], this.functions[name], name); | ||
private generateClassParentNames(inheritance: IClassInheritance, parentClassName: string): void { | ||
for (const i in inheritance) { | ||
this.classParentNames[i] = parentClassName; | ||
this.generateClassParentNames(inheritance[i], i); | ||
} | ||
@@ -240,32 +224,22 @@ } | ||
/** | ||
* Proliferates all members of the donor to the recipient recursively, as | ||
* a deep copy. | ||
* Deep copies all members of the donor to the recipient recursively. | ||
* | ||
* @param recipient An object receiving the donor's members. | ||
* @param donor An object whose members are copied to recipient. | ||
* @param noOverride If recipient properties may be overriden (by default, false). | ||
*/ | ||
private proliferate(recipient: any, donor: any, noOverride?: boolean): any { | ||
// For each attribute of the donor: | ||
private proliferate(recipient: any, donor: any): void { | ||
for (const i in donor) { | ||
// If noOverride is specified, don't override if it already exists | ||
if (noOverride && recipient.hasOwnProperty(i)) { | ||
continue; | ||
} | ||
const setting: any = donor[i]; | ||
// If it's an object, recurse on a new version of it | ||
const setting: any = donor[i]; | ||
if (typeof setting === "object") { | ||
if (!recipient.hasOwnProperty(i)) { | ||
if (!this.hasOwnProperty.call(recipient, i)) { | ||
recipient[i] = new setting.constructor(); | ||
} | ||
this.proliferate(recipient[i], setting, noOverride); | ||
this.proliferate(recipient[i], setting); | ||
} else { | ||
// Regular primitives are easy to copy otherwise | ||
recipient[i] = setting; | ||
} | ||
} | ||
return recipient; | ||
} | ||
} |
@@ -1,6 +0,6 @@ | ||
define(["require", "exports", "../utils/fakes", "../main"], function (require, exports, fakes_1, main_1) { | ||
define(["require", "exports", "../main", "../utils/fakes"], function (require, exports, main_1, fakes_1) { | ||
"use strict"; | ||
main_1.mochaLoader.it("creates objects that respect the prototype chain", function () { | ||
// Arrange | ||
var property = function () { }; | ||
var property = new Function(); | ||
var ObjectMaker = fakes_1.fakes.stubObjectMakr({ | ||
@@ -11,5 +11,3 @@ inheritance: { | ||
properties: { | ||
sample: { | ||
property: property | ||
} | ||
sample: { property: property } | ||
} | ||
@@ -22,2 +20,26 @@ }); | ||
}); | ||
main_1.mochaLoader.it("creates objects that respect a deep prototype chain", function () { | ||
// Arrange | ||
var parentProperty = new Function(); | ||
var childProperty = new Function(); | ||
var ObjectMaker = fakes_1.fakes.stubObjectMakr({ | ||
inheritance: { | ||
parent: { | ||
child: {} | ||
} | ||
}, | ||
properties: { | ||
parent: { | ||
property: parentProperty | ||
}, | ||
child: { | ||
property: childProperty | ||
} | ||
} | ||
}); | ||
// Act | ||
var madeObject = ObjectMaker.make("child"); | ||
// Assert | ||
chai.expect(madeObject.property).to.equal(childProperty); | ||
}); | ||
main_1.mochaLoader.it("doesn't add prototype methods to created objects", function () { | ||
@@ -24,0 +46,0 @@ // Arrange |
import { IObjectMakr } from "../../src/IObjectMakr"; | ||
import { mochaLoader } from "../main"; | ||
import { fakes } from "../utils/fakes"; | ||
import { mochaLoader } from "../main"; | ||
mochaLoader.it("creates objects that respect the prototype chain", (): void => { | ||
// Arrange | ||
const property = (): void => {}; | ||
const property: Function = new Function(); | ||
const ObjectMaker: IObjectMakr = fakes.stubObjectMakr({ | ||
@@ -13,5 +13,3 @@ inheritance: { | ||
properties: { | ||
sample: { | ||
property: property | ||
} | ||
sample: { property } | ||
} | ||
@@ -21,3 +19,3 @@ }); | ||
// Act | ||
const madeObject = ObjectMaker.make("sample"); | ||
const madeObject: any = ObjectMaker.make("sample"); | ||
@@ -28,2 +26,29 @@ // Assert | ||
mochaLoader.it("creates objects that respect a deep prototype chain", (): void => { | ||
// Arrange | ||
const parentProperty: Function = new Function(); | ||
const childProperty: Function = new Function(); | ||
const ObjectMaker: IObjectMakr = fakes.stubObjectMakr({ | ||
inheritance: { | ||
parent: { | ||
child: {} | ||
} | ||
}, | ||
properties: { | ||
parent: { | ||
property: parentProperty | ||
}, | ||
child: { | ||
property: childProperty | ||
} | ||
} | ||
}); | ||
// Act | ||
const madeObject: any = ObjectMaker.make("child"); | ||
// Assert | ||
chai.expect(madeObject.property).to.equal(childProperty); | ||
}); | ||
mochaLoader.it("doesn't add prototype methods to created objects", (): void => { | ||
@@ -30,0 +55,0 @@ // Arrange |
@@ -13,3 +13,2 @@ { | ||
"eofline": true, | ||
"forin": true, | ||
"indent": [true, 4], | ||
@@ -16,0 +15,0 @@ "interface-name": [true, "always-prefix"], |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
54
2861
569906