Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5a29f88
commit dab7c07
Showing
4 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// modular library written by Conor O'Bruie | ||
|
||
export default function(cheddar){ | ||
// let modular = new cheddar.func(); | ||
// modular.scope = new Map([ | ||
|
||
return cheddar.namespace([ | ||
["of", cheddar.from(require("./modular/of"))] | ||
]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
let importInstance; | ||
export default function(cheddar){ | ||
console.log("from ModularClass.es6") | ||
console.log(cheddar); | ||
if(importInstance) return importInstance; | ||
|
||
return importInstance = class ModularSystem extends cheddar.class { | ||
init(min, max){ | ||
this.setter("min", min); | ||
this.accessor("min"); | ||
this.setter("max", max); | ||
this.accessor("max"); | ||
} | ||
|
||
// MUST be capitalized, otherwise bork | ||
Scope = new Map([ | ||
["fit", cheddar.var( | ||
new cheddar.func([ | ||
["entry", { type: cheddar.number }] | ||
], function(scope, input){ | ||
let self = input("self"), | ||
value = input("entry"), | ||
min = self.accessor("min"), | ||
max = self.accessor("max"); | ||
|
||
while(value < this.min) value += this.max; | ||
while(value >= this.max) value -= this.max; | ||
return value; | ||
}) | ||
)] | ||
]); | ||
} | ||
|
||
return ModularSystem; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import Modular from "./helpers/ModularClass"; | ||
|
||
export default function(cheddar){ | ||
return new cheddar.func( | ||
[ | ||
["min", { type: cheddar.number }], | ||
["max", { type: cheddar.number }] | ||
], | ||
function(cheddar, input){ | ||
return new (Modular(cheddar))( | ||
input("min"), | ||
input("max") | ||
); | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters