_getEmail() {
const emails = [];
return new Promise((resolve, reject) => {
this.start();
this.db.query('SELECT * FROM contacts', (err, res) => {
if (!!err) {
return reject('Error in the Query');
} else {
res.forEach(function (item, i) {
if ((item.email !== '') && (item.email !== null)) {
emails.push(item.email);
}
});
this.end();
return resolve(emails);
}
});
});
}
async getEmail(){
try {
const emails = await this._getEmail();
} catch (error) {
console.log(error);
};
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<textarea id="area" cols="100" rows="50"></textarea>
<script>
var doc = {
"_id": "5b1055bab772d4a8c93dc0cf",
"name": "sendPhotoRemovePush",
"titleEn": "Photo deleted (No face)",
"titleRu": "Фото удалено (Без лица)",
"bodyEn": "Upload your photo with a face. Your profile will be deleted with in 24 hours",
"bodyRu": "Загрузите своё фото с лицом. Ваш профиль будет удалён в течении 24 часа",
"sound": "obyjvlenie.mp3",
"createdAt": "2018-05-31T21:02:39.547Z",
"updatedAt": "2018-06-01T07:09:29.791Z"
}
area.value = JSON.stringify(doc, null, 4);
</script>
</body>
</html>
const search = document.querySelector('#search');
const allLinks = document.querySelectorAll('#container>p>a');
search.onkeyup = function (event) {
const regex = new RegExp(event.target.value.toLowerCase());
allLinks.forEach(element => {
if (regex.test(element.textContent.toLowerCase())) {
element.style.display = '';
} else {
element.style.display = 'none';
}
})
}
const collections = []
for (let i = 0; i < data.length; i++) {
if (!collections.includes(data[i].collection)) {
collections.push(data[i].collection);
}
}
const collections = Array.from(new Set(data.map(d => d.collection)));
const collections = Object.keys(data.reduce((res, next) => {
res[next.collection] = null;
return res;
}, {}));
const collections = data.reduce((res, next) => {
if (!res.includes(next.collection)) {
res.push(next.collection);
}
return res;
}, {});
var output = '565^23'.split('');
for (var i = 0, l = output.length; i < l; i++) {
if (output[i] == '^' && i > 0 && i < l - 1) {
output[i] = 'Math.pow(' + output[i - 1] + ',' + output[i + 1] + ')';
output[i - 1] = '';
if (i >= l - 2 || output[i + 2] !== '^') {
output[i + 1] = '';
}
i++;
}
}
alert(output.join(''));
async (req, res) => {
try {
const categories = await categoryModel.find({});
const products = await productModel.find({});
const seasons = await seasonModel.find({});
const sizes = await sizeModel.find({});
return res.render("admin", { categories, products, seasons, sizes });
} catch (error) {
console.log(error);
return res.render('error');
};
}
async (req, res) => {
try {
const [categories, products, seasons, sizes] = await Promise.all([
categoryModel.find({}),
productModel.find({}),
seasonModel.find({}),
sizeModel.find({})
])
return res.render("admin", { categories, products, seasons, sizes });
} catch (error) {
console.log(error);
return res.render('error');
};
}
function createWrappedSlides(slides, count = 3) {
const wrappedSlides = [];
for (let i = 0; i < slides.length; i += count) {
wrappedSlides.push(slides.slice(i, i + count));
}
return wrappedSlides;
}
createWrappedSlides(slides).map((slide, i) => <Slide key={i} data={slide} />)
this.model = new Model()
class Model {
private _initialValues = {
name: 'name',
surname: 'surname'
}
constructor() { }
reset() {
Object.keys(this._initialValues).forEach(key => {
this[key] = this._initialValues[key];
})
}
}
class Model {
constructor() {
this.name = 'test'
}
reset() {
const newInstance = new Test();
Object.keys(newInstance).forEach(key => {
this[key] = newInstance[key];
})
}
}
function palindromeChecker(str) {
str = str.toLowerCase().replace(/[^а-яa-z1-9]/gi, '');
const lastIndex = str.length - 1;
for (let i = 0; i < str.length / 2; i++) {
if (str[i] !== str[lastIndex - i]) {
return false;
}
}
return true;
}
function palindromeChecker2(str) {
str = str.toLowerCase().replace(/[^а-яa-z1-9]/gi, '');
const halfOfLength = Math.floor(str.length / 2);
return str.substr(0, Math.floor(halfOfLength)) === str.substr(Math.floor(str.length % 2 ? halfOfLength + 1 : halfOfLength)).split('').reverse().join('')
}
window.frames[0].addEventListener('message', receiveMessage, false);
function receiveMessage(event) {
console.log(event.data);
}
window.postMessage('Hello World', 'Your domain');
const myObject = { name: 'name', surname: 'surname' };
Object.keys(myObject).forEach(key => {
console.log(myObject[key])
})
const list = [{ test: "a", test2: "aa" }, { test: "b", test2: "bb" }]
const res = list.map(l => l.test)