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
| import * as functions from 'firebase-functions'; | |
| import * as admin from "firebase-admin"; | |
| import * as puppeteer from "puppeteer"; | |
| admin.initializeApp() | |
| export const takeGoogleScreenshot = functions | |
| .runWith({ memory: "1GB" }) | |
| .https.onRequest(async (request, response) => { | |
| const browser = await puppeteer.launch({ |
| /* | |
| fetch is awesome, there's no question about it. | |
| But aren't you tired of: | |
| - Writing your `res => res.json()` handler | |
| - Having to stringify your body | |
| - Signin your request with the same headers (```{'Content-Type': json, Authorization: 'JWT ...'}```) | |
| - Inconsistently handling the response status code and not reject promise when relevant. | |
| Usage: | |
| request('http://yourawesome.api.com').then(console.log).catch(console.error); |
| # iOS | |
| app_identifier "com.myapp.app" # The bundle identifier of your app | |
| apple_id "me@gmail.com" # Your Apple email address | |
| team_id "1234ABCD" # Developer Portal Team ID | |
| # Android | |
| json_key_file "./google-play-api-secret.json" # Path to the json secret file - Follow https://github.com/fastlane/supply#setup to get one | |
| package_name "com.myapp.app" # Your Android app package |
| /* | |
| * Explore/Spy App Global variables, excluding defaults (defaults comes down a scope) | |
| * > Run me in your dev tool console via copy/pasting | |
| * > In return, I provide a list of keys, and copy in your clipboard (how sweet is that!) | |
| * | |
| * Follow my creator https://twitter.com/grabthecode | |
| */ | |
| ;(function(scope, defaults){ |
| '.source.js': | |
| 'ReactNative Component': | |
| 'prefix': 'rnc' | |
| 'body': """ | |
| 'use strict'; | |
| import React, { | |
| Text, | |
| } from 'react-native'; |
| * { | |
| font-size: 12pt; | |
| font-family: monospace; | |
| font-weight: normal; | |
| font-style: normal; | |
| text-decoration: none; | |
| color: black; | |
| cursor: default; | |
| } |
| root = exports ? this | |
| root._log = -> | |
| args = [new Date()].concat Array.prototype.slice.apply(arguments) | |
| console.log.apply console, args |
| if (moment().quarter() == 4) { | |
| var current_fiscal_year_start = moment().month('October').startOf('month'); | |
| var current_fiscal_year_end = moment().add('year', 1).month('September').endOf('month'); | |
| var last_fiscal_year_start = moment().subtract('year', 1).month('October').startOf('month'); | |
| var last_fiscal_year_end = moment().month('September').endOf('month'); | |
| } else { | |
| var current_fiscal_year_start = moment().subtract('year', 1).month('October').startOf('month'); | |
| var current_fiscal_year_end = moment().month('September').endOf('month'); | |
| var last_fiscal_year_start = moment().subtract('year', 2).month('October').startOf('month'); | |
| var last_fiscal_year_end = moment().subtract('year', 1).month('September').endOf('month'); |