This file contains hidden or 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
// Node.js backpressure demo | |
// Run: node demo.js | |
const readline = require('readline'); | |
const { Writable } = require('stream'); | |
// Tweak these to make the effect more or less visible | |
const TOTAL = 60; // total chunks to produce | |
const DELAY_MS = 300; // consumer processing time per chunk (slower = more backpressure) | |
const HWM = 12; // writable highWaterMark (buffer size in objectMode) |
This file contains hidden or 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
void main() { | |
final dt = DateTime.now().toLocal(); | |
final deviceTimezoneOffset = dt.timeZoneOffset; | |
final offsetHours = deviceTimezoneOffset.inHours.abs().toString().padLeft(2, '0'); | |
final offsetMinutes = deviceTimezoneOffset.inMinutes.remainder(60).abs().toString().padLeft(2, '0'); | |
final offsetSign = (deviceTimezoneOffset.isNegative) ? '-' : '+'; | |
final offsetString = '$offsetSign$offsetHours:$offsetMinutes'; | |