Code Explainers

Code explainers tagged #buffering

go
package logbuffer
 
import (
	"bufio"

A buffered logger with background flushing in Go

concurrency buffering context
Intermediate 8 steps
javascript
const MAX_BATCH_SIZE = 20;
const FLUSH_INTERVAL = 5000;
const ENDPOINT = '/api/analytics';
 

Batching analytics events in the browser

batching buffering sendbeacon
Intermediate 10 steps
php
final class DebouncedSessionStore
{
    private array $pending = [];
    private array $timers = [];

Debouncing session writes with an event loop

debounce event-loop atomic-write
Advanced 9 steps
rust
use std::fs::{File, OpenOptions};
use std::io::{self, Write};
use std::path::Path;
 

A buffered log writer in Rust

buffering raii file-io
Intermediate 9 steps
rust
use std::collections::HashSet;
use std::io::{self, BufRead, BufWriter, Write};
 
fn main() -> io::Result<()> {

Filtering duplicate lines in Rust

stdin hashset buffering
Beginner 5 steps
typescript
type Event = Record<string, unknown>;
 
interface BatcherOptions {
  endpoint: string;

Batching analytics events in TypeScript

batching buffering async
Intermediate 8 steps