Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

clazz-js

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clazz-js - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

src/.build

4

bower.json
{
"name": "ClazzJS",
"version": "0.1.0",
"version": "0.1.1",
"ignore": [

@@ -11,4 +11,4 @@ "node_modules",

"dependencies": {
"MetaJS": "~0.1.1"
"MetaJS": "~0.2.0"
}
}
;(function(global, Meta, undefined) {
var Clazz = function(name, parent, meta) {
var Clazz = function(name /* [dependencies] || ( [parent], [metaTypes], meta) */) {
var parent, metaTypes, meta;
// If called as constructor - creates new clazz object.
if (this instanceof Clazz) {
var clazz = Manager.get(name);
return clazz.create.apply(clazz, Array.prototype.slice.call(arguments, 1));
var last = arguments[arguments.length-1];
if (typeof last !== 'function' && Object.prototype.toString.call(last) !== '[object Object]') {
return Manager.get(name, /* actually dependencies */parent || [])
}
else {
if (arguments.length == 1) {
if (typeof name === 'object') {
meta = name;
name = null;
}
// If only name is specified - returns entity clazz.
return name ? Manager.get(name) : Factory.create(meta);
}
// If name and some meta data are specified - save meta.
// Class will be created on demand (lazy load).
else {
Manager.setMeta(name, parent, meta);
}
meta = last;
parent = arguments[1];
metaTypes = arguments[2];
if (Object.prototype.toString.call(parent) === '[objectArray]') {
metaTypes = parent;
parent = null;
}
if (metaTypes === meta) {
metaTypes = null;
}
if (parent === meta) {
parent = null;
}
Manager.setMeta(name, {
parent: parent,
metaTypes: metaTypes,
meta: meta
});
}
var NameSpace = function(namespace) {
if (NameSpace.current() === namespace) {
return;
}
NameSpace._stack.push(namespace);
}
NameSpace.GLOBAL = 'GLOBAL';
NameSpace.DELIMITERS = ['\\', '/', '_', '-', '.']
NameSpace._stack = [];
NameSpace.end = function() {
this._stack.pop();
}
NameSpace.current = function() {
return this._stack[this._stack.length - 1] || this.GLOBAL;
}
NameSpace.whereLookFor = function() {
var current = this.current(), lookfor = [current];
if (current !== this.GLOBAL) {
lookfor.push(this.GLOBAL);
}
return lookfor;
}
NameSpace.getDelimitersRegexp = function() {
return new RegExp('[\\' + this.DELIMITERS.join('\\') + ']');
}
var Base = function() {
if (typeof this.init === 'function') {
this.init.apply(this, Array.prototype.slice.call(arguments));
var response = this.init.apply(this, Array.prototype.slice.call(arguments));
if (typeof response !== 'undefined') {
return response;
}
}
}
Base.NAME = '__BASE_CLAZZ__';
Base.NAME = '__BASE_CLAZZ__';
Base.DEPENDENCIES = [];
Base.parent = null;

@@ -48,2 +94,3 @@

META_TYPE: 'ClazzJS.Clazz',
CLASS_NAME: 'Clazz{uid}',

@@ -53,16 +100,35 @@

create: function(name, parent, meta) {
if (typeof meta === 'undefined') {
meta = parent;
parent = null;
create: function(params) {
var clazz, i, ii;
var name = params.name || this.generateName();
var parent = params.parent;
var metaTypes = params.metaTypes || [this.META_TYPE];
var meta = params.meta;
var dependencies = params.dependencies || [];
if (typeof parent === 'string') {
parent = [parent];
}
if (typeof meta === 'undefined') {
meta = name;
name = null;
if (Object.prototype.toString.call(parent) === '[object Array]') {
parent = Manager.get(parent[0], parent[1] || [])
}
if (typeof parent === 'string') {
parent = Manager.get(parent);
clazz = this.createClazz(name, parent);
clazz.DEPENDENCIES = dependencies;
if (meta) {
if (typeof meta === 'function') {
meta = meta.apply(clazz, dependencies);
}
for (i = 0, ii = metaTypes.length; i < ii; ++i) {
if (typeof metaTypes[i] === 'string') {
metaTypes[i] = Meta.Manager.getType(metaTypes[i]);
}
metaTypes[i].process(clazz, meta);
}
}
return this.processMeta(this.createClazz(name, parent), meta);
return clazz;
},

@@ -76,3 +142,7 @@

var clazz = function () {
parent.apply(this, Array.prototype.slice.call(arguments));
var response = parent.apply(this, Array.prototype.slice.call(arguments));
if (typeof response !== 'undefined') {
return response;
}
}

@@ -103,14 +173,2 @@

return this.CLASS_NAME.replace('{uid}', ++this._clazzUID);
},
processMeta: function(clazz, meta) {
if (typeof meta === 'function') {
meta = meta.apply(clazz)
}
if (meta) {
Clazz.Meta.Clazz.process(clazz, meta);
Clazz.Meta.Object.process(clazz.prototype, meta);
}
return clazz;
}

@@ -123,8 +181,21 @@ }

setMeta: function(name, parent, meta) {
if (typeof meta === 'undefined') {
meta = parent;
parent = undefined;
adjustName: function(name, namespace) {
if (typeof namespace === 'undefined') {
namespace = NameSpace.current();
}
this._meta[name] = [parent, meta];
return (namespace+'.'+name).replace(NameSpace.getDelimitersRegexp(), '.');
},
setMeta: function(name, meta) {
if (meta.metaTypes) {
for (var i = 0, ii = meta.metaTypes.length; i < ii; ++i) {
if (typeof meta.metaTypes[i] === 'string') {
meta.metaTypes[i] = Meta.Manager.getType(meta.metaTypes[i]);
}
}
}
this._meta[this.adjustName(name)] = meta;
return this;

@@ -134,37 +205,117 @@ },

hasMeta: function(name) {
return name in this._meta;
var i, ii, namespaces = NameSpace.whereLookFor();
for (i = 0, ii = namespaces.length; i < ii; ++i) {
if (this.adjustName(name, namespaces[i]) in this._meta) {
return true;
}
}
return false;
},
getMeta: function(name) {
if (!(name in this._meta)) {
throw new Error('Meta does not exists for "' + name + '"!');
var i, ii, aname, namespaces = NameSpace.whereLookFor();
for (i = 0, ii = namespaces.length; i < ii; ++i) {
aname = this.adjustName(name, namespaces[i]);
if (aname in this._meta) {
return this._meta[aname];
}
}
return this._meta[name];
throw new Error('Meta does not exists for "' + name + '"!');
},
getClazz: function(name) {
if (!(name in this._clazz)) {
throw new Error('Clazz does not exists for "' + name + '"!');
getClazz: function(name, dependencies) {
var i, ii, j, jj, clazz, aname, namespaces = NameSpace.whereLookFor(), isFound;
for (i = 0, ii = namespaces.length; i < ii; ++i) {
aname = this.adjustName(name, namespaces[i]);
if (aname in this._clazz) {
clazz = this._clazz[aname];
break;
}
}
return this._clazz[name];
if (Object.prototype.toString.apply(clazz) === '[object Array]') {
if (!dependencies) {
dependencies = [];
}
for (i = 0, ii = clazz.length; i < ii; ++i) {
isFound = true;
for (j = 0, jj = clazz[i].DEPENDENCIES.length; j < jj; ++j) {
if (clazz[i].DEPENDENCIES[j] !== dependencies[j]) {
isFound = false;
break;
}
}
if (isFound) {
return clazz[i];
}
}
}
throw new Error('Clazz "' + name + '" does not exists!');
},
hasClazz: function(name) {
return name in this._clazz;
hasClazz: function(name, dependencies) {
var i, ii, j, jj, clazz, aname, namespaces = NameSpace.whereLookFor(), isFound;
for (i = 0, ii = namespaces.length; i < ii; ++i) {
aname = this.adjustName(name, namespaces[i]);
if (aname in this._clazz) {
clazz = this._clazz[aname];
break;
}
}
if (Object.prototype.toString.apply(clazz) === '[object Array]') {
if (!dependencies) {
return true;
}
for (i = 0, ii = clazz.length; i < ii; ++i) {
isFound = true;
for (j = 0, jj = clazz[i].DEPENDENCIES.length; j < jj; ++j) {
if (clazz[i].DEPENDENCIES[j] !== dependencies[j]) {
isFound = false;
break;
}
}
if (isFound) {
return true;
}
}
}
return false;
},
setClazz: function(name, clazz) {
if (typeof name === 'function') {
clazz = name;
name = clazz.NAME;
}
if (typeof clazz !== 'function') {
throw new Error('Clazz must be a function!');
}
this._clazz[name] = clazz;
var aname = this.adjustName(name);
if (!(aname in this._clazz)) {
this._clazz[aname] = [];
}
this._clazz[aname].push(clazz);
return this;
},
get: function(name) {
if (!this.hasClazz(name)) {
get: function(name , dependencies) {
if (!this.hasClazz(name, dependencies)) {
var meta = this.getMeta(name);
this.setClazz(name, Factory.create(name, meta[0], meta[1]));
meta.name = name;
meta.dependencies = dependencies;
this.setClazz(Factory.create(meta));
}
return this.getClazz(name);
return this.getClazz(name, dependencies);
},

@@ -183,3 +334,3 @@

}
var ConstantsInterfaceProcessor = new Meta.Processor.Interface({
var ConstantsInterfaceProcessor = new Meta.Processors.Interface({

@@ -230,8 +381,2 @@ const: function(name) {

});
var ConstantsProcessor = new Meta.Processor.Chain({
init: ConstantsInitProcessor,
interface: ConstantsInterfaceProcessor
})
var MethodsProcessor = function(object, methods) {

@@ -257,10 +402,53 @@

}
var PropertiesDefaultsProcessor = function(object) {
var PropertiesDefaultsProcessor = {
var property, defaults = object.getDefaults();
process: function(object) {
for (property in defaults) {
object['_' + property] = defaults[property];
var type, defaultValue, property, properties = object.__properties
for (property in properties) {
defaultValue = properties[property]['default'];
if (typeof defaultValue === 'undefined') {
type = properties[property]['type'];
if (typeof type !== 'undefined' && type in this.DEFAULT) {
defaultValue = this.DEFAULT[type];
}
}
object['_' + property] = this.copy(defaultValue);
}
},
copy: function(object) {
var copy, toString = Object.prototype.toString.apply(object);
if (typeof object !== 'object') {
copy = object;
}
else if ('[object Date]' === toString) {
copy = new Date(object.getTime())
}
else if ('[object Array]' === toString) {
copy = [];
for (var i = 0, ii = object.length; i < ii; ++i) {
copy[i] = this.copy(object[i]);
}
}
else if ('[object RegExp]' === toString) {
copy = new RegExp(object.source);
}
else {
copy = {}
for (var property in object) {
copy[property] = this.copy(object[property]);
}
}
return copy;
},
DEFAULT: {
hash: {},
array: []
}
}

@@ -274,8 +462,9 @@ var PropertiesInitProcessor = function(object, properties) {

}
var PropertiesInterfaceProcessor = new Meta.Processor.Interface({
var PropertiesInterfaceProcessor = new Meta.Processors.Interface({
__setters: {},
__getters: {},
__defaults: {},
__properties: {},
init: function(data) {

@@ -285,34 +474,45 @@ this.__setData(data);

__adjustPropertyName: function(name) {
return name.replace(/(?:_)\w/, function (match) { return match[1].toUpperCase(); });
__setProperties: function(properties) {
for (var property in properties) {
this.__setProperty(property, properties[property]);
}
return this;
},
__getDefaults: function() {
var defaults = {}, parent = this;
__getProperties: function() {
return this.__properties;
},
while (parent) {
if (parent.hasOwnProperty('__defaults')) {
for (var prop in parent.__defaults) {
if (!(prop in defaults)) {
defaults[prop] = parent.__defaults[prop];
}
}
__setProperty: function(property, key, value) {
property = this.__adjustPropertyName(property);
if (typeof this.__properties[property] === 'undefined') {
this.__properties[property] = {};
}
if ({}.constructor === key.constructor) {
for (var prop in key) {
this.__properties[property][prop] = key[prop];
}
}
else {
this.__properties[property][key] = value;
}
parent = parent.parent;
}
return defaults
return this;
},
__getDefault: function(property) {
var defaults = this.__getDefaults();
return property in defaults ? defaults[property] : undefined;
__getProperty: function(property, key) {
return typeof key === 'undefined'
? this.__properties[property]
: this.__properties[property] && this.__properties[property][key];
},
__setDefault: function(property, value) {
this.__defaults[property] = value;
__hasProperty: function(property) {
property = this.__adjustPropertyName(property);
return ('_' + property) in this && typeof this['_' + property] !== 'function';
},
__hasDefault: function(property) {
return property in this.__getDefaults();
__adjustPropertyName: function(name) {
return name.replace(/(?:_)\w/, function (match) { return match[1].toUpperCase(); });
},

@@ -325,3 +525,3 @@

}
this.__setProperty(property, data[property]);
this.__setPropertyValue(property, data[property]);
}

@@ -331,3 +531,5 @@ return this;

__getProperty: function(property) {
__getPropertyValue: function(property /*, fields... */) {
var getters, i, ii, name, value;
property = this.__adjustPropertyName(property);

@@ -339,12 +541,24 @@

var value = this['_' + property], getters = this.__getGetters(property);
value = this['_' + property];
for (var name in getters) {
getters = this.__getGetters(property);
for (name in getters) {
value = getters[name].call(this, value);
}
var fields = Object.prototype.toString.call(arguments[1]) === '[object Array]'
? arguments[1]
: Array.prototype.slice.call(arguments, 1);
for (i = 0, ii = fields.length; i < ii; ++i) {
value = value[fields[i]];
}
return value;
},
__setProperty: function(property, value) {
__setPropertyValue: function(property /* fields... , value */) {
var setters, i, ii, name, fields, value, setValue = arguments[arguments.length - 1];
property = this.__adjustPropertyName(property);

@@ -356,5 +570,23 @@

var setters = this.__getSetters(property);
fields = Object.prototype.toString.call(arguments[1]) === '[object Array]'
? arguments[1]
: Array.prototype.slice.call(arguments, 1, -1);
for (var name in setters) {
if (fields && fields.length) {
value = this['_' + property];
for (i = 0, ii = fields.length - 1; i < ii; ++i) {
if (!(fields[i] in value)) {
value[fields[i]] = {};
}
value = value[fields[i]];
}
value[fields[i]] = setValue;
}
else {
value = setValue;
}
setters = this.__getSetters(property);
for (name in setters) {
value = setters[name].call(this, value);

@@ -368,17 +600,22 @@ }

__hasProperty: function(property) {
property = this.__adjustPropertyName(property);
__isPropertyValue: function(property /* fields... , value */) {
var fields = Object.prototype.toString.apply(arguments[1]) === '[object Array]'
? arguments[1]
: Array.prototype.slice.call(arguments, 1);
return ('_' + property) in this && typeof this['_' + property] !== 'function';
},
var value = this.__getPropertyValue(property, fields);
var compare = arguments[arguments.length - 1];
__isProperty: function(property, value) {
return typeof value !== 'undefined' ? value == this.__getProperty(property) : Boolean(this.__getProperty(property));
return typeof value !== 'undefined' ? value == compare : !!value;
},
__isEmptyProperty: function(property) {
var value = this.__getProperty(property);
__hasPropertyValue: function(property /*, fields... */) {
var fields = Object.prototype.toString.apply(arguments[1]) === '[object Array]'
? arguments[1]
: Array.prototype.slice.call(arguments, 1);
var value = this.__getPropertyValue(property, fields);
if (Object.prototype.toString.apply(value) === '[object Object]') {
for (var prop in value) {
for (var p in value) {
return true;

@@ -389,6 +626,6 @@ }

return (typeof this[value] === 'undefined')
return !((typeof this[value] === 'undefined')
|| (value === null)
|| (typeof value === 'string' && value === '')
|| (Object.prototype.toString.apply(value) === '[object Array]' && value.length === 0);
|| (Object.prototype.toString.apply(value) === '[object Array]' && value.length === 0));
},

@@ -413,7 +650,7 @@

__getSetters: function(property) {
var setters, prop, allSetters = {}, parent = this.clazz.prototype;
var i, ii, setters, prop, allSetters = {}, parent = this.clazz.prototype;
while (parent) {
if (parent.hasOwnProperty('__setters')) {
for (var prop in parent.__setters) {
for (prop in parent.__setters) {
if (!(prop in allSetters)) {

@@ -424,4 +661,3 @@ allSetters[prop] = parent.__setters[prop];

}
parent = parent.parent;
parent = parent.parent;
}

@@ -437,3 +673,3 @@

for (var i = 0, ii = allSetters[property].length; i < ii; ++i) {
for (i = 0, ii = allSetters[property].length; i < ii; ++i) {
setters.push(allSetters[property][i][1]);

@@ -467,7 +703,7 @@ }

__getGetters: function(property) {
var getters, allGetters = {}, parent = this.clazz.prototype;
var i, ii, prop, getters, allGetters = {}, parent = this.clazz.prototype;
while (parent) {
if (parent.hasOwnProperty('__getters')) {
for (var prop in parent.__getters) {
for (prop in parent.__getters) {
if (!(prop in allGetters)) {

@@ -490,3 +726,3 @@ allGetters[prop] = parent.__getters[prop];

for (var i = 0, ii = allGetters[property].length; i < ii; ++i) {
for (i = 0, ii = allGetters[property].length; i < ii; ++i) {
getters.push(allGetters[property][i][1]);

@@ -506,173 +742,224 @@ }

for (var property in properties) {
this.Meta.process(object, properties[property], property)
this.MetaHandler.process(object, properties[property], property)
}
},
Meta: new Meta({
MetaHandler: new Meta.Handler({
options: {
type: {
process: function(object, type, option, property) {
var self = this, params = {};
if (Object.prototype.toString.apply(type) === '[object Array]') {
params = type[1];
type = type[0];
}
if (!(type in this.TYPES)) {
throw new Error('Unsupported property type "' + type + '"!');
}
type: {
process: function(object, type, option, property) {
if (Object.prototype.toString.apply(type) !== '[object Array]') {
type = [type, {}];
}
if (!(type[0] in this.TYPES)) {
throw new Error('Unsupported property type "' + type[0] + '"!');
}
object.__setProperty(property, 'type', type);
var typer = this.TYPES[type[0]];
object.__addSetter(property, function(value) {
return self.checkValue(value, type, params);
});
},
object.__addSetter(property, function(value) {
return typer.call(object, value, type[1]);
});
},
checkValue: function(value, type, params) {
return this.TYPES[type].call(this, value, params);
},
TYPES: {
boolean: function(value) {
return Boolean(value);
},
number: function(value, params) {
value = Number(value);
if ('min' in params && value < params['min']) {
throw new Error('Value "' + value + '" must not be less then "' + params['min'] + '"!');
TYPES: {
boolean: function(value) {
return Boolean(value);
},
number: function(value, params) {
value = Number(value);
if ('min' in params && value < params['min']) {
throw new Error('Value "' + value + '" must not be less then "' + params['min'] + '"!');
}
if ('max' in params && value > params['max']) {
throw new Error('Value "' + value + '" must not be greater then "' + params['max'] + '"!');
}
return value;
},
string: function(value, params) {
value = String(value);
if ('pattern' in params && !params['pattern'].test(value)) {
throw new Error('Value "' + value + '" does not match pattern "' + params['pattern'] + '"!');
}
return value;
},
datetime: function(value) {
if (!(value instanceof Date)) {
value = new Date(Date.parse(value));
}
return value;
},
array: function(value, params) {
return typeof value === 'string' ? value.split(params['delimiter'] || ',') : [].concat(value);
},
hash: function(value, params) {
if ({}.constructor !== value.constructor) {
throw new Error('Incorrect value: not hash type!');
}
if ('keys' in params) {
for (var prop in value) {
if (!(prop in params.keys)) {
throw new Error('Unsupported hash key "' + prop + '"!');
}
}
}
if ('element' in params) {
this.checkValue.apply(this, [].concat(params.element));
}
return value;
}
if ('max' in params && value > params['max']) {
throw new Error('Value "' + value + '" must not be greater then "' + params['max'] + '"!');
}
return value;
},
string: function(value, params) {
value = String(value);
if ('pattern' in params && !params['pattern'].test(value)) {
throw new Error('Value "' + value + '" does not match pattern "' + params['pattern'] + '"!');
}
return value;
},
datetime: function(value) {
if (!(value instanceof Date)) {
value = new Date(Date.parse(value));
}
return value;
},
array: function(value, params) {
return typeof value === 'string' ? value.split(params['delimiter'] || ',') : [].concat(value);
}
}
},
},
default: function(object, defaultValue, option, property) {
if (typeof defaultValue === 'function') {
defaultValue = defaultValue();
}
default: {
process: function(object, defaultValue, option, property) {
var type;
this.__setDefault(property, defaultValue);
},
if (typeof defaultValue === 'function') {
defaultValue = defaultValue();
}
methods: {
process: function(object, methods, option, property) {
if (Object.prototype.toString.apply(methods) !== '[object Array]') {
methods = [methods];
object.__setProperty(property, 'default', defaultValue);
}
for (var i = 0, ii = methods.length; i < ii; ++i) {
this.addMethod(methods[i], object, property);
}
},
addMethod: function(name, object, property) {
var method = this.createMethod(name, property);
object[method.name] = method.body;
},
createMethod: function(name, property) {
if (!(name in this.METHODS)) {
throw new Error('Unsupported method "' + name + '"!');
}
return this.METHODS[name](property);
},
methods: {
METHODS: {
get: function(property) {
return {
name: 'get' + property[0].toUpperCase() + property.slice(1),
body: function() {
return this.__getProperty(property);
}
process: function(object, methods, option, property) {
if (Object.prototype.toString.apply(methods) !== '[object Array]') {
methods = [methods];
}
for (var i = 0, ii = methods.length; i < ii; ++i) {
this.addMethod(methods[i], object, property);
}
},
set: function(property) {
return {
name: 'set' + property[0].toUpperCase() + property.slice(1),
body: function(value) {
return this.__setProperty(property, value);
}
addMethod: function(name, object, property) {
var method = this.createMethod(name, property);
object[method.name] = method.body;
},
createMethod: function(name, property) {
if (!(name in this.METHODS)) {
throw new Error('Unsupported method "' + name + '"!');
}
},
is: function(property) {
return {
name: (0 !== property.indexOf('is') ? 'is' : '') + property[0].toUpperCase() + property.slice(1),
body: function(value) {
return this.__isProperty(property, value);
var method = this.METHODS[name](property);
if (typeof method === 'function') {
method = {
name: name + property[0].toUpperCase() + property.slice(1),
body: method
}
}
return method;
},
isEmpty: function(property) {
return {
name: (0 !== property.indexOf('isEmpty') ? 'isEmpty' : '') + property[0].toUpperCase() + property.slice(1),
body: function() {
return this.__isEmptyProperty(property);
METHODS: {
get: function(property) {
return function() {
return this.__getPropertyValue.apply(this, [property].concat(Array.prototype.slice.call(arguments)));
}
},
set: function(property) {
return function(value) {
return this.__setPropertyValue.apply(this, [property].concat(Array.prototype.slice.call(arguments)));
}
},
is: function(property) {
return {
name: (0 !== property.indexOf('is') ? 'is' : '') + property[0].toUpperCase() + property.slice(1),
body: function() {
return this.__isPropertyValue.apply(this, [property].concat(Array.prototype.slice.call(arguments)));
}
}
},
has: function(property) {
return function() {
return this.__hasPropertyValue.apply(this, [property].concat(Array.prototype.slice.call(arguments)));
}
}
}
}
},
},
converters: function(object, converters, option, property) {
converters: function(object, converters, option, property) {
object.__addSetter(property, 1000, function(value) {
for (var name in converters) {
value = converters[name].call(this, value);
}
return value;
})
},
object.__addSetter(property, 1000, function(value) {
for (var name in converters) {
value = converters[name].call(this, value);
}
return value;
})
},
constraints: function(object, constraints, option, property) {
constraints: function(object, constraints, option, property) {
object.__addSetter(property, function(value) {
for (var name in constraints) {
if (!constraints[name].call(this, value)) {
throw new Error('Constraint "' + name + '" was failed!');
object.__addSetter(property, function(value) {
for (var name in constraints) {
if (!constraints[name].call(this, value)) {
throw new Error('Constraint "' + name + '" was failed!');
}
}
}
return value;
})
return value;
})
}
}
})
}
var PropertiesProcessor = new Meta.Processor.Chain({
Meta.Processors.sets({
init: PropertiesInitProcessor,
interface: PropertiesInterfaceProcessor,
meta: PropertiesMetaProcessor
clazz_constants_init: ConstantsInitProcessor,
clazz_constants_interface: ConstantsInterfaceProcessor,
})
clazz_constants: [
'clazz_constants_init',
'clazz_constants_interface'
],
Clazz.Base = Base;
Clazz.Factory = Factory;
Clazz.Manager = Manager;
clazz_properties_init: PropertiesInitProcessor,
clazz_properties_interface: PropertiesInterfaceProcessor,
clazz_properties_meta: PropertiesMetaProcessor,
clazz_properties_defaults: PropertiesDefaultsProcessor,
Clazz.Meta = {
Clazz: new Meta({
constants: ConstantsProcessor,
clazz_properties: PropertiesProcessor,
clazz_methods: MethodsProcessor
}),
Object: new Meta({
properties: PropertiesProcessor,
methods: MethodsProcessor
})
clazz_properties: [
'clazz_properties_init',
'clazz_properties_interface',
'clazz_properties_meta',
'clazz_properties_defaults'
],
clazz_methods: MethodsProcessor
});
Meta.Manager.setType(Factory.META_TYPE, {
clazz: {
options: {
constants: 'clazz_constants',
clazz_properties: 'clazz_properties',
clazz_methods: 'clazz_methods'
}
},
object: {
objectHandler: function(object) {
return object.prototype;
},
options: {
properties: 'clazz_properties',
methods: 'clazz_methods'
}
}
});
global.Clazz = Clazz;
Clazz.Base = Base;
Clazz.Factory = Factory;
Clazz.Manager = Manager;
global.NameSpace = NameSpace;
global.Clazz = Clazz;
})(this, Meta);

@@ -1,2 +0,2 @@

!function(a,b,c){var d=function(a,b,c){if(this instanceof d){var e=g.get(a);return e.create.apply(e,Array.prototype.slice.call(arguments,1))}return 1==arguments.length?("object"==typeof a&&(c=a,a=null),a?g.get(a):f.create(c)):(g.setMeta(a,b,c),void 0)},e=function(){"function"==typeof this.init&&this.init.apply(this,Array.prototype.slice.call(arguments))};e.NAME="__BASE_CLAZZ__",e.parent=null,e.create=function(){var a=arguments;return new this(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10])},e.prototype={parent:null,clazz:e};var f={CLASS_NAME:"Clazz{uid}",_clazzUID:0,create:function(a,b,c){return"undefined"==typeof c&&(c=b,b=null),"undefined"==typeof c&&(c=a,a=null),"string"==typeof b&&(b=g.get(b)),this.processMeta(this.createClazz(a,b),c)},createClazz:function(a,b){b||(b=e);var d=function(){b.apply(this,Array.prototype.slice.call(arguments))};for(var f in b)"function"==typeof b[f]?d[f]=b[f]:"_"===f[0]&&(d[f]=c);return d.NAME=a||this.generateName(),d.parent=b,d.prototype=Object.create(b.prototype),d.prototype.clazz=d,d.prototype.parent=b.prototype,d},generateName:function(){return this.CLASS_NAME.replace("{uid}",++this._clazzUID)},processMeta:function(a,b){return"function"==typeof b&&(b=b.apply(a)),b&&(d.Meta.Clazz.process(a,b),d.Meta.Object.process(a.prototype,b)),a}},g={_clazz:{},_meta:{},setMeta:function(a,b,d){return"undefined"==typeof d&&(d=b,b=c),this._meta[a]=[b,d],this},hasMeta:function(a){return a in this._meta},getMeta:function(a){if(!(a in this._meta))throw new Error('Meta does not exists for "'+a+'"!');return this._meta[a]},getClazz:function(a){if(!(a in this._clazz))throw new Error('Clazz does not exists for "'+a+'"!');return this._clazz[a]},hasClazz:function(a){return a in this._clazz},setClazz:function(a,b){if("function"!=typeof b)throw new Error("Clazz must be a function!");return this._clazz[a]=b,this},get:function(a){if(!this.hasClazz(a)){var b=this.getMeta(a);this.setClazz(a,f.create(a,b[0],b[1]))}return this.getClazz(a)},has:function(a){return this.hasClazz(a)||this.hasMeta(a)}},h=function(a,b){a.__constants={};for(var c in b)a.__constants[c]=b[c]},i=new b.Processor.Interface({"const":function(a){return this.__getConstant(a)},__getConstant:function(a,b){var c=this;if("undefined"==typeof b&&(b=c.__getConstants()),"undefined"!=typeof a){if(!(a in b))throw new Error('Constant "'+a+'" does not defined!');if(b=b[a],"[object Object]"===Object.prototype.toString.apply(b))return function(a){return c.__getConstant(a,b)}}return b},__getConstants:function(){for(var a={},b=this;b;){if(b.hasOwnProperty("__constants"))for(var c in b.__constants)c in a||(a[c]=b.__constants[c]);b=b.parent}return a}}),j=new b.Processor.Chain({init:h,"interface":i}),k=function(a,b){if("function"==typeof a&&a.parent)for(var c in a.parent)"function"==typeof a.parent[c]&&(a[c]=a.parent[c]);for(var c in b){if("function"!=typeof b[c])throw new Error('Method "'+c+'" must be a function!');a[c]=b[c]}},l=function(a){var b,c=a.getDefaults();for(b in c)a["_"+b]=c[b]},m=function(a,b){for(var d in b)a["_"+d]=c},n=new b.Processor.Interface({__setters:{},__getters:{},__defaults:{},init:function(a){this.__setData(a)},__adjustPropertyName:function(a){return a.replace(/(?:_)\w/,function(a){return a[1].toUpperCase()})},__getDefaults:function(){for(var a={},b=this;b;){if(b.hasOwnProperty("__defaults"))for(var c in b.__defaults)c in a||(a[c]=b.__defaults[c]);b=b.parent}return a},__getDefault:function(a){var b=this.__getDefaults();return a in b?b[a]:c},__setDefault:function(a,b){this.__defaults[a]=b},__hasDefault:function(a){return a in this.__getDefaults()},__setData:function(a){for(var b in a)this.__hasProperty(b)&&this.__setProperty(b,a[b]);return this},__getProperty:function(a){if(a=this.__adjustPropertyName(a),!this.__hasProperty(a))throw new Error("Can't get! Property \""+a+'" does not exists!');var b=this["_"+a],c=this.__getGetters(a);for(var d in c)b=c[d].call(this,b);return b},__setProperty:function(a,b){if(a=this.__adjustPropertyName(a),!this.__hasProperty(a))throw new Error("Can't set! Property \""+a+'" does not exists!');var c=this.__getSetters(a);for(var d in c)b=c[d].call(this,b);return this["_"+a]=b,this},__hasProperty:function(a){return a=this.__adjustPropertyName(a),"_"+a in this&&"function"!=typeof this["_"+a]},__isProperty:function(a,b){return"undefined"!=typeof b?b==this.__getProperty(a):Boolean(this.__getProperty(a))},__isEmptyProperty:function(a){var b=this.__getProperty(a);if("[object Object]"===Object.prototype.toString.apply(b)){for(var c in b)return!0;return!1}return"undefined"==typeof this[b]||null===b||"string"==typeof b&&""===b||"[object Array]"===Object.prototype.toString.apply(b)&&0===b.length},__addSetter:function(a,b,c){if("undefined"==typeof c&&(c=b,b=0),"function"!=typeof c)throw new Error("Set callback must be a function!");return a in this.__setters||(this.__setters[a]=[]),this.__setters[a].push([b,c]),this},__getSetters:function(a){for(var b,c,d={},e=this.clazz.prototype;e;){if(e.hasOwnProperty("__setters"))for(var c in e.__setters)c in d||(d[c]=e.__setters[c]);e=e.parent}if("undefined"!=typeof a){if(b=[],a in d&&d[a].length){d[a].sort(function(a,b){return b[0]-a[0]});for(var f=0,g=d[a].length;g>f;++f)b.push(d[a][f][1])}}else b=d;return b},__addGetter:function(a,b,c){if("undefined"==typeof c&&(c=b,b=0),"function"!=typeof c)throw new Error("Get callback must be a function!");return a in this.__getters||(this.__getters[a]=[]),this.__getters[a].push([b,c]),this},__getGetters:function(a){for(var b,c={},d=this.clazz.prototype;d;){if(d.hasOwnProperty("__getters"))for(var e in d.__getters)e in c||(c[e]=d.__getters[e]);d=d.parent}if("undefined"!=typeof a){if(b=[],a in c&&c[a].length){c[a].sort(function(a,b){return b[0]-a[0]});for(var f=0,g=c[a].length;g>f;++f)b.push(c[a][f][1])}}else b=c;return b}}),o={process:function(a,b){for(var c in b)this.Meta.process(a,b[c],c)},Meta:new b({type:{process:function(a,b,c,d){if("[object Array]"!==Object.prototype.toString.apply(b)&&(b=[b,{}]),!(b[0]in this.TYPES))throw new Error('Unsupported property type "'+b[0]+'"!');var e=this.TYPES[b[0]];a.__addSetter(d,function(c){return e.call(a,c,b[1])})},TYPES:{"boolean":function(a){return Boolean(a)},number:function(a,b){if(a=Number(a),"min"in b&&a<b.min)throw new Error('Value "'+a+'" must not be less then "'+b.min+'"!');if("max"in b&&a>b.max)throw new Error('Value "'+a+'" must not be greater then "'+b.max+'"!');return a},string:function(a,b){if(a=String(a),"pattern"in b&&!b.pattern.test(a))throw new Error('Value "'+a+'" does not match pattern "'+b.pattern+'"!');return a},datetime:function(a){return a instanceof Date||(a=new Date(Date.parse(a))),a},array:function(a,b){return"string"==typeof a?a.split(b.delimiter||","):[].concat(a)}}},"default":function(a,b,c,d){"function"==typeof b&&(b=b()),this.__setDefault(d,b)},methods:{process:function(a,b,c,d){"[object Array]"!==Object.prototype.toString.apply(b)&&(b=[b]);for(var e=0,f=b.length;f>e;++e)this.addMethod(b[e],a,d)},addMethod:function(a,b,c){var d=this.createMethod(a,c);b[d.name]=d.body},createMethod:function(a,b){if(!(a in this.METHODS))throw new Error('Unsupported method "'+a+'"!');return this.METHODS[a](b)},METHODS:{get:function(a){return{name:"get"+a[0].toUpperCase()+a.slice(1),body:function(){return this.__getProperty(a)}}},set:function(a){return{name:"set"+a[0].toUpperCase()+a.slice(1),body:function(b){return this.__setProperty(a,b)}}},is:function(a){return{name:(0!==a.indexOf("is")?"is":"")+a[0].toUpperCase()+a.slice(1),body:function(b){return this.__isProperty(a,b)}}},isEmpty:function(a){return{name:(0!==a.indexOf("isEmpty")?"isEmpty":"")+a[0].toUpperCase()+a.slice(1),body:function(){return this.__isEmptyProperty(a)}}}}},converters:function(a,b,c,d){a.__addSetter(d,1e3,function(a){for(var c in b)a=b[c].call(this,a);return a})},constraints:function(a,b,c,d){a.__addSetter(d,function(a){for(var c in b)if(!b[c].call(this,a))throw new Error('Constraint "'+c+'" was failed!');return a})}})},p=new b.Processor.Chain({init:m,"interface":n,meta:o});d.Base=e,d.Factory=f,d.Manager=g,d.Meta={Clazz:new b({constants:j,clazz_properties:p,clazz_methods:k}),Object:new b({properties:p,methods:k})},a.Clazz=d}(this,Meta);
!function(a,b,c){var d=function(a){var b,c,d,e=arguments[arguments.length-1];return"function"!=typeof e&&"[object Object]"!==Object.prototype.toString.call(e)?h.get(a,b||[]):(d=e,b=arguments[1],c=arguments[2],"[objectArray]"===Object.prototype.toString.call(b)&&(c=b,b=null),c===d&&(c=null),b===d&&(b=null),h.setMeta(a,{parent:b,metaTypes:c,meta:d}),void 0)},e=function(a){e.current()!==a&&e._stack.push(a)};e.GLOBAL="GLOBAL",e.DELIMITERS=["\\","/","_","-","."],e._stack=[],e.end=function(){this._stack.pop()},e.current=function(){return this._stack[this._stack.length-1]||this.GLOBAL},e.whereLookFor=function(){var a=this.current(),b=[a];return a!==this.GLOBAL&&b.push(this.GLOBAL),b},e.getDelimitersRegexp=function(){return new RegExp("[\\"+this.DELIMITERS.join("\\")+"]")};var f=function(){if("function"==typeof this.init){var a=this.init.apply(this,Array.prototype.slice.call(arguments));if("undefined"!=typeof a)return a}};f.NAME="__BASE_CLAZZ__",f.DEPENDENCIES=[],f.parent=null,f.create=function(){var a=arguments;return new this(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10])},f.prototype={parent:null,clazz:f};var g={META_TYPE:"ClazzJS.Clazz",CLASS_NAME:"Clazz{uid}",_clazzUID:0,create:function(a){var c,d,e,f=a.name||this.generateName(),g=a.parent,i=a.metaTypes||[this.META_TYPE],j=a.meta,k=a.dependencies||[];if("string"==typeof g&&(g=[g]),"[object Array]"===Object.prototype.toString.call(g)&&(g=h.get(g[0],g[1]||[])),c=this.createClazz(f,g),c.DEPENDENCIES=k,j)for("function"==typeof j&&(j=j.apply(c,k)),d=0,e=i.length;e>d;++d)"string"==typeof i[d]&&(i[d]=b.Manager.getType(i[d])),i[d].process(c,j);return c},createClazz:function(a,b){b||(b=f);var d=function(){var a=b.apply(this,Array.prototype.slice.call(arguments));return"undefined"!=typeof a?a:void 0};for(var e in b)"function"==typeof b[e]?d[e]=b[e]:"_"===e[0]&&(d[e]=c);return d.NAME=a||this.generateName(),d.parent=b,d.prototype=Object.create(b.prototype),d.prototype.clazz=d,d.prototype.parent=b.prototype,d},generateName:function(){return this.CLASS_NAME.replace("{uid}",++this._clazzUID)}},h={_clazz:{},_meta:{},adjustName:function(a,b){return"undefined"==typeof b&&(b=e.current()),(b+"."+a).replace(e.getDelimitersRegexp(),".")},setMeta:function(a,c){if(c.metaTypes)for(var d=0,e=c.metaTypes.length;e>d;++d)"string"==typeof c.metaTypes[d]&&(c.metaTypes[d]=b.Manager.getType(c.metaTypes[d]));return this._meta[this.adjustName(a)]=c,this},hasMeta:function(a){var b,c,d=e.whereLookFor();for(b=0,c=d.length;c>b;++b)if(this.adjustName(a,d[b])in this._meta)return!0;return!1},getMeta:function(a){var b,c,d,f=e.whereLookFor();for(b=0,c=f.length;c>b;++b)if(d=this.adjustName(a,f[b]),d in this._meta)return this._meta[d];throw new Error('Meta does not exists for "'+a+'"!')},getClazz:function(a,b){var c,d,f,g,h,i,j=e.whereLookFor(),k;for(c=0,d=j.length;d>c;++c)if(i=this.adjustName(a,j[c]),i in this._clazz){h=this._clazz[i];break}if("[object Array]"===Object.prototype.toString.apply(h))for(b||(b=[]),c=0,d=h.length;d>c;++c){for(k=!0,f=0,g=h[c].DEPENDENCIES.length;g>f;++f)if(h[c].DEPENDENCIES[f]!==b[f]){k=!1;break}if(k)return h[c]}throw new Error('Clazz "'+a+'" does not exists!')},hasClazz:function(a,b){var c,d,f,g,h,i,j=e.whereLookFor(),k;for(c=0,d=j.length;d>c;++c)if(i=this.adjustName(a,j[c]),i in this._clazz){h=this._clazz[i];break}if("[object Array]"===Object.prototype.toString.apply(h)){if(!b)return!0;for(c=0,d=h.length;d>c;++c){for(k=!0,f=0,g=h[c].DEPENDENCIES.length;g>f;++f)if(h[c].DEPENDENCIES[f]!==b[f]){k=!1;break}if(k)return!0}}return!1},setClazz:function(a,b){if("function"==typeof a&&(b=a,a=b.NAME),"function"!=typeof b)throw new Error("Clazz must be a function!");var c=this.adjustName(a);return c in this._clazz||(this._clazz[c]=[]),this._clazz[c].push(b),this},get:function(a,b){if(!this.hasClazz(a,b)){var c=this.getMeta(a);c.name=a,c.dependencies=b,this.setClazz(g.create(c))}return this.getClazz(a,b)},has:function(a){return this.hasClazz(a)||this.hasMeta(a)}},i=function(a,b){a.__constants={};for(var c in b)a.__constants[c]=b[c]},j=new b.Processors.Interface({"const":function(a){return this.__getConstant(a)},__getConstant:function(a,b){var c=this;if("undefined"==typeof b&&(b=c.__getConstants()),"undefined"!=typeof a){if(!(a in b))throw new Error('Constant "'+a+'" does not defined!');if(b=b[a],"[object Object]"===Object.prototype.toString.apply(b))return function(a){return c.__getConstant(a,b)}}return b},__getConstants:function(){for(var a={},b=this;b;){if(b.hasOwnProperty("__constants"))for(var c in b.__constants)c in a||(a[c]=b.__constants[c]);b=b.parent}return a}}),k=function(a,b){if("function"==typeof a&&a.parent)for(var c in a.parent)"function"==typeof a.parent[c]&&(a[c]=a.parent[c]);for(var c in b){if("function"!=typeof b[c])throw new Error('Method "'+c+'" must be a function!');a[c]=b[c]}},l={process:function(a){var b,c,d,e=a.__properties;for(d in e)c=e[d]["default"],"undefined"==typeof c&&(b=e[d].type,"undefined"!=typeof b&&b in this.DEFAULT&&(c=this.DEFAULT[b])),a["_"+d]=this.copy(c)},copy:function(a){var b,c=Object.prototype.toString.apply(a);if("object"!=typeof a)b=a;else if("[object Date]"===c)b=new Date(a.getTime());else if("[object Array]"===c){b=[];for(var d=0,e=a.length;e>d;++d)b[d]=this.copy(a[d])}else if("[object RegExp]"===c)b=new RegExp(a.source);else{b={};for(var f in a)b[f]=this.copy(a[f])}return b},DEFAULT:{hash:{},array:[]}},m=function(a,b){for(var d in b)a["_"+d]=c},n=new b.Processors.Interface({__setters:{},__getters:{},__properties:{},init:function(a){this.__setData(a)},__setProperties:function(a){for(var b in a)this.__setProperty(b,a[b]);return this},__getProperties:function(){return this.__properties},__setProperty:function(a,b,c){if(a=this.__adjustPropertyName(a),"undefined"==typeof this.__properties[a]&&(this.__properties[a]={}),{}.constructor===b.constructor)for(var d in b)this.__properties[a][d]=b[d];else this.__properties[a][b]=c;return this},__getProperty:function(a,b){return"undefined"==typeof b?this.__properties[a]:this.__properties[a]&&this.__properties[a][b]},__hasProperty:function(a){return a=this.__adjustPropertyName(a),"_"+a in this&&"function"!=typeof this["_"+a]},__adjustPropertyName:function(a){return a.replace(/(?:_)\w/,function(a){return a[1].toUpperCase()})},__setData:function(a){for(var b in a)this.__hasProperty(b)&&this.__setPropertyValue(b,a[b]);return this},__getPropertyValue:function(a){var b,c,d,e,f;if(a=this.__adjustPropertyName(a),!this.__hasProperty(a))throw new Error("Can't get! Property \""+a+'" does not exists!');f=this["_"+a],b=this.__getGetters(a);for(e in b)f=b[e].call(this,f);var g="[object Array]"===Object.prototype.toString.call(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);for(c=0,d=g.length;d>c;++c)f=f[g[c]];return f},__setPropertyValue:function(a){var b,c,d,e,f,g,h=arguments[arguments.length-1];if(a=this.__adjustPropertyName(a),!this.__hasProperty(a))throw new Error("Can't set! Property \""+a+'" does not exists!');if(f="[object Array]"===Object.prototype.toString.call(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1,-1),f&&f.length){for(g=this["_"+a],c=0,d=f.length-1;d>c;++c)f[c]in g||(g[f[c]]={}),g=g[f[c]];g[f[c]]=h}else g=h;b=this.__getSetters(a);for(e in b)g=b[e].call(this,g);return this["_"+a]=g,this},__isPropertyValue:function(a){var b="[object Array]"===Object.prototype.toString.apply(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1),c=this.__getPropertyValue(a,b),d=arguments[arguments.length-1];return"undefined"!=typeof c?c==d:!!c},__hasPropertyValue:function(a){var b="[object Array]"===Object.prototype.toString.apply(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1),c=this.__getPropertyValue(a,b);if("[object Object]"===Object.prototype.toString.apply(c)){for(var d in c)return!0;return!1}return!("undefined"==typeof this[c]||null===c||"string"==typeof c&&""===c||"[object Array]"===Object.prototype.toString.apply(c)&&0===c.length)},__addSetter:function(a,b,c){if("undefined"==typeof c&&(c=b,b=0),"function"!=typeof c)throw new Error("Set callback must be a function!");return a in this.__setters||(this.__setters[a]=[]),this.__setters[a].push([b,c]),this},__getSetters:function(a){for(var b,c,d,e,f={},g=this.clazz.prototype;g;){if(g.hasOwnProperty("__setters"))for(e in g.__setters)e in f||(f[e]=g.__setters[e]);g=g.parent}if("undefined"!=typeof a){if(d=[],a in f&&f[a].length)for(f[a].sort(function(a,b){return b[0]-a[0]}),b=0,c=f[a].length;c>b;++b)d.push(f[a][b][1])}else d=f;return d},__addGetter:function(a,b,c){if("undefined"==typeof c&&(c=b,b=0),"function"!=typeof c)throw new Error("Get callback must be a function!");return a in this.__getters||(this.__getters[a]=[]),this.__getters[a].push([b,c]),this},__getGetters:function(a){for(var b,c,d,e,f={},g=this.clazz.prototype;g;){if(g.hasOwnProperty("__getters"))for(d in g.__getters)d in f||(f[d]=g.__getters[d]);g=g.parent}if("undefined"!=typeof a){if(e=[],a in f&&f[a].length)for(f[a].sort(function(a,b){return b[0]-a[0]}),b=0,c=f[a].length;c>b;++b)e.push(f[a][b][1])}else e=f;return e}}),o={process:function(a,b){for(var c in b)this.MetaHandler.process(a,b[c],c)},MetaHandler:new b.Handler({options:{type:{process:function(a,b,c,d){var e=this,f={};if("[object Array]"===Object.prototype.toString.apply(b)&&(f=b[1],b=b[0]),!(b in this.TYPES))throw new Error('Unsupported property type "'+b+'"!');a.__setProperty(d,"type",b),a.__addSetter(d,function(a){return e.checkValue(a,b,f)})},checkValue:function(a,b,c){return this.TYPES[b].call(this,a,c)},TYPES:{"boolean":function(a){return Boolean(a)},number:function(a,b){if(a=Number(a),"min"in b&&a<b.min)throw new Error('Value "'+a+'" must not be less then "'+b.min+'"!');if("max"in b&&a>b.max)throw new Error('Value "'+a+'" must not be greater then "'+b.max+'"!');return a},string:function(a,b){if(a=String(a),"pattern"in b&&!b.pattern.test(a))throw new Error('Value "'+a+'" does not match pattern "'+b.pattern+'"!');return a},datetime:function(a){return a instanceof Date||(a=new Date(Date.parse(a))),a},array:function(a,b){return"string"==typeof a?a.split(b.delimiter||","):[].concat(a)},hash:function(a,b){if({}.constructor!==a.constructor)throw new Error("Incorrect value: not hash type!");if("keys"in b)for(var c in a)if(!(c in b.keys))throw new Error('Unsupported hash key "'+c+'"!');return"element"in b&&this.checkValue.apply(this,[].concat(b.element)),a}}},"default":{process:function(a,b,c,d){var e;"function"==typeof b&&(b=b()),a.__setProperty(d,"default",b)}},methods:{process:function(a,b,c,d){"[object Array]"!==Object.prototype.toString.apply(b)&&(b=[b]);for(var e=0,f=b.length;f>e;++e)this.addMethod(b[e],a,d)},addMethod:function(a,b,c){var d=this.createMethod(a,c);b[d.name]=d.body},createMethod:function(a,b){if(!(a in this.METHODS))throw new Error('Unsupported method "'+a+'"!');var c=this.METHODS[a](b);return"function"==typeof c&&(c={name:a+b[0].toUpperCase()+b.slice(1),body:c}),c},METHODS:{get:function(a){return function(){return this.__getPropertyValue.apply(this,[a].concat(Array.prototype.slice.call(arguments)))}},set:function(a){return function(b){return this.__setPropertyValue.apply(this,[a].concat(Array.prototype.slice.call(arguments)))}},is:function(a){return{name:(0!==a.indexOf("is")?"is":"")+a[0].toUpperCase()+a.slice(1),body:function(){return this.__isPropertyValue.apply(this,[a].concat(Array.prototype.slice.call(arguments)))}}},has:function(a){return function(){return this.__hasPropertyValue.apply(this,[a].concat(Array.prototype.slice.call(arguments)))}}}},converters:function(a,b,c,d){a.__addSetter(d,1e3,function(a){for(var c in b)a=b[c].call(this,a);return a})},constraints:function(a,b,c,d){a.__addSetter(d,function(a){for(var c in b)if(!b[c].call(this,a))throw new Error('Constraint "'+c+'" was failed!');return a})}}})};b.Processors.sets({clazz_constants_init:i,clazz_constants_interface:j,clazz_constants:["clazz_constants_init","clazz_constants_interface"],clazz_properties_init:m,clazz_properties_interface:n,clazz_properties_meta:o,clazz_properties_defaults:l,clazz_properties:["clazz_properties_init","clazz_properties_interface","clazz_properties_meta","clazz_properties_defaults"],clazz_methods:k}),b.Manager.setType(g.META_TYPE,{clazz:{options:{constants:"clazz_constants",clazz_properties:"clazz_properties",clazz_methods:"clazz_methods"}},object:{objectHandler:function(a){return a.prototype},options:{properties:"clazz_properties",methods:"clazz_methods"}}}),d.Base=f,d.Factory=g,d.Manager=h,a.NameSpace=e,a.Clazz=d}(this,Meta);
//# sourceMappingURL=dist/ClazzJS.min.map

@@ -17,2 +17,3 @@ "use strict";

"src/Clazz.js",
"src/NameSpace.js",
"src/Base.js",

@@ -24,2 +25,3 @@ "src/Factory.js",

"src/.build",
"src/.suffix"

@@ -26,0 +28,0 @@ ]

{
"name": "clazz-js",
"title": "ClazzJS",
"version": "0.1.0",
"version": "0.1.1",
"description": "Portable JavaScript library for class-style OOP programming",

@@ -6,0 +6,0 @@ "author": {

var Base = function() {
if (typeof this.init === 'function') {
this.init.apply(this, Array.prototype.slice.call(arguments));
var response = this.init.apply(this, Array.prototype.slice.call(arguments));
if (typeof response !== 'undefined') {
return response;
}
}
}
Base.NAME = '__BASE_CLAZZ__';
Base.NAME = '__BASE_CLAZZ__';
Base.DEPENDENCIES = [];
Base.parent = null;

@@ -9,0 +15,0 @@

@@ -1,23 +0,30 @@

var Clazz = function(name, parent, meta) {
var Clazz = function(name /* [dependencies] || ( [parent], [metaTypes], meta) */) {
var parent, metaTypes, meta;
// If called as constructor - creates new clazz object.
if (this instanceof Clazz) {
var clazz = Manager.get(name);
return clazz.create.apply(clazz, Array.prototype.slice.call(arguments, 1));
var last = arguments[arguments.length-1];
if (typeof last !== 'function' && Object.prototype.toString.call(last) !== '[object Object]') {
return Manager.get(name, /* actually dependencies */parent || [])
}
else {
if (arguments.length == 1) {
if (typeof name === 'object') {
meta = name;
name = null;
}
// If only name is specified - returns entity clazz.
return name ? Manager.get(name) : Factory.create(meta);
}
// If name and some meta data are specified - save meta.
// Class will be created on demand (lazy load).
else {
Manager.setMeta(name, parent, meta);
}
meta = last;
parent = arguments[1];
metaTypes = arguments[2];
if (Object.prototype.toString.call(parent) === '[objectArray]') {
metaTypes = parent;
parent = null;
}
if (metaTypes === meta) {
metaTypes = null;
}
if (parent === meta) {
parent = null;
}
Manager.setMeta(name, {
parent: parent,
metaTypes: metaTypes,
meta: meta
});
}
var Factory = {
META_TYPE: 'ClazzJS.Clazz',
CLASS_NAME: 'Clazz{uid}',

@@ -7,16 +8,35 @@

create: function(name, parent, meta) {
if (typeof meta === 'undefined') {
meta = parent;
parent = null;
create: function(params) {
var clazz, i, ii;
var name = params.name || this.generateName();
var parent = params.parent;
var metaTypes = params.metaTypes || [this.META_TYPE];
var meta = params.meta;
var dependencies = params.dependencies || [];
if (typeof parent === 'string') {
parent = [parent];
}
if (typeof meta === 'undefined') {
meta = name;
name = null;
if (Object.prototype.toString.call(parent) === '[object Array]') {
parent = Manager.get(parent[0], parent[1] || [])
}
if (typeof parent === 'string') {
parent = Manager.get(parent);
clazz = this.createClazz(name, parent);
clazz.DEPENDENCIES = dependencies;
if (meta) {
if (typeof meta === 'function') {
meta = meta.apply(clazz, dependencies);
}
for (i = 0, ii = metaTypes.length; i < ii; ++i) {
if (typeof metaTypes[i] === 'string') {
metaTypes[i] = Meta.Manager.getType(metaTypes[i]);
}
metaTypes[i].process(clazz, meta);
}
}
return this.processMeta(this.createClazz(name, parent), meta);
return clazz;
},

@@ -30,3 +50,7 @@

var clazz = function () {
parent.apply(this, Array.prototype.slice.call(arguments));
var response = parent.apply(this, Array.prototype.slice.call(arguments));
if (typeof response !== 'undefined') {
return response;
}
}

@@ -57,15 +81,3 @@

return this.CLASS_NAME.replace('{uid}', ++this._clazzUID);
},
processMeta: function(clazz, meta) {
if (typeof meta === 'function') {
meta = meta.apply(clazz)
}
if (meta) {
Clazz.Meta.Clazz.process(clazz, meta);
Clazz.Meta.Object.process(clazz.prototype, meta);
}
return clazz;
}
}

@@ -6,8 +6,21 @@ var Manager = {

setMeta: function(name, parent, meta) {
if (typeof meta === 'undefined') {
meta = parent;
parent = undefined;
adjustName: function(name, namespace) {
if (typeof namespace === 'undefined') {
namespace = NameSpace.current();
}
this._meta[name] = [parent, meta];
return (namespace+'.'+name).replace(NameSpace.getDelimitersRegexp(), '.');
},
setMeta: function(name, meta) {
if (meta.metaTypes) {
for (var i = 0, ii = meta.metaTypes.length; i < ii; ++i) {
if (typeof meta.metaTypes[i] === 'string') {
meta.metaTypes[i] = Meta.Manager.getType(meta.metaTypes[i]);
}
}
}
this._meta[this.adjustName(name)] = meta;
return this;

@@ -17,37 +30,117 @@ },

hasMeta: function(name) {
return name in this._meta;
var i, ii, namespaces = NameSpace.whereLookFor();
for (i = 0, ii = namespaces.length; i < ii; ++i) {
if (this.adjustName(name, namespaces[i]) in this._meta) {
return true;
}
}
return false;
},
getMeta: function(name) {
if (!(name in this._meta)) {
throw new Error('Meta does not exists for "' + name + '"!');
var i, ii, aname, namespaces = NameSpace.whereLookFor();
for (i = 0, ii = namespaces.length; i < ii; ++i) {
aname = this.adjustName(name, namespaces[i]);
if (aname in this._meta) {
return this._meta[aname];
}
}
return this._meta[name];
throw new Error('Meta does not exists for "' + name + '"!');
},
getClazz: function(name) {
if (!(name in this._clazz)) {
throw new Error('Clazz does not exists for "' + name + '"!');
getClazz: function(name, dependencies) {
var i, ii, j, jj, clazz, aname, namespaces = NameSpace.whereLookFor(), isFound;
for (i = 0, ii = namespaces.length; i < ii; ++i) {
aname = this.adjustName(name, namespaces[i]);
if (aname in this._clazz) {
clazz = this._clazz[aname];
break;
}
}
return this._clazz[name];
if (Object.prototype.toString.apply(clazz) === '[object Array]') {
if (!dependencies) {
dependencies = [];
}
for (i = 0, ii = clazz.length; i < ii; ++i) {
isFound = true;
for (j = 0, jj = clazz[i].DEPENDENCIES.length; j < jj; ++j) {
if (clazz[i].DEPENDENCIES[j] !== dependencies[j]) {
isFound = false;
break;
}
}
if (isFound) {
return clazz[i];
}
}
}
throw new Error('Clazz "' + name + '" does not exists!');
},
hasClazz: function(name) {
return name in this._clazz;
hasClazz: function(name, dependencies) {
var i, ii, j, jj, clazz, aname, namespaces = NameSpace.whereLookFor(), isFound;
for (i = 0, ii = namespaces.length; i < ii; ++i) {
aname = this.adjustName(name, namespaces[i]);
if (aname in this._clazz) {
clazz = this._clazz[aname];
break;
}
}
if (Object.prototype.toString.apply(clazz) === '[object Array]') {
if (!dependencies) {
return true;
}
for (i = 0, ii = clazz.length; i < ii; ++i) {
isFound = true;
for (j = 0, jj = clazz[i].DEPENDENCIES.length; j < jj; ++j) {
if (clazz[i].DEPENDENCIES[j] !== dependencies[j]) {
isFound = false;
break;
}
}
if (isFound) {
return true;
}
}
}
return false;
},
setClazz: function(name, clazz) {
if (typeof name === 'function') {
clazz = name;
name = clazz.NAME;
}
if (typeof clazz !== 'function') {
throw new Error('Clazz must be a function!');
}
this._clazz[name] = clazz;
var aname = this.adjustName(name);
if (!(aname in this._clazz)) {
this._clazz[aname] = [];
}
this._clazz[aname].push(clazz);
return this;
},
get: function(name) {
if (!this.hasClazz(name)) {
get: function(name , dependencies) {
if (!this.hasClazz(name, dependencies)) {
var meta = this.getMeta(name);
this.setClazz(name, Factory.create(name, meta[0], meta[1]));
meta.name = name;
meta.dependencies = dependencies;
this.setClazz(Factory.create(meta));
}
return this.getClazz(name);
return this.getClazz(name, dependencies);
},

@@ -54,0 +147,0 @@

@@ -1,2 +0,2 @@

var ConstantsInterfaceProcessor = new Meta.Processor.Interface({
var ConstantsInterfaceProcessor = new Meta.Processors.Interface({

@@ -3,0 +3,0 @@ const: function(name) {

@@ -1,9 +0,52 @@

var PropertiesDefaultsProcessor = function(object) {
var PropertiesDefaultsProcessor = {
var property, defaults = object.getDefaults();
process: function(object) {
for (property in defaults) {
object['_' + property] = defaults[property];
var type, defaultValue, property, properties = object.__properties
for (property in properties) {
defaultValue = properties[property]['default'];
if (typeof defaultValue === 'undefined') {
type = properties[property]['type'];
if (typeof type !== 'undefined' && type in this.DEFAULT) {
defaultValue = this.DEFAULT[type];
}
}
object['_' + property] = this.copy(defaultValue);
}
},
copy: function(object) {
var copy, toString = Object.prototype.toString.apply(object);
if (typeof object !== 'object') {
copy = object;
}
else if ('[object Date]' === toString) {
copy = new Date(object.getTime())
}
else if ('[object Array]' === toString) {
copy = [];
for (var i = 0, ii = object.length; i < ii; ++i) {
copy[i] = this.copy(object[i]);
}
}
else if ('[object RegExp]' === toString) {
copy = new RegExp(object.source);
}
else {
copy = {}
for (var property in object) {
copy[property] = this.copy(object[property]);
}
}
return copy;
},
DEFAULT: {
hash: {},
array: []
}
}

@@ -1,7 +0,8 @@

var PropertiesInterfaceProcessor = new Meta.Processor.Interface({
var PropertiesInterfaceProcessor = new Meta.Processors.Interface({
__setters: {},
__getters: {},
__defaults: {},
__properties: {},
init: function(data) {

@@ -11,34 +12,45 @@ this.__setData(data);

__adjustPropertyName: function(name) {
return name.replace(/(?:_)\w/, function (match) { return match[1].toUpperCase(); });
__setProperties: function(properties) {
for (var property in properties) {
this.__setProperty(property, properties[property]);
}
return this;
},
__getDefaults: function() {
var defaults = {}, parent = this;
__getProperties: function() {
return this.__properties;
},
while (parent) {
if (parent.hasOwnProperty('__defaults')) {
for (var prop in parent.__defaults) {
if (!(prop in defaults)) {
defaults[prop] = parent.__defaults[prop];
}
}
__setProperty: function(property, key, value) {
property = this.__adjustPropertyName(property);
if (typeof this.__properties[property] === 'undefined') {
this.__properties[property] = {};
}
if ({}.constructor === key.constructor) {
for (var prop in key) {
this.__properties[property][prop] = key[prop];
}
}
else {
this.__properties[property][key] = value;
}
parent = parent.parent;
}
return defaults
return this;
},
__getDefault: function(property) {
var defaults = this.__getDefaults();
return property in defaults ? defaults[property] : undefined;
__getProperty: function(property, key) {
return typeof key === 'undefined'
? this.__properties[property]
: this.__properties[property] && this.__properties[property][key];
},
__setDefault: function(property, value) {
this.__defaults[property] = value;
__hasProperty: function(property) {
property = this.__adjustPropertyName(property);
return ('_' + property) in this && typeof this['_' + property] !== 'function';
},
__hasDefault: function(property) {
return property in this.__getDefaults();
__adjustPropertyName: function(name) {
return name.replace(/(?:_)\w/, function (match) { return match[1].toUpperCase(); });
},

@@ -51,3 +63,3 @@

}
this.__setProperty(property, data[property]);
this.__setPropertyValue(property, data[property]);
}

@@ -57,3 +69,5 @@ return this;

__getProperty: function(property) {
__getPropertyValue: function(property /*, fields... */) {
var getters, i, ii, name, value;
property = this.__adjustPropertyName(property);

@@ -65,12 +79,24 @@

var value = this['_' + property], getters = this.__getGetters(property);
value = this['_' + property];
for (var name in getters) {
getters = this.__getGetters(property);
for (name in getters) {
value = getters[name].call(this, value);
}
var fields = Object.prototype.toString.call(arguments[1]) === '[object Array]'
? arguments[1]
: Array.prototype.slice.call(arguments, 1);
for (i = 0, ii = fields.length; i < ii; ++i) {
value = value[fields[i]];
}
return value;
},
__setProperty: function(property, value) {
__setPropertyValue: function(property /* fields... , value */) {
var setters, i, ii, name, fields, value, setValue = arguments[arguments.length - 1];
property = this.__adjustPropertyName(property);

@@ -82,5 +108,23 @@

var setters = this.__getSetters(property);
fields = Object.prototype.toString.call(arguments[1]) === '[object Array]'
? arguments[1]
: Array.prototype.slice.call(arguments, 1, -1);
for (var name in setters) {
if (fields && fields.length) {
value = this['_' + property];
for (i = 0, ii = fields.length - 1; i < ii; ++i) {
if (!(fields[i] in value)) {
value[fields[i]] = {};
}
value = value[fields[i]];
}
value[fields[i]] = setValue;
}
else {
value = setValue;
}
setters = this.__getSetters(property);
for (name in setters) {
value = setters[name].call(this, value);

@@ -94,17 +138,22 @@ }

__hasProperty: function(property) {
property = this.__adjustPropertyName(property);
__isPropertyValue: function(property /* fields... , value */) {
var fields = Object.prototype.toString.apply(arguments[1]) === '[object Array]'
? arguments[1]
: Array.prototype.slice.call(arguments, 1);
return ('_' + property) in this && typeof this['_' + property] !== 'function';
},
var value = this.__getPropertyValue(property, fields);
var compare = arguments[arguments.length - 1];
__isProperty: function(property, value) {
return typeof value !== 'undefined' ? value == this.__getProperty(property) : Boolean(this.__getProperty(property));
return typeof value !== 'undefined' ? value == compare : !!value;
},
__isEmptyProperty: function(property) {
var value = this.__getProperty(property);
__hasPropertyValue: function(property /*, fields... */) {
var fields = Object.prototype.toString.apply(arguments[1]) === '[object Array]'
? arguments[1]
: Array.prototype.slice.call(arguments, 1);
var value = this.__getPropertyValue(property, fields);
if (Object.prototype.toString.apply(value) === '[object Object]') {
for (var prop in value) {
for (var p in value) {
return true;

@@ -115,6 +164,6 @@ }

return (typeof this[value] === 'undefined')
return !((typeof this[value] === 'undefined')
|| (value === null)
|| (typeof value === 'string' && value === '')
|| (Object.prototype.toString.apply(value) === '[object Array]' && value.length === 0);
|| (Object.prototype.toString.apply(value) === '[object Array]' && value.length === 0));
},

@@ -139,7 +188,7 @@

__getSetters: function(property) {
var setters, prop, allSetters = {}, parent = this.clazz.prototype;
var i, ii, setters, prop, allSetters = {}, parent = this.clazz.prototype;
while (parent) {
if (parent.hasOwnProperty('__setters')) {
for (var prop in parent.__setters) {
for (prop in parent.__setters) {
if (!(prop in allSetters)) {

@@ -150,4 +199,3 @@ allSetters[prop] = parent.__setters[prop];

}
parent = parent.parent;
parent = parent.parent;
}

@@ -163,3 +211,3 @@

for (var i = 0, ii = allSetters[property].length; i < ii; ++i) {
for (i = 0, ii = allSetters[property].length; i < ii; ++i) {
setters.push(allSetters[property][i][1]);

@@ -193,7 +241,7 @@ }

__getGetters: function(property) {
var getters, allGetters = {}, parent = this.clazz.prototype;
var i, ii, prop, getters, allGetters = {}, parent = this.clazz.prototype;
while (parent) {
if (parent.hasOwnProperty('__getters')) {
for (var prop in parent.__getters) {
for (prop in parent.__getters) {
if (!(prop in allGetters)) {

@@ -216,3 +264,3 @@ allGetters[prop] = parent.__getters[prop];

for (var i = 0, ii = allGetters[property].length; i < ii; ++i) {
for (i = 0, ii = allGetters[property].length; i < ii; ++i) {
getters.push(allGetters[property][i][1]);

@@ -219,0 +267,0 @@ }

@@ -5,146 +5,172 @@ var PropertiesMetaProcessor = {

for (var property in properties) {
this.Meta.process(object, properties[property], property)
this.MetaHandler.process(object, properties[property], property)
}
},
Meta: new Meta({
MetaHandler: new Meta.Handler({
options: {
type: {
process: function(object, type, option, property) {
var self = this, params = {};
if (Object.prototype.toString.apply(type) === '[object Array]') {
params = type[1];
type = type[0];
}
if (!(type in this.TYPES)) {
throw new Error('Unsupported property type "' + type + '"!');
}
type: {
process: function(object, type, option, property) {
if (Object.prototype.toString.apply(type) !== '[object Array]') {
type = [type, {}];
}
if (!(type[0] in this.TYPES)) {
throw new Error('Unsupported property type "' + type[0] + '"!');
}
object.__setProperty(property, 'type', type);
var typer = this.TYPES[type[0]];
object.__addSetter(property, function(value) {
return self.checkValue(value, type, params);
});
},
object.__addSetter(property, function(value) {
return typer.call(object, value, type[1]);
});
},
checkValue: function(value, type, params) {
return this.TYPES[type].call(this, value, params);
},
TYPES: {
boolean: function(value) {
return Boolean(value);
},
number: function(value, params) {
value = Number(value);
if ('min' in params && value < params['min']) {
throw new Error('Value "' + value + '" must not be less then "' + params['min'] + '"!');
TYPES: {
boolean: function(value) {
return Boolean(value);
},
number: function(value, params) {
value = Number(value);
if ('min' in params && value < params['min']) {
throw new Error('Value "' + value + '" must not be less then "' + params['min'] + '"!');
}
if ('max' in params && value > params['max']) {
throw new Error('Value "' + value + '" must not be greater then "' + params['max'] + '"!');
}
return value;
},
string: function(value, params) {
value = String(value);
if ('pattern' in params && !params['pattern'].test(value)) {
throw new Error('Value "' + value + '" does not match pattern "' + params['pattern'] + '"!');
}
return value;
},
datetime: function(value) {
if (!(value instanceof Date)) {
value = new Date(Date.parse(value));
}
return value;
},
array: function(value, params) {
return typeof value === 'string' ? value.split(params['delimiter'] || ',') : [].concat(value);
},
hash: function(value, params) {
if ({}.constructor !== value.constructor) {
throw new Error('Incorrect value: not hash type!');
}
if ('keys' in params) {
for (var prop in value) {
if (!(prop in params.keys)) {
throw new Error('Unsupported hash key "' + prop + '"!');
}
}
}
if ('element' in params) {
this.checkValue.apply(this, [].concat(params.element));
}
return value;
}
if ('max' in params && value > params['max']) {
throw new Error('Value "' + value + '" must not be greater then "' + params['max'] + '"!');
}
return value;
},
string: function(value, params) {
value = String(value);
if ('pattern' in params && !params['pattern'].test(value)) {
throw new Error('Value "' + value + '" does not match pattern "' + params['pattern'] + '"!');
}
return value;
},
datetime: function(value) {
if (!(value instanceof Date)) {
value = new Date(Date.parse(value));
}
return value;
},
array: function(value, params) {
return typeof value === 'string' ? value.split(params['delimiter'] || ',') : [].concat(value);
}
}
},
},
default: function(object, defaultValue, option, property) {
if (typeof defaultValue === 'function') {
defaultValue = defaultValue();
}
default: {
process: function(object, defaultValue, option, property) {
var type;
this.__setDefault(property, defaultValue);
},
if (typeof defaultValue === 'function') {
defaultValue = defaultValue();
}
methods: {
process: function(object, methods, option, property) {
if (Object.prototype.toString.apply(methods) !== '[object Array]') {
methods = [methods];
object.__setProperty(property, 'default', defaultValue);
}
for (var i = 0, ii = methods.length; i < ii; ++i) {
this.addMethod(methods[i], object, property);
}
},
addMethod: function(name, object, property) {
var method = this.createMethod(name, property);
object[method.name] = method.body;
},
createMethod: function(name, property) {
if (!(name in this.METHODS)) {
throw new Error('Unsupported method "' + name + '"!');
}
return this.METHODS[name](property);
},
methods: {
METHODS: {
get: function(property) {
return {
name: 'get' + property[0].toUpperCase() + property.slice(1),
body: function() {
return this.__getProperty(property);
}
process: function(object, methods, option, property) {
if (Object.prototype.toString.apply(methods) !== '[object Array]') {
methods = [methods];
}
for (var i = 0, ii = methods.length; i < ii; ++i) {
this.addMethod(methods[i], object, property);
}
},
set: function(property) {
return {
name: 'set' + property[0].toUpperCase() + property.slice(1),
body: function(value) {
return this.__setProperty(property, value);
}
addMethod: function(name, object, property) {
var method = this.createMethod(name, property);
object[method.name] = method.body;
},
createMethod: function(name, property) {
if (!(name in this.METHODS)) {
throw new Error('Unsupported method "' + name + '"!');
}
},
is: function(property) {
return {
name: (0 !== property.indexOf('is') ? 'is' : '') + property[0].toUpperCase() + property.slice(1),
body: function(value) {
return this.__isProperty(property, value);
var method = this.METHODS[name](property);
if (typeof method === 'function') {
method = {
name: name + property[0].toUpperCase() + property.slice(1),
body: method
}
}
return method;
},
isEmpty: function(property) {
return {
name: (0 !== property.indexOf('isEmpty') ? 'isEmpty' : '') + property[0].toUpperCase() + property.slice(1),
body: function() {
return this.__isEmptyProperty(property);
METHODS: {
get: function(property) {
return function() {
return this.__getPropertyValue.apply(this, [property].concat(Array.prototype.slice.call(arguments)));
}
},
set: function(property) {
return function(value) {
return this.__setPropertyValue.apply(this, [property].concat(Array.prototype.slice.call(arguments)));
}
},
is: function(property) {
return {
name: (0 !== property.indexOf('is') ? 'is' : '') + property[0].toUpperCase() + property.slice(1),
body: function() {
return this.__isPropertyValue.apply(this, [property].concat(Array.prototype.slice.call(arguments)));
}
}
},
has: function(property) {
return function() {
return this.__hasPropertyValue.apply(this, [property].concat(Array.prototype.slice.call(arguments)));
}
}
}
}
},
},
converters: function(object, converters, option, property) {
converters: function(object, converters, option, property) {
object.__addSetter(property, 1000, function(value) {
for (var name in converters) {
value = converters[name].call(this, value);
}
return value;
})
},
object.__addSetter(property, 1000, function(value) {
for (var name in converters) {
value = converters[name].call(this, value);
}
return value;
})
},
constraints: function(object, constraints, option, property) {
constraints: function(object, constraints, option, property) {
object.__addSetter(property, function(value) {
for (var name in constraints) {
if (!constraints[name].call(this, value)) {
throw new Error('Constraint "' + name + '" was failed!');
object.__addSetter(property, function(value) {
for (var name in constraints) {
if (!constraints[name].call(this, value)) {
throw new Error('Constraint "' + name + '" was failed!');
}
}
}
return value;
})
return value;
})
}
}
})
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc