Implement while

This commit is contained in:
Bladymir Tellez 2020-08-23 11:53:07 -05:00
parent 82cfdf567e
commit 7e6970b9e4
2 changed files with 11 additions and 0 deletions

View File

@ -1214,6 +1214,11 @@ function Library (client) {
this.not = (a) => {
return !a
}
this.while = (fn, action) => {
while (fn()) {
action()
}
}
this.each = (arr, fn) => { // Run a function for each element in a list.
for (let i = 0; i < arr.length; i++) {
const arg = arr[i]

View File

@ -421,6 +421,12 @@ function Library (client) {
// Arrays
this.while = (fn, action) => {
while (fn()) {
action()
}
}
this.each = (arr, fn) => { // Run a function for each element in a list.
for (let i = 0; i < arr.length; i++) {
const arg = arr[i]