-
Notifications
You must be signed in to change notification settings - Fork 0
from()
the from function is similar to the init function but it doesn't have a name parameter because it carries over the name of the class entered
if the class doesn't have a name it defaults to "Unnamed"
const Class = require('aepl');
// creates a normal class
class A {
constructor() {
this.data = [1, 2, 3];
}
}
// creates the new aepl class
Class.from(A);
// creates a new prop called test
A.newProp("test", function() {
return this.data.reverse();
});
// creates a new instance
let a = new A();
console.log(a); // A { data: [1, 2, 3] }
console.log(a.test); // [3, 2, 1]
its main use is for having separate names for classes along with Class.setName()
const Class = require('aepl');
// creates a normal class
class A {
constructor() {
this.data = [1, 2, 3];
}
}
// creates the new aepl class
Class.from(A);
// creates a new prop called test
A.newProp("test", function() {
return this.data.reverse();
});
// sets the name of the class
A.setName("B");
// creates a new instance of B
let b = new B();
console.log(b); // A { data: [1, 2, 3] }
console.log(b.test); // [3, 2, 1]
If you want to check out the different versions and changes check out the releases
For a look into the development side check out the src folder
init()
from()
inspect()
new()
addClass()
addFunc()
addProp()
addChore()
addAsyncChore()
addPreClass()
addPreFunc()
addPreProp()
addPreChore()
addPreAChore()
setName()
setInspect()
Subclass
Function
Property
Chore
AsyncChore
Preclass
PreFunction
PreProperty
PreChore
PreAsyncChore
compact
multiple-layers
event handler
alternate names
setting and getting inspects