Skip to content

Instantly share code, notes, and snippets.

View midnqp's full-sized avatar
:octocat:
Make very sure to have fun opensourcing!

Muhammad Bin Zafar midnqp

:octocat:
Make very sure to have fun opensourcing!
View GitHub Profile
@danpetitt
danpetitt / esmodules.md
Last active September 26, 2024 19:49
Typescript, Jest and ECMAScript Modules

Typescript, Jest and ECMAScript Modules (ESM)

Package.json

Add the type property to package.json to ensure modules are supported:

{
  "type": "module",
}
@sindresorhus
sindresorhus / esm-package.md
Last active September 28, 2024 20:11
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
The goal of Node was event driven HTTP servers.
5:04 https://youtu.be/M3BM9TB-8yA?t=304
1 Regret: Not sticking with Promises.
* I added promises to Node in June 2009 but foolishly removed them in February 2010.
* Promises are the necessary abstraction for async/await.
* It's possible unified usage of promises in Node would have sped the delivery of the eventual standartization and async/await.
* Today Node's many async APIs are aging baldly due to this.
6:02 https://youtu.be/M3BM9TB-8yA?t=362
@jirihnidek
jirihnidek / getaddrinfo_example.c
Last active August 31, 2024 19:54
Example of getaddrinfo() program.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
int
lookup_host (const char *host)