Skip to content

Instantly share code, notes, and snippets.

View Willwf's full-sized avatar
📌
Focusing

William Firmino Willwf

📌
Focusing
View GitHub Profile

How to use async/await without try/catch block

We can use something like this:

async function resolveToNumber () {
  const promise = Promise.resolve(1)
  const [error, result] = await to(promise)
  console.log(error, result) // [null, 1] -> Here we have the result, and error will be null
}
@Willwf
Willwf / gist:01c16076db2637131006a015d2838bb2
Last active October 20, 2023 18:31
Why use an index.js file for easy imports?

Using an index.js file in each component or feature folder serves as a convenient way to organize and simplify imports within your project. Here's why it's commonly used:

  1. Cleaner Imports: When you have an index.js file in a folder, you can use that file to re-export the main components, functions, or objects from that folder. This allows you to import them using a cleaner syntax without needing to specify the full path to the individual files.

  2. Abstraction of Implementation Details: The index.js file abstracts the internal implementation details of a component or feature. Other parts of the application don't need to know the specific file names or structure within the folder; they only need to import from the folder's root.

  3. Easier Refactoring: If you decide to reorganize your files or rename them, you only need to update the index.js file's export statements. This prevents you from having to update import paths across your entire codebase.

  4. Reduces Cognitive Load: By havi

@Willwf
Willwf / 🎵 My Spotify Top Tracks
Last active August 31, 2025 01:21
🎵 My Spotify Top Tracks - Updated Daily - https://github.com/Willwf/spotify-box
City Ruins - Rays of Li 岡部啓一
City Ruins - Shade 岡部啓一
CUPID'S GIRL MARINA
Significance - Marina K 岡部啓一
Significance - Nothing 岡部啓一
HELLO KITTY MARINA
Peaceful Sleep 岡部啓一
Deixaria Tudo (Dejaria Leonardo
FINAL BOSS MARINA
Detalhes - Versão Remas Roberto Carlos