Skip to content

Instantly share code, notes, and snippets.

View gfausagullo's full-sized avatar

Gonzalo Faus Agulló gfausagullo

View GitHub Profile
// Basic --key value flag parsing
const args = new Map(
process.argv
.slice(2)
.map((a, i, arr) =>
a.startsWith("--")
? [
a.replace(/^--/, ""),
arr[i + 1] && !arr[i + 1].startsWith("--") ? arr[i + 1] : "",
]