Update index.js
This commit is contained in:
parent
99721595c0
commit
74d18a2dff
19
index.html
19
index.html
@ -1211,6 +1211,9 @@ function Library (client) {
|
|||||||
}
|
}
|
||||||
return args[args.length - 1]
|
return args[args.length - 1]
|
||||||
}
|
}
|
||||||
|
this.not = (a) => {
|
||||||
|
return !a
|
||||||
|
}
|
||||||
this.each = (arr, fn) => { // Run a function for each element in a list.
|
this.each = (arr, fn) => { // Run a function for each element in a list.
|
||||||
for (let i = 0; i < arr.length; i++) {
|
for (let i = 0; i < arr.length; i++) {
|
||||||
const arg = arr[i]
|
const arg = arr[i]
|
||||||
@ -1240,6 +1243,15 @@ function Library (client) {
|
|||||||
this.len = (item) => { // Returns the length of a list.
|
this.len = (item) => { // Returns the length of a list.
|
||||||
return item.length
|
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.
|
this.first = (arr) => { // Returns the first item of a list.
|
||||||
return arr[0]
|
return arr[0]
|
||||||
}
|
}
|
||||||
@ -1278,6 +1290,13 @@ function Library (client) {
|
|||||||
return acc[key]
|
return acc[key]
|
||||||
}, h)
|
}, 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
|
this.keys = (item) => { // Returns a list of the object's keys
|
||||||
return Object.keys(item)
|
return Object.keys(item)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user