diff --git a/.github/workflows/publish-wiki.yml b/.github/workflows/publish-wiki.yml new file mode 100644 index 0000000..741c6c9 --- /dev/null +++ b/.github/workflows/publish-wiki.yml @@ -0,0 +1,18 @@ +name: Publish wiki +on: + push: + branches: [main] + paths: + - wiki/** + - .github/workflows/publish-wiki.yml +concurrency: + group: publish-wiki + cancel-in-progress: true +permissions: + contents: write +jobs: + publish-wiki: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: Andrew-Chen-Wang/github-wiki-action@v4 \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..308faee --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/node_modules +/package-lock.json +/config.json \ No newline at end of file diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..9b540a8 --- /dev/null +++ b/.npmignore @@ -0,0 +1,7 @@ +/prog +/assets +/node_modules +/.github +/.vscode +/wiki +/tests \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..10451eb --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,17 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Launch Program", + "skipFiles": [ + "/**" + ], + "program": "${workspaceFolder}/tests/bulkwiki.js" + } + ] +} \ No newline at end of file diff --git a/README.md b/README.md index d128703..a7ec394 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # aepl 🍎 version downloads -docs -publish +docs +publish aepl is a Node.JS multi-layered class creation package with built-in parenting systems that let you get info from classes above as well as better function and property makers for easier to read and understand development and modding support inspired by Roblox's Studio API. - Open source @@ -16,7 +16,7 @@ aepl is a Node.JS multi-layered class creation package with built-in parenting s npm i aepl ``` ```console -npm i paishee/aepl +npm i shysolocup/aepl ``` diff --git a/tests/bulkwiki.js b/tests/bulkwiki.js new file mode 100644 index 0000000..07ac8e4 --- /dev/null +++ b/tests/bulkwiki.js @@ -0,0 +1,23 @@ +const fs = require('fs'); +const pages = fs.readdirSync('wiki'); + +console.log(pages); + +pages.forEach(p => { + let content = fs.readFileSync(`wiki/${p}`, 'utf8'); + + let replacers = { + "paigeroid": "shysolocup", + "paishee": "shysolocup", + "revameg": "shysolocup", + "nutmeg": "shysolocup" + }; + + for (let [r, w] of Object.entries(replacers)) { + while (content.includes(r)) { + content = content.replace(r, w) + } + } + + fs.writeFileSync(`wiki/${p}`, content); +}); \ No newline at end of file diff --git a/wiki/AsyncChore.md b/wiki/AsyncChore.md new file mode 100644 index 0000000..079f202 --- /dev/null +++ b/wiki/AsyncChore.md @@ -0,0 +1,53 @@ +Async Chores are async functions made from strings.
+These can be beneficial to know for some occasions +```js +const Class = require('aepl'); + + +// creates a new class named Example +new Class("Example", class { + constructor() { + this.data = [1, 2, 3]; + } + + sleep(time) { + return new Promise(resolve => setTimeout(resolve, time*1000)); + } +}); + + +// creates a new chore named add using a string with function data +new Example.AsyncChore("add", "number", ` + console.log(this.data); // [1, 2, 3] + + await this.sleep(3); // waits for 3 seconds + + this.data.push(number); + console.log(this.data); // [1, 2, 3, 4] +`); + + +// creates a new instance of the class +let example = new Example(); + +(async () => { + await example.add(4); +})(); +``` + +
+ +> ## Class.AsyncChore +> description: creates a new async chore
+> calls: +> - AsyncChore/asyncChore +> - AChore/aChore +> +> parameters: +> - name `String`: name of the async chore +> - ...?parameters `String`: parameters for the async chore +> - value `String`: what the async chore does +> +>
+> +> note: too lazy to add any example for this you get it \ No newline at end of file diff --git a/wiki/Chore.md b/wiki/Chore.md new file mode 100644 index 0000000..6512b5d --- /dev/null +++ b/wiki/Chore.md @@ -0,0 +1,50 @@ +Chores are functions made from strings.
+These can be beneficial to know for some occasions +```js +const Class = require('aepl'); + + +// creates a new class named Example +new Class("Example", class { + constructor() { + this.data = [1, 2, 3]; + } +}); + + +// creates a new chore named add using a string with function data +new Example.Chore("add", "number", "this.data.push(number)"); + + +// creates a new instance of the class +let example = new Example(); + +console.log(example.data); // [1, 2, 3] + +example.add(4); + +console.log(example.data); // [1, 2, 3, 4] +``` + +
+ +> ## Class.Chore +> description: creates a new chore
+> calls: +> - Chore/chore +> +> parameters: +> - name `String`: name of the chore +> - ...?parameters `String`: parameters for the chore +> - value `String`: what the chore does +> ```js +> new Class("Example", class { /* class info */ }); +> +> new Example.Chore("a", "function data"); +> new Example.Chore("b", "arg1", "arg2" "function data"); +> +> let example = new Example(); +> +> example.a(); // runs whatever's in the function +> example.b(1, 2); // runs whatever's in the function +> ``` \ No newline at end of file diff --git a/wiki/Classes.md b/wiki/Classes.md new file mode 100644 index 0000000..898571e --- /dev/null +++ b/wiki/Classes.md @@ -0,0 +1,36 @@ +Class is the export from aepl and it's used to make new aepl classes
+When new classes are created it automatically defines it for you unless you tell it not to +```js +const Class = require('aepl'); + + +// creates a new class named Main +new Class("Main", class { + constructor() { + this.data = [ 1, 2, 3 ]; + } +}); + + +// creates a new instance of the Main class +let main = new Main(); + + +console.log(main.data); // [ 1, 2, 3 ] +``` + +
+ +> ## Class +> description: creates a new aepl class
+> parameters: +> - name `String`: name of the class +> - class `Class`: class to create using +> - ?autodefine `Boolean`: if the class should automatically define or not +> ```js +> new Class("Example1", class { /* class info */ }); +> let Example2 = new Class("Example2", class { /* class info */ }, false); +> +> let ex1 = new Example1(); +> let ex2 = new Example2(); +> ``` diff --git a/wiki/Function.md b/wiki/Function.md new file mode 100644 index 0000000..b81b493 --- /dev/null +++ b/wiki/Function.md @@ -0,0 +1,52 @@ +Function is used to create new functions for your class +```js +const Class = require('aepl'); + + +// creates a new class named Example +new Class("Example", class { + constructor() { + this.data = [1, 2, 3]; + } +}); + + +// creates a new function for the Example class +new Example.Function("add", function(number) { + return this.data.push(number); +}); + + +// creates a new instance of the class +let example = new Example(); + +console.log(example.data); // [1, 2, 3] + +example.add(4); + +console.log(example.data); // [1, 2, 3, 4] +``` + +
+ + +> ## Class.Function +> description: creates a new function
+> calls: +> - Function/function +> - Func/func +> +> parameters: +> - name `String`: name of the function +> - value `Any`: what the function does (usually a function but can be a normal value) +> ```js +> new Class("Example", class { /* class info */ }); +> +> new Example.Function("a", function() { /* function info */ }); +> new Example.Function("b", "value"); +> +> let example = new Example(); +> +> example.a(); // runs whatever's in the function +> example.b(); // returns "value" +> ``` \ No newline at end of file diff --git a/wiki/Home.md b/wiki/Home.md new file mode 100644 index 0000000..e6f643b --- /dev/null +++ b/wiki/Home.md @@ -0,0 +1,8 @@ +
+

