This shows the execution order given JavaScript's Call Stack, Event Loop, and any asynchronous APIs provided in the JS execution environment (in this example; Web APIs in a Browser environment)
Given the code
| { | |
| "public_identifier": "lednhatkhanh", | |
| "profile_pic_url": "https://s3.us-west-000.backblazeb2.com/proxycurl/person/lednhatkhanh/profile?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=0004d7f56a0400b0000000001%2F20240506%2Fus-west-000%2Fs3%2Faws4_request&X-Amz-Date=20240506T020208Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=e5d730e286c7451bbdf9c7921d60c28926509eb34a0ad6149efffe94937fc75e", | |
| "background_cover_image_url": null, | |
| "first_name": "Khanh", | |
| "last_name": "Le Dinh Nhat", | |
| "full_name": "Khanh Le Dinh Nhat", | |
| "follower_count": null, | |
| "occupation": "Senior Fullstack Developer at ONE Tech Stop", | |
| "headline": "Senior Fullstack Developer at ONE Tech Stop", |
| export const ws = webSocket<WebsocketMessage>(`wss://${location.hostname}:${location.protocol === 'https:' ? 443 : 80}/ws/`); | |
| export const wsObserver = ws | |
| .pipe( | |
| retryWhen(errors => | |
| errors.pipe( | |
| delay(1000) | |
| ) | |
| ) | |
| ); |
| export const uniqBy = <T>(arr: T[], key: keyof T): T[] => { | |
| return Object.values( | |
| arr.reduce( | |
| (map, item) => ({ | |
| ...map, | |
| [`${item[key]}`]: item, | |
| }), | |
| {}, | |
| ), | |
| ); |
| export function asyncLimit<T extends (...args: any) => Promise<any>>(fn: T, n: number): T { | |
| let pendingPromises = [] as Promise<ReturnType<T>>[]; | |
| return async function limitedFunction(this: ThisType<T>, ...args: Parameters<T>) { | |
| while (pendingPromises.length >= n) { | |
| await Promise.race(pendingPromises); | |
| } | |
| const p = fn.apply<ThisType<T>, Parameters<T>, Promise<ReturnType<T>>>(this, args); |
| function listToTree(list) { | |
| const copiedList = [...list]; | |
| const mapObj = {}; | |
| const result = []; | |
| for (let i = 0; i < copiedList.length; i += 1) { | |
| mapObj[copiedList[i].uuid] = i; | |
| copiedList[i].children = []; | |
| } |
| <?php | |
| use Illuminate\Support\Facades\DB; | |
| use Illuminate\Support\Facades\Schema; | |
| use Illuminate\Database\Schema\Blueprint; | |
| use Illuminate\Database\Migrations\Migration; | |
| class AddFeedbacksTableDeleteTrigger extends Migration | |
| { | |
| /** | |
| * Run the migrations. | |
| * |
| # JPF site configuration | |
| jpf-core = ${user.home}/projects/jpf/jpf-core | |
| extensions=${jpf-core} |