Last active
July 10, 2018 03:03
-
-
Save bmino/bbb4669c7c40947166c9b1fc1d05ad8a to your computer and use it in GitHub Desktop.
Node Binance Api Instantiation Test
This file contains hidden or 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
const Api1 = require('node-binance-api'); | |
const Api2 = require('node-binance-api'); | |
let singleton1 = Api1(); | |
let singleton2 = Api2(); | |
let instance1 = new Api1(); | |
let instance2= new Api1(); | |
const OPTION_NAME = 'recvWindow'; | |
// Set value of singleton | |
singleton1.setOption(OPTION_NAME, 1010); | |
singleton2.setOption(OPTION_NAME, 2020); | |
console.log('Singletons share values'); | |
console.log(singleton1.getOption(OPTION_NAME) === 2020 && singleton2.getOption(OPTION_NAME) === 2020); // true | |
console.log(); | |
// Set value of instance | |
instance1.setOption(OPTION_NAME, 3030); | |
instance2.setOption(OPTION_NAME, 4040); | |
console.log('Instances do NOT share values'); | |
console.log(instance1.getOption(OPTION_NAME) === 3030 && instance2.getOption(OPTION_NAME) === 4040); // true | |
console.log(); | |
console.log('Instances do not wreck singleton values'); | |
console.log(singleton1.getOption(OPTION_NAME) === 2020 && singleton2.getOption(OPTION_NAME) === 2020); // true | |
console.log(); | |
// Set singleton value | |
singleton1.setOption(OPTION_NAME, 6070); | |
singleton2.setOption(OPTION_NAME, 7070); | |
console.log('Singletons do not wreck instance values'); | |
console.log(instance1.getOption(OPTION_NAME) === 3030 && instance2.getOption(OPTION_NAME) === 4040); // true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment