async function saveData(data) {
for(let id of Object.keys(data)) {
await appendFile(fileName, id);
await appendFile(fileName, data[id]);
}
}
saveData({cat:1,dog:2})
let data = {cat:1,dog:2};
Object.keys(data).reduce(
(p, id) => p
.then(() => appendFile(fileName, id))
.then(() => appendFile(fileName, data[id])),
Promise.resolve()
);
$('#marka option').each(function () {
var $this = $(this);
if (location.href.indexOf($this.val()) === -1) {
// не содержит
} else {
$this.prop('selected', true);
}
});
Array.prototype.forEach.call(document.getElementById('marka').options, function(opt) {
if (location.href.indexOf(opt.value) === -1) {
// не содержит
} else {
opt.selected = true;
}
});
pasteControlItem: function () {
let item = document.querySelectorAll('.todo__item');
for (let i = 0; i < item.length; i++) {
let control = document.createElement('i');
control.setAttribute('aria-hidden', 'true');
control.classList.add('fa');
control.classList.add('fa-circle-thin');
item[i].insertBefore(control, item[i].childNodes[0]);
}
}
pasteControlItem: function () {
let item = document.querySelectorAll('.todo__item');
for (let i = 0; i < item.length; i++) {
item.insertAdjacentHTML('afterBegin', '<i aria-hidden="true" class="fa fa-circle-thin"></i>');
}
}
const tty = require('tty');
if(tty.isatty(0)) {
process.stdin = new tty.ReadStream();
} else {
//init process.stdin from other stream
}
var outStream;
if(tty.isatty(1)) {
outStream = new tty.WriteStream();
process.stdout = outStream;
} else {
//init process.stdout from other stream
}
if(tty.isatty(2)) {
if(!outStream) {
outStream = new tty.WriteStream();
}
process.stderr = outStream;
} else {
//init process.stderr from other stream
}