Skip to content

Instantly share code, notes, and snippets.

View RenanLazarotto's full-sized avatar
Transformando café em código

Renan "Firehawk" Lazarotto RenanLazarotto

Transformando café em código
  • Brasil
  • 10:08 (UTC -03:00)
View GitHub Profile
@clmrb
clmrb / enum.js
Last active December 20, 2025 19:28
JavaScript enum function with working JSDoc autocompletion
/**
* @description
* Creates a frozen enumeration object where each key maps to its own string value.
* This is useful for defining a set of constant string values that can be referenced by name.
* This also avoids defining an object with duplicated string values manually.
* @template {string} T
* @param {...T} values
* @returns {{ [K in T]: K }}
* @example
* const Colors = Enum('Red', 'Green', 'Blue');