function func<T>(...args: any[], cb: (err: any, result: T) => void): any;
// или
function func<T1, T2>(...args: any[], cb: (err: any, res1: T1, res2: T2) => void): any;
наfunction func<T>(...args: any[]): Promise<T>;
// или
function func<T1, T2>(...args: any[]): Promise<{res1: T1; res2: T2}>;
function exec(command: string, options?: ExecOptions, cb: (err: Error, stdout: string | Buffer, stderr: string | Buffer) => void): ChildProcess;
что приходит к сигнатуре:function exec(command: string, options?: ExecOptions): Promise<{stdout: string | Buffer; stderr: string | Buffer}>;
function spawn(command: string, args: string[], options: SpawnOptions): ChildProcess;
Просто некуда подставить колбэк, который будет отслеживать промис obj.field++;
obj.field += 5;
const variable = obj.field = 10;
const human = {
name: 'Andrew'
};
Мы уже в коде много где использовали это поле как поле, и вдруг понадобилось делать что-то, когда это поле меняется, что проще, сделать сеттер или поменять весь остальной код? addItem = text => {
return axios.post("/task", {
headers: { "Content-Type": "application/json" },
text: text
})
.then(res => {
this.arr.push(res.data.task);
})
.catch(e => console.log(e));
};
describe("STORE", () => {
it("create new task", () => {
const store = new Store();
const text = "test";
expect(store.addItem(text)).resolves.toBe(1);
});
});
const el = this.forms.find((f, idx) => idx === x);
Скажите мне, зачем? Зачем нужно гонять ЦИКЛ ради того что бы достать элемент массива по индексу?const el = this.forms[x];
даст абсолютно аналогичный результат, но не сожрет кучу тактов моего процессора...var m_top = $('.go').offset().top;
запомнит оффсет только для самого первого элемента найденного по селектору, поэтому и обрабатывается только он.$(document).ready(function(){
var observer = new IntersectionObserver(function(entries){
entries.forEach(function(entry){
if(entry.isIntersecting) {
$(entry.target).addClass('active bounceInLeft');
} else {
$(entry.target).removeClass('active bounceInLeft');
}
});
}, {threshold: 0.1});
$('.go').each(function(){
observer.observe(this);
});
});
как восстановить виндуПочитайте: