Improved setter

This commit is contained in:
Devine Lu Linvega
2019-07-22 10:19:20 +09:00
parent d88cfdbed7
commit 2ca61842b1
2 changed files with 19 additions and 16 deletions

View File

@@ -299,9 +299,13 @@ function Library (ronin) {
return item[key]
}
this.set = (item, key, val) => { // Sets an object's parameter with name as value.
item[key] = val
return item[key]
this.set = (item, ...args) => { // Sets an object's parameter with name as value.
for (let i = 0; i < args.length; i += 2) {
const key = args[i]
const val = args[i + 1]
item[key] = val
}
return item
}
this.of = (h, ...keys) => { // Gets object parameters with names.