diff --git a/index.html b/index.html index 5a4b8f2..7f69a68 100644 --- a/index.html +++ b/index.html @@ -1211,6 +1211,9 @@ function Library (client) { } return args[args.length - 1] } + this.not = (a) => { + return !a + } 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] @@ -1240,6 +1243,15 @@ function Library (client) { this.len = (item) => { // Returns the length of a list. return item.length } + this.cons = (arr, item) => { // Retruns a new array with the item. + return array.concat([item]) + } + this.push = (arr, item) => { // Appends the item item into the existing list. + return array.push(item) + } + this.pop = (arr) => { // Pop the last item from the list and return the item. + return arr.pop(); + } this.first = (arr) => { // Returns the first item of a list. return arr[0] } @@ -1278,6 +1290,13 @@ function Library (client) { return acc[key] }, h) } + this.object = (...entries) => { // Creates an object with provided entries. + const result = {} + for (let i = 0; i < entries.length; i += 2) { + result[entries[i]] = entries[i + 1] + } + return result + } this.keys = (item) => { // Returns a list of the object's keys return Object.keys(item) }