This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
do { | |
// 1. Call the method | |
let images = try await fetchImages() | |
// 2. Fetch images method returns | |
// 3. Call the resize method | |
let resizedImages = try await resizeImages(images) | |
// 4. Resize method returns | |
print("Fetched \(images.count) images.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Call the method | |
fetchImages { result in | |
// 3. The asynchronous method returns | |
switch result { | |
case .success(let images): | |
print("Fetched \(images.count) images.") | |
// 4. Call the resize method | |
resizeImages(images) { result in | |
// 6. Resize method returns |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DatabaseManager { | |
static let databaseObj = DatabaseManager() | |
private init() { | |
} | |
func checkDatabaseAccess(user: String) { | |
if user == ("Sung-Jie") { | |
print("Access Granted!") | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
┌───────────────────────────┐ | |
┌─>│ timers │ | |
│ └─────────────┬─────────────┘ | |
│ ┌─────────────┴─────────────┐ | |
│ │ pending callbacks │ | |
│ └─────────────┬─────────────┘ | |
│ ┌─────────────┴─────────────┐ | |
│ │ idle, prepare │ | |
│ └─────────────┬─────────────┘ ┌───────────────┐ | |
│ ┌─────────────┴─────────────┐ │ incoming: │ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const firstFunction = () => { | |
console.log("Hello from the first function"); | |
}; | |
const secondFunction = () => { | |
setTimeout(() => { | |
console.log("Hello from the second function"); | |
}, 1000); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const firstFunction = () => { | |
console.log("Hello from the first function"); | |
}; | |
const secondFunction = () => { | |
console.log("Hello from the second function"); | |
}; | |
firstFunction(); | |
secondFunction(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | |
exports[`toUpperCase 1`] = `"FOOBAR"`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const toUpperCase = (str: string) => str.toUpperCase(); | |
if (import.meta.vitest) { | |
const { it, expect } = import.meta.vitest; | |
it("toUpperCase", () => { | |
const result = toUpperCase("foobar"); | |
expect(result).toMatchSnapshot(); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
. | |
└── vitest-demo/ | |
└── coverage/ | |
└── index.ts.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { defineConfig } from "vitest/config"; | |
export default defineConfig({ | |
test: { | |
includeSource: ["src/**/*.{js,ts}"], | |
coverage: { | |
reporter: ["text", "html"], | |
}, | |
}, | |
}); |
NewerOlder