gedbac / class4js Goto Github PK
View Code? Open in Web Editor NEWThe class4j module is for class-driven development in JavaScript.
Home Page: www.class4js.com
License: Other
The class4j module is for class-driven development in JavaScript.
Home Page: www.class4js.com
License: Other
var DieselEngine = function (hp) {
this.__hp = hp;
Object.defineProperty(this, '__hp', { enumerable: false });
Object.seal(this);
};
$package - it will create new scope which will be integrated to given namespace:
class4js.Package.create(namespace: String, scope: Object): void
or
$package(namespace: String, scope: Object): void
Example
$package("class4js.utl", {
MyClass: $class({
// ...
})
});
Example:
var Component = $class({
get name () {
return this.__name;
},
set name (value) {
this.__name = value;
}
});
Proxies should be declared by using $proxy keyword.
var person = Activator.create(Person, { name = "petras", age = 30 });
Wrong line:
var index = this.__listeners.indexOf(listener);
Should be:
var index = this.__listeners[type].indexOf(listener);
var Shape = $class({ ... });
var Rectangle = $class({ ... }, Shape);
var rec = new Rectangle();
$is(rec, Shape); // This statement should return true
var Priority = $enum({
Low: 0,
Normal: 1,
Hight: 2
});
Enum field's name should be in uppercasing
Example: 'toString' in 22
Doesn't work:
var confirmedEvent = new loaddex.visual.common.Event({ cancelable: true });
this.fire('confirmed', confirmedEvent);
if (!confirmedEvent.isDefaultPrevented) {
this._goBack();
}
Events implementation should be moved from util4js to class4js module. Events implementation also should be adapted to Node.js.
$import - it will create new scope and will import members from other scopes to thew newly created scope:
class4js.Package.import(dependencies: Array, scope: Function): void
or
$import(dependencies: Array, scope: Function): void
Example
$import(["class4js", "util", "io"], function () {
// ...
});
$package - it will create new scope which will be integrated to given namespace:
class4js.Package.create(namespace: String, scope: Object): void
or
$package(namespace: String, scope: Object): void
Example
$package("class4js.utl", {
MyClass: $class({
// ...
})
});
Example:
var util = $module([window], function (exports, global) {
exports.Exception = ...
});
Implement Interface class which will allow to use contract approach in JavaScript
var TypeException = function (message) {
this.__name = "TypeException";
this.__message = message;
} <-- here
create: {
value: function (properties, parent, interfaces) {
var constructor = function () {
if (Class.__extensions && Class.__extensions.length > 0) {
for (var i = 0; i < Class.__extensions.length; i++) { <-- here
instanceOf: {
value: function (source, target) {
if (source && target) {
if (typeof target === "object") {
for (var propertyName in target) {
if (!(propertyName in source)) {
return false;
}
}
} else if (!(source instanceof target)) {
return false;
}
return true;
} else {
throw new TypeException("Source or target is not set");
}
return false; <-- here
},
exports.Interface = Interface <-- here
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.