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
/** | |
* @param {number} num - it's a number in radix 10 that indicates summation of power of 2 numbers | |
* @returns an array containing power of 2 numbers that sum of all is equal to num | |
*/ | |
export const deconstructPowersOfTwo = (num: number) => { | |
let decimalArray = []; | |
const binaryNumberString = num.toString(2); | |
const reversedBinaryNumber = reverseString(binaryNumberString); |
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
const url = require("url"); | |
const parsedUrl = url.parse( | |
process.env.CONNECTION_STRING || "mongodb://localhost:27017/reactor" | |
); | |
module.exports = { | |
db: { | |
host: parsedUrl.hostname, | |
port: parseInt(parsedUrl.port, 10), | |
name: parsedUrl.pathname.substr(1), |
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
const MongoClient = require("mongodb").MongoClient; | |
const config = require("./config"); | |
module.exports = (function () { | |
let connectionInstance; | |
let db; | |
function getInstance() { | |
return new Promise(function (resolve, reject) { | |
if (connectionInstance) { |