aepl wiki 🍎

+ +Welcome to the aepl wiki pages, where you can find documentation about pretty much everything.

+ +If you have any issues, bugs or suggestions report them [here](https://github.com/paigeroid/aepl/issues) + +
\ No newline at end of file diff --git a/wiki/Installation.md b/wiki/Installation.md new file mode 100644 index 0000000..6a659e9 --- /dev/null +++ b/wiki/Installation.md @@ -0,0 +1,6 @@ +```console +npm i aepl +``` +```console +npm i paishee/aepl +``` \ No newline at end of file diff --git a/wiki/Property.md b/wiki/Property.md new file mode 100644 index 0000000..b8a995d --- /dev/null +++ b/wiki/Property.md @@ -0,0 +1,55 @@ +Properties are just good old variables inside of classes.
+If you put a function in while creating a property it'll run that function everytime that the value is gotten
+They can be set by overwriting them with a new value or by using Class.setProp() +```js +const Class = require('aepl'); + + +// creates a new class named Example +new Class("Example", class { + constructor() { + this.data = [1, 2, 3, 4]; + } +}); + + +// creates a new property named thing that'll return "thing" +new Example.Property("thing", "thing"); + + +// creates a new property named reversed that'll return a reversed version of the data +new Example.Property("reversed", function() { + return this.data.reverse(); +}); + + +// creates a new instance of the class +let example = new Example(); + + +console.log(example.thing); // "thing" +console.log(example.reversed); // [4, 3, 2, 1] +``` + +
+ +> ## Class.Property +> description: creates a new property
+> calls: +> - Property/property +> - Prop/prop +> +> parameters: +> - name `String`: name of the property +> - value `Any`: value of the property (can be a function) +> ```js +> new Class("Example", class { /* class info */ }); +> +> new Example.Property("a", "value"); +> new Example.Property("b", function() { /* property info */ }); +> +> let example = new Example(); +> +> example.a; // returns "value" +> example.b; // returns whatever's in the function +> ``` \ No newline at end of file diff --git a/wiki/Subclass.md b/wiki/Subclass.md new file mode 100644 index 0000000..abad486 --- /dev/null +++ b/wiki/Subclass.md @@ -0,0 +1,55 @@ +you can use new x.Class(), new x.Subclass(), new x.SubClass(), or new x.Sub() to create a new sub class +```js +const Class = require('aepl'); + + +// creates a new class named A +new Class("A", class { + constructor() { + this.data = [1, 2, 3]; + } +}); + + +// creates a new subclass named B +new A.Class("B", class { + constructor() { + this.data = [4, 5, 6]; + } +}); + + +// creates a new instance of A +let a = new A(); + +console.log(a.data); // [1, 2, 3] + +// creates a new instance of B +let b = new a.B(); + +console.log(b.data); // [4, 5, 6] +``` + +
+ +> ## Class.Subclass +> description: creates a new subclass
+> calls: +> - Class/class +> - SubClass/Subclass/subclass +> - Sub/sub +> +> parameters: +> - name `String`: name of the subclass +> - value `Any`: class to create using (usually a class but it can also just be a value) +> ```js +> new Class("Example", class { /* class info */ }); +> +> new Example.Class("A", class { /* class info */ }); +> new Example.Class("B", "value"); +> +> let example = new Example(); +> +> let a = new example.A(); // whatever's in the class +> let b = new example.B(); // returns "value" +> ``` \ No newline at end of file diff --git a/wiki/_Footer.md b/wiki/_Footer.md new file mode 100644 index 0000000..b5ee2eb --- /dev/null +++ b/wiki/_Footer.md @@ -0,0 +1,5 @@ +# Change Logs +If you want to check out the different versions and changes check out the [releases](https://github.com/paigeroid/aepl/releases) + +# Source Code +For a look into the development side check out the [src folder](https://github.com/paigeroid/aepl/tree/main/src) \ No newline at end of file diff --git a/wiki/_Sidebar.md b/wiki/_Sidebar.md new file mode 100644 index 0000000..d0cea3d --- /dev/null +++ b/wiki/_Sidebar.md @@ -0,0 +1,54 @@ +# aepl docs 🍎 +### [Home](https://github.com/paigeroid/aepl/wiki) + +> ### Introduction +> [Installation](https://github.com/paigeroid/aepl/wiki/Installation)
+> [Classes](https://github.com/paigeroid/aepl/wiki/Classes)
+> [parent](https://github.com/paigeroid/aepl/wiki/parent)
+> [inspect](https://github.com/paigeroid/aepl/wiki/inspect)
+> [calls](https://github.com/paigeroid/aepl/wiki/calls)
+ +
+ +> ### Functions +> [init()](https://github.com/paigeroid/aepl/wiki/init())
+> [from()](https://github.com/paigeroid/aepl/wiki/from())
+> [inspect()](https://github.com/paigeroid/aepl/wiki/inspect())
+> [new()](https://github.com/paigeroid/aepl/wiki/new())
+> [addClass()](https://github.com/paigeroid/aepl/wiki/addClass())
+> [addFunc()](https://github.com/paigeroid/aepl/wiki/addFunc())
+> [addProp()](https://github.com/paigeroid/aepl/wiki/addProp())
+> [addChore()](https://github.com/paigeroid/aepl/wiki/addChore())
+> [addAsyncChore()](https://github.com/paigeroid/aepl/wiki/addAsyncChore())
+> [addPreClass()](https://github.com/paigeroid/aepl/wiki/addPreClass())
+> [addPreFunc()](https://github.com/paigeroid/aepl/wiki/addPreFunc())
+> [addPreProp()](https://github.com/paigeroid/aepl/wiki/addPreProp())
+> [addPreChore()](https://github.com/paigeroid/aepl/wiki/addPreChore())
+> [addPreAChore()](https://github.com/paigeroid/aepl/wiki/addPreAChore())
+> [setName()](https://github.com/paigeroid/aepl/wiki/setName())
+> [setInspect()](https://github.com/paigeroid/aepl/wiki/setInspect())
+ +
+ +> ### Classes +> [Subclass](https://github.com/paigeroid/aepl/wiki/Subclass)
+> [Function](https://github.com/paigeroid/aepl/wiki/Function)
+> [Property](https://github.com/paigeroid/aepl/wiki/Property)
+> [Chore](https://github.com/paigeroid/aepl/wiki/Chore)
+> [AsyncChore](https://github.com/paigeroid/aepl/wiki/AsyncChore)
+> [Preclass](https://github.com/paigeroid/aepl/wiki/Preclass)
+> [PreFunction](https://github.com/paigeroid/aepl/wiki/PreFunction)
+> [PreProperty](https://github.com/paigeroid/aepl/wiki/PreProperty)
+> [PreChore](https://github.com/paigeroid/aepl/wiki/PreChore)
+> [PreAsyncChore](https://github.com/paigeroid/aepl/wiki/PreAsyncChore)
+ +
+ +> ### Advanced Examples +> [compact](https://github.com/paigeroid/aepl/wiki/compact)
+> [multiple-layers](https://github.com/paigeroid/aepl/wiki/multiple-layers)
+> [event handler](https://github.com/paigeroid/aepl/wiki/event-handler)
+> [alternate names](https://github.com/paigeroid/aepl/wiki/alternate-names)
+> [setting and getting inspects](https://github.com/paigeroid/aepl/wiki/settings-and-getting-inspects)
+ +
\ No newline at end of file diff --git a/wiki/addAsyncChore().md b/wiki/addAsyncChore().md new file mode 100644 index 0000000..a9d915d --- /dev/null +++ b/wiki/addAsyncChore().md @@ -0,0 +1,17 @@ +addAsyncChore() adds a new async chore
+too lazy to do an example for it + +
+ +> ## Class.addAsyncChore() +> description: adds a new async chore
+> calls: +> - addAsyncChore() +> - addAChore() +> - setAsyncChore() +> - setAChore() +> - newAsyncChore() +> - newAChore() +> - addACh() +> - setACh() +> - newACh() \ No newline at end of file diff --git a/wiki/addChore().md b/wiki/addChore().md new file mode 100644 index 0000000..6051503 --- /dev/null +++ b/wiki/addChore().md @@ -0,0 +1,30 @@ +addChore() adds a new chore +```js +const Class = require('aepl'); + + +new Class("Main", class { + constructor() { + this.data = [1, 2, 3]; + } +}); + + +Main.addChore("reverse", `return this.data.reverse();`); + +let main = new Main(); + +console.log(main.reverse()); // [3, 2, 1] +``` + +
+ +> ## Class.addChore() +> description: adds a new chore
+> calls: +> - addChore() +> - setChore() +> - newChore() +> - addCh() +> - setCh() +> - newCh() \ No newline at end of file diff --git a/wiki/addClass().md b/wiki/addClass().md new file mode 100644 index 0000000..53004f8 --- /dev/null +++ b/wiki/addClass().md @@ -0,0 +1,36 @@ +addClass(), addSubClass() and addSub() adds a new subclass +```js +const Class = require('aepl'); + + +new Class("Main", class { /* class info */ }); + + +Main.addSub("Layer0", class { /* class info */ }); +Main.addClass("Layer1", class { /* class info */ }); +Main.addSubClass("Layer2", class { /* class info */ }); +``` + +
+ +> ## Class.addClass() +> description: adds a new subclass
+> calls: +> - addClass() +> - addSubClass()/addSubclass() +> - addSub() +> - setClass() +> - setSubClass()/setSubclass() +> - setSub() +> - newClass() +> - newSubClass()/newSubclass() +> - newSub() +> - addC() +> - addSC() +> - addS() +> - setC() +> - setSC() +> - setS() +> - newC() +> - newSC() +> - newS() \ No newline at end of file diff --git a/wiki/addFunc().md b/wiki/addFunc().md new file mode 100644 index 0000000..3da663b --- /dev/null +++ b/wiki/addFunc().md @@ -0,0 +1,36 @@ +addFunc() and addFunction() adds a new function +```js +const Class = require('aepl'); + + +new Class("Main", class { + constructor() { + this.data = [1, 2, 3]; + } +}); + + +Main.addFunc("reverse", function() { + return this.data.reverse(); +}); + + +let main = new Main(); + +console.log(main.reverse()); // [3, 2, 1] +``` + +
+ +> ## Class.addFunc() +> description: adds a new function
+> calls: +> - addFunc() +> - addFunction() +> - setFunc() +> - setFunction() +> - newFunc() +> - newFunction() +> - addF() +> - setF() +> - newF() \ No newline at end of file diff --git a/wiki/addProp().md b/wiki/addProp().md new file mode 100644 index 0000000..936cdab --- /dev/null +++ b/wiki/addProp().md @@ -0,0 +1,36 @@ +addProp() and addProperty() adds a new property +```js +const Class = require('aepl'); + + +new Class("Main", class { + constructor() { + this.data = [1, 2, 3]; + } +}); + + +Main.addProp("reversed", function() { + return this.data.reverse(); +}); + + +let main = new Main(); + +console.log(main.reversed); // [3, 2, 1] +``` + +
+ +> ## Class.addProp() +> description: adds a new property
+> calls: +> - addProp() +> - addProperty() +> - setProp() +> - setProperty() +> - newProp() +> - newProperty() +> - addP() +> - setP() +> - newP() \ No newline at end of file diff --git a/wiki/alternate-names.md b/wiki/alternate-names.md new file mode 100644 index 0000000..2facf29 --- /dev/null +++ b/wiki/alternate-names.md @@ -0,0 +1,26 @@ +```js +const cl = require('aepl'); + + +class Template { + constructor() { + this.data = [1, 2, 3]; + } +} + + +cl.from(Template); +Template.setName("Main"); + + +Main.newProp("test", function() { + return this.data.reverse(); +}); + + +let main = new Main(); + + +console.log(main); // Template { data: [1, 2, 3] } +console.log(main.test); // [3, 2, 1] +``` \ No newline at end of file diff --git a/wiki/calls.md b/wiki/calls.md new file mode 100644 index 0000000..3f2f74f --- /dev/null +++ b/wiki/calls.md @@ -0,0 +1,59 @@ +calls or refs are different names for the classes and functions mostly for simplicity and variety

+if you prefer your code being shorter but slightly less understandable there are shortened versions
+if you prefer your code being longer but easier to understand then there are full versions
+if you prefer lowercase then there are also lowercase versions

+ +all of the functions have three main calls: +- add +- set +- new + +
+ +```js +Class.addProp(name, value); + +Class.setProp(name, value); + +Class.newProp(name, value); +``` + + +
+ +--- + +
+ + +```js +// shorter +new Main.Func(); // upper +new Main.func(); // lower + +// longer +new Main.Function(); // upper +new Main.function(); // lower +``` +```js +// shorter +new Main.Prop(); // upper +new Main.prop(); // lower + +// longer +new Main.Property(); // upper +new Main.property(); // lower +``` +```js +// short +new Main.AFunc(); // upper +new Main.aFunc(); // lower + +// medium +new Main.AsyncFunc(); // upper +new Main.asyncFunc(); // lower + +// long +new Main.AsyncFunction(); // upper +new Main.asyncFunction(); // lower +``` diff --git a/wiki/compact.md b/wiki/compact.md new file mode 100644 index 0000000..3e9b897 --- /dev/null +++ b/wiki/compact.md @@ -0,0 +1,53 @@ +```js +const cl = require('aepl'); + + +// main class +let m = cl.init("Main", class { + constructor() { + this.data = [1, 2, 3]; + } +}); + + +m.newF("reverse", function() { + return this.data.reverse(); +}); + + +// layer class +let l = m.newC("Layer", class { + constructor() { + this.data = [4, 5, 6]; + } +}); + + +l.newF("reverse", function() { + return this.data.reverse(); +}); + + +l.newP("mainData", function() { + return this.parent.data; +}); + + +// creates new main instance +let main = new Main(); + + +console.log(main.data); // [1, 2, 3] + + +// creates a new layer instance +let layer = new main.Layer(); + + +console.log(layer.data); // [4, 5, 6] +console.log(layer.mainData); // [1, 2, 3] + + +console.log(main.reverse()); // [3, 2, 1] +console.log(layer.reverse()); // [6, 5, 4] +``` \ No newline at end of file diff --git a/wiki/event-handler.md b/wiki/event-handler.md new file mode 100644 index 0000000..9351b51 --- /dev/null +++ b/wiki/event-handler.md @@ -0,0 +1,66 @@ +NOTE: this example uses [stews](https://github.com/paigeroid/stews) + +
+ + +```js +const Class = require('aepl'); +const { Soup } = require('stews'); + + + +// creates the main class +new Class("Main", class { + constructor() { + this.events = new Soup(Object); + } + + on(name, func) { + this.events.get(name).listen(func); + return func; + } + + off(name, func) { + this.events.get(name).listeners.remove(func); + } +}); + + + +// creates the event subclass +Main.new("subclass", "Event", class { + constructor(name) { + this.name = name; + this.listeners = new Soup(); + this.parent.events.push(name, this); + } + + listen(func) { + this.listeners.push(func); + } + + fire() { + this.listeners.forEach( (f) => { + f(...Array.from(arguments)); + }); + } +}); + + + +// example +let main = new Main(); +let event = new main.Event("test"); + + +let f = main.on("test", function(a, b) { + console.log(a, b); +}); + + +event.fire("a", "b"); // a b + +main.off("test", f); // removes the listener + +event.fire("a", "b"); // doesn't log anything +``` \ No newline at end of file diff --git a/wiki/from().md b/wiki/from().md new file mode 100644 index 0000000..62aa4c3 --- /dev/null +++ b/wiki/from().md @@ -0,0 +1,71 @@ +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" +```js +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() + +
+ +```js +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] +``` diff --git a/wiki/init().md b/wiki/init().md new file mode 100644 index 0000000..5998ab5 --- /dev/null +++ b/wiki/init().md @@ -0,0 +1,20 @@ +init() is an alternative to new Class() +```js +const Class = require('aepl'); + +Class.init("Main", class { + constructor() { + this.data = [1, 2, 3]; + } +}); + + +Main.new("func", "reverse", function() { + return this.data.reverse(); +}); + + +let main = new Main(); + +console.log(main.reverse()); // [3, 2, 1] +``` diff --git a/wiki/multiple-layers.md b/wiki/multiple-layers.md new file mode 100644 index 0000000..10bfe0e --- /dev/null +++ b/wiki/multiple-layers.md @@ -0,0 +1,93 @@ +```js +const Class = require('aepl'); + + +// main class +new Class("Main", class { + constructor() { + this.data = [1, 2, 3]; + this.layers = []; + } +}); + + + +// subclasses +Main.new("subclass", "Layer", class { + constructor() { + this.extras = []; + this.data = [4, 5, 6]; + this.parent.layers.push(this); + } +}); + + +Layer.new("subclass", "Extra", class { + constructor() { + this.data = [7, 8, 9] + this.parent.extras.push(this); + } +}); + + + +// functions +Main.new("func", "reverse", function() { + return this.data.reverse(); +}); + + +Layer.new("func", "reverse", function() { + return this.data.reverse(); +}); + + +Extra.new("func", "reverse", function() { + return this.data.reverse(); +}); + + + +// properties +Layer.new("prop", "main", function() { + return this.parent; +}); + + +Extra.new("prop", "layer", function() { + return this.parent; +}); + + +Extra.new("prop", "main", function() { + return this.parent.parent; +}); + + + +// examples +let main = new Main(); + + +console.log(main); // Main { layers: [], data: [1, 2, 3] } + + +let layer = new main.Layer(); + + +console.log(layer); // Layer { extras: [], data: [4, 5, 6] } +console.log(layer.main); // Main { layers: [ [Layer] ], data: [1, 2, 3] } + + +let extra = new layer.Extra(); + + +console.log(extra); // Extra { data: [7, 8, 9] } +console.log(extra.layer); // Layer { extras: [ [Extra] ], data: [4, 5, 6] } +console.log(extra.main); // Main { layers: [ [Layer] ], data: [1, 2, 3] } + + +console.log(main.reverse()); // [3, 2, 1] +console.log(layer.reverse()); // [6, 5, 4] +console.log(extra.reverse()); // [9, 8, 7] +``` \ No newline at end of file diff --git a/wiki/new().md b/wiki/new().md new file mode 100644 index 0000000..70c77ad --- /dev/null +++ b/wiki/new().md @@ -0,0 +1,29 @@ +new() and addNew() can be used to add different things more easily +```js +const Class = require('aepl'); +const { Soup } = require('stews'); + +new Class("Main", class { + this.data = new Soup([1, 2, 3]); +}); + +Main.new("prop", "reversed", function() { + return this.data.reverse(); +}); + +Main.addNew("func", "shuffle", function() { + return this.data.shuffle(); +}); + +let main = new Main(); + +console.log(main.reversed); // [3, 2, 1] +``` + +
+ +> ## Class.new() +> description: adds a new thing
+> calls: +> - new() +> - addNew() diff --git a/wiki/parent.md b/wiki/parent.md new file mode 100644 index 0000000..1e8dc4d --- /dev/null +++ b/wiki/parent.md @@ -0,0 +1,36 @@ +parent is used in subclasses to get elements from the original class + +```js +const Class = require('aepl'); + + +// creates a new class called A +new Class("A", class { + constructor() { + this.data = [1, 2, 3]; + } +}); + + +// creates a subclass called B +new A.Class("B", class { + constructor() { + let data = this.parent.data; // gets the data from class A + + let last = data[data.length]; // gets the last number from the data + + data.push(last+1); // adds 4 to the data + } +}); + + +// creates a new instance of class A +let a = new A(); + +console.log(a.data); // [1, 2, 3] + +// creates a new instanceof class B adding 4 to the data +let b = new a.B(); + +console.log(a.data); // [1, 2, 3, 4] +``` \ No newline at end of file diff --git a/wiki/setName().md b/wiki/setName().md new file mode 100644 index 0000000..85bc5c5 --- /dev/null +++ b/wiki/setName().md @@ -0,0 +1,40 @@ +the setName function is used to create an alternate name for a class +```js +const Class = require('aepl'); + + +// creates a new class named A +Class.new("A", class { + constructor() { + this.data = [1, 2, 3]; + } +}); + + +// creates a new prop called test +A.newProp("test", function() { + return this.data.reverse(); +}); + + +// sets name to B +A.setName("B"); + + +let b = new B(); + +console.log(b); // A { data: [1, 2, 3] } +console.log(b.test); // [3, 2, 1] +``` + +

+ +> ## Class.setName() +> description: sets the name of a class
+> parameters: +> - name `String`: name to set to +> - ?autodefine `Boolean`: if it should automatically define as the new name +> +> refs: +> - setName() +> - setN() \ No newline at end of file