const company_data = () => new Promise((resolve,reject) => {
pool.query(`select * from the_company where creator_id = ?`, {creator_id}, (error,results,fields) => {
const id = results.map(r => r.id)
const name = results.map(r => r.name) //Ответ - { id: '41' } - id
console.log(`${id} - id`)
resolve(id)
})
})
var productCounter = { a: 0 }
function incrementCounter(counter) {
counter.a++
console.log(counter.a)
}
incrementCounter(productCounter)
console.log(productCounter.a)
console.log( JSON.stringify(object) )
reconnectTries: 2, // попытки реконнекта
reconnectInterval: 1000, //каждую секунду
connectTimeoutMS: 2000, // после 2 секунд ожидания соединения пытаться снова или сбрасывать
db.on('reconnected', function(){ console.log('reconnected successfully'});
db.on('reconnectFailed', function (error){
//Что делать если все попытки реконнекта провалились
});
jQuery(document).ready(function($) {
document.addEventListener('click', function(e) {
if (!e.target.classList.contains("linkinp")) return;
var element = document.querySelector(".doght-03");
if(element.classList.contains("show-block")) {
element.classList.remove("show-block");
} else {
element.classList.add("show-block");
}
});
});
const ip2int = (ip) =>
ip.split('.')
.map( (value, index) => Number(value) * 256 ** (3-index))
.reduce( (sum,value) => sum + value, 0);
const range = (from, to) => ip2int(to) - ip2int(from);
console.log(range("192.168.1.0", "192.168.1.255"));
// 255 - т.е. броадкаст адрес он тоже считает
var a = [123, 125, 555];
delete a[1];
console.log(a);
//[123, null, 555]
a.splice(1,1); // первое число это индекс, второе - количество удаляемых. Функция вернёт удаленные элементы, поэтому просто её вызываем
console.log(a);
// [123, 555]
a = a.filter( (index, value) => index != 1 );
console.log(a);
// [123, 555]
var _MR=0;
bot.addScene('sample',
({ reply, scene: { next } }) => {
next()
reply('Введите MR(целое число)');
},
({ reply, body, scene: { next } }) => {
_MR=parseInt(body);
next()
reply('Введите TR(целое число)')
},
({ reply, body, scene: { leave } }) => {
leave()
let kmr = _MR / parseInt(body)
reply(`KMR = ${kmr}`)
}
);
bot.command('Рассчитать коэффициент маржинального дохода', ({ scene: { join } }) => join("sample") );