From b25c03af5279f1837fe455099e130c2bc192773b Mon Sep 17 00:00:00 2001 From: neauoire Date: Sun, 3 Nov 2019 21:44:11 -0500 Subject: [PATCH] * --- desktop/sources/scripts/commander.js | 7 ++++--- desktop/sources/scripts/library.js | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/desktop/sources/scripts/commander.js b/desktop/sources/scripts/commander.js index e3bfd78..f3565cb 100644 --- a/desktop/sources/scripts/commander.js +++ b/desktop/sources/scripts/commander.js @@ -222,6 +222,7 @@ function Commander (ronin) { this.getCurrentFunction = () => { const word = this.getCurrentWord() let mostSimilar = '' + if (ronin.library[word]) { return word } for (const id of Object.keys(ronin.library)) { if (id.substr(0, word.length) === word) { mostSimilar = id @@ -234,10 +235,10 @@ function Commander (ronin) { const name = this.getCurrentFunction() const fn = ronin.library[name] if (!fn) { return } - const fnString = fn.toString() + const fnString = fn.toString().replace('async ', '') if (fnString.indexOf(') => {') < 0) { return } - const fnParams = fnString.split(') => {')[0].substr(1).replace(/,/g, '').trim() - return `(${name} ${fnParams})` + const fnParams = fnString.split(') => {')[0].substr(1).split(',').reduce((acc, item) => { return `${acc}${item.indexOf('=') > -1 ? '~' + item.split('=')[0].trim() : item} ` }, '').trim() + return `(${(name + ' ' + fnParams).trim()})` } // Splash diff --git a/desktop/sources/scripts/library.js b/desktop/sources/scripts/library.js index a4e004a..42369a9 100644 --- a/desktop/sources/scripts/library.js +++ b/desktop/sources/scripts/library.js @@ -470,7 +470,7 @@ function Library (ronin) { // Objects this.get = (item, key) => { // Gets an object's parameter with name. - return item[key] + return item && key ? item[key] : null } this.set = (item, ...args) => { // Sets an object's parameter with name as value.