diff --git a/index.html b/index.html index df1992a..fe16f62 100644 --- a/index.html +++ b/index.html @@ -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] diff --git a/scripts/library.js b/scripts/library.js index 168c499..5e0600b 100644 --- a/scripts/library.js +++ b/scripts/library.js @@ -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]