🏋️♀️
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <uv.h> | |
#include <fcntl.h> | |
#define BUFFER_SIZE 1024 | |
// Forward declaration of the on_open function | |
void on_open(uv_fs_t *req); |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <fcntl.h> | |
#include <unistd.h> | |
#define BUFFER_SIZE 1024 | |
int main(int argc, char *argv[]) | |
{ | |
int fd; |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#define BUFFER_SIZE 1024 | |
int main(int argc, char *argv[]) | |
{ | |
FILE *file; | |
char buffer[BUFFER_SIZE]; | |
size_t bytesRead; |
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 fs = require('fs'); | |
function read_file_1() { | |
try { | |
// get the number of times we should repeat the read operation | |
const repeat = process.argv[2] || 1; | |
for (let i = 0; i < repeat; i++) { | |
const data = fs.readFileSync('./hello.txt', 'utf8'); | |
console.log(data); | |
} |
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 fs = require('fs').promises; | |
async function read_file_1() { | |
try { | |
// get the number of times we should repeat the read operation | |
const repeat = process.argv[2] || 1; | |
for (let i = 0; i < repeat; i++) { | |
const data = await fs.readFile('./hello.txt', 'utf8'); | |
console.log(data); | |
} |
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 fs = require('fs'); | |
function read_file_1(repeat, count = 0) { | |
if (count >= repeat) return; | |
fs.readFile('./hello.txt', 'utf8', (err, data) => { | |
if (err) { | |
console.error(err); | |
return; | |
} |
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
let currentHook: Hook | null = null; | |
let workInProgressHook: Hook | null = null; | |
function mountWorkInProgressHook(): Hook { | |
const hook: Hook = { | |
memoizedState: null, | |
baseState: null, | |
baseQueue: null, |
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
function mountStateImpl<S>(initialState: (() => S) | S): Hook { | |
const hook = mountWorkInProgressHook(); | |
if (typeof initialState === 'function') { | |
const initialStateInitializer = initialState; | |
// $FlowFixMe[incompatible-use]: Flow doesn't like mixed types | |
initialState = initialStateInitializer(); | |
if (shouldDoubleInvokeUserFnsInHooksDEV) { | |
setIsStrictModeForDevtools(true); | |
// $FlowFixMe[incompatible-use]: Flow doesn't like mixed types | |
initialStateInitializer(); |
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
function mountState<S>( | |
initialState: (() => S) | S, | |
): [S, Dispatch<BasicStateAction<S>>] { | |
const hook = mountStateImpl(initialState); | |
const queue = hook.queue; | |
const dispatch: Dispatch<BasicStateAction<S>> = (dispatchSetState.bind( | |
null, | |
currentlyRenderingFiber, | |
queue, | |
): any); |
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
function dispatchSetState<S, A>( | |
fiber: Fiber, | |
queue: UpdateQueue<S, A>, | |
action: A, | |
): void { | |
const lane = requestUpdateLane(fiber); | |
const update: Update<S, A> = { | |
lane, | |
revertLane: NoLane, |
NewerOlder