Created
March 10, 2022 07:01
-
-
Save DevLucem/95e846c16227880859769ce94d9ea728 to your computer and use it in GitHub Desktop.
TradingView To Anywhere Platform Creation Format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Platform { | |
// receive and validate the data | |
constructor(data) { | |
this.command = {valid: true}; | |
if (typeof data === 'string') this.command.data = data | |
else if (typeof data === 'object') { | |
} else this.command.valid = false; | |
} | |
// execute the activation automation process | |
process(activations = [{}]){ | |
return new Promise( (resolve, reject) => { | |
if (!this.command.valid) return reject(); | |
let results = {}; activations.forEach( activation => { | |
doAutomationAction().then( res => results[activation.id] = res) | |
.catch(error => results[activation.id] = error) | |
.finally(()=> {if (Object.keys(results).length>=activations.length) resolve(results)}) | |
}) | |
}) | |
} | |
} | |
module.exports = Telegram |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment