Update formatting

This commit is contained in:
Isabelle Viktoria Maciohsek
2022-01-30 12:03:26 +02:00
parent 6f11554999
commit 8b3ee1c65b
4 changed files with 5 additions and 5 deletions

View File

@ -7,9 +7,9 @@ lastUpdated: 2020-10-22T20:24:30+03:00
Runs a function in a separate thread by using a [Web Worker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers), allowing long running functions to not block the UI.
- Create a `new Worker()` using a `Blob` object URL, the contents of which should be the stringified version of the supplied function.
- Create a `Worker` using a `Blob` object URL, the contents of which should be the stringified version of the supplied function.
- Immediately post the return value of calling the function back.
- Return a `new Promise()`, listening for `onmessage` and `onerror` events and resolving the data posted back from the worker, or throwing an error.
- Return a `Promise`, listening for `onmessage` and `onerror` events and resolving the data posted back from the worker, or throwing an error.
```js
const runAsync = fn => {

View File

@ -7,7 +7,7 @@ lastUpdated: 2020-10-22T20:24:30+03:00
Delays the execution of an asynchronous function.
- Delay executing part of an `async` function, by putting it to sleep, returning a `new Promise()`.
- Delay executing part of an `async` function, by putting it to sleep, returning a `Promise`.
```js
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));

View File

@ -6,7 +6,7 @@ firstSeen: 2021-08-15T05:00:00-04:00
Returns the zero-indexed week of the year that a date corresponds to.
- Use `new Date()` and `Date.prototype.getFullYear()` to get the first day of the year as a `Date` object.
- Use the `Date` constructor and `Date.prototype.getFullYear()` to get the first day of the year as a `Date` object.
- Use `Date.prototype.setDate()`, `Date.prototype.getDate()` and `Date.prototype.getDay()` along with the modulo (`%`) operator to get the first Monday of the year.
- Subtract the first Monday of the year from the given `date` and divide with the number of milliseconds in a week.
- Use `Math.round()` to get the zero-indexed week of the year corresponding to the given `date`.

View File

@ -7,7 +7,7 @@ lastUpdated: 2020-10-22T20:24:44+03:00
Results in a string representation of yesterday's date.
- Use `new Date()` to get the current date.
- Use the `Date` constructor to get the current date.
- Decrement it by one using `Date.prototype.getDate()` and set the value to the result using `Date.prototype.setDate()`.
- Use `Date.prototype.toISOString()` to return a string in `yyyy-mm-dd` format.