Skip to content

Instantly share code, notes, and snippets.

View sirkostya009's full-sized avatar

Constantine sirkostya009

  • Ukraine
View GitHub Profile
@sirkostya009
sirkostya009 / esm-to-cjs.sh
Created May 8, 2025 12:01
ESM to CJS bash script
#!/bin/bash
mkdir -p cjs
for file in esm/*.js; do
out="cjs/$(basename "${file%.js}.js")"
ids=()
content=$(sed -E '
s/^import[[:space:]]+\{([^}]+)\}[[:space:]]+from[[:space:]]+["'\'']([^"'\'']+)["'\''];?/const {\1} = require("\2");/;
@sirkostya009
sirkostya009 / logger.ts
Last active April 21, 2025 10:41
Structured, non-blocking logger for Node.js and Vite. Uses Vite for pretty-printing logs in dev mode, and serializing them as JSON in prod. slog and sdebug functions don't print anything in prod. Follows a similar naming pattern as console, prepended with s (for structural). Vite dependency may be dropped by replacing all `import.meta.env.DEV` w…
import { inspect, type InspectOptions } from 'node:util';
const inspectOptions: InspectOptions = {
colors: true,
depth: Infinity,
compact: true,
// numericSeparator: true,
// showHidden: true,
getters: true,
};