Skip to content

Instantly share code, notes, and snippets.

@ilopX
Created November 20, 2019 13:07
Show Gist options
  • Save ilopX/1df268416b1feabdf9972d50d7273907 to your computer and use it in GitHub Desktop.
Save ilopX/1df268416b1feabdf9972d50d7273907 to your computer and use it in GitHub Desktop.
let result;
timeSplit(15,
() => result = 1, // (1) r == 1 через 15 с
() => result += 3, // (2) r == 4 через 30 с
() => result += 13, // (3) r == 17 через 45 с
() => result += 34, // (4) r == 51 через 60
() => result += 2); // (5) r == 53 через 75 с
testing.tick(1000);
assert(result).toBe(undefined);
testing.tick(14000);
assert(result).toBe(1); // прошло 15 с
testing.tick(15000);
assert(result).toBe(4); // прошло 30 с
testing.tick(1000);
assert(result).toBe(4); // прошло 31 с, (3) еще не вызвана
testing.tick(14000);
assert(result).toBe(17);
testing.tick(15000);
assert(result).toBe(51);
testing.tick(15000);
assert(result).toBe(53);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment