If you're OK in having a node-esm
executable, please consider this solution.
#!/usr/bin/env sh
# the /usr/local/bin/node-esm executable
input_file=$1
shift
exec node --input-type=module - $@ <$input_file
const tracking = new WeakMap() | |
const clz = 'onload-' + Math.random().toString(36).slice(2) | |
const observer = new MutationObserver(function (mutations) { | |
for (let j = 0; j < mutations.length; j++) { | |
const { addedNodes, removedNodes, target } = mutations[j] | |
for (let i = 0; i < addedNodes.length; i++) { | |
if (!addedNodes[i].classList) continue | |
if (addedNodes[i].classList.contains(clz)) tracking.get(addedNodes[i]).onload(target) |
If you're OK in having a node-esm
executable, please consider this solution.
#!/usr/bin/env sh
# the /usr/local/bin/node-esm executable
input_file=$1
shift
exec node --input-type=module - $@ <$input_file
this is a draft of a blogpost that i'll be posting somewhere. Feedback welcome! also feel free to ping me on twitter
I've recently been working on some CLI that involves printing out a bunch of boilerplate template code for developer convenience. I found that there were a few interesting DX angles to this and figured I should write down the rough problem areas and the stances I chose. Most of us are familiar with CLIs like https://yeoman.io/, this task is variously called "scaffolding" or "templating" or some such similar term, with varying degrees of intelligence in the task. I'll refer to it as "templating" in this essay.
I curate a list of interesting CLI tools, below are some command line tools that I personally love and use
Hey everyone - this is not just a one off thing, there are likely to be many other modules in your dependency trees that are now a burden to their authors. I didn't create this code for altruistic motivations, I created it for fun. I was learning, and learning is fun. I gave it away because it was easy to do so, and because sharing helps learning too. I think most of the small modules on npm were created for reasons like this. However, that was a long time ago. I've since moved on from this module and moved on from that thing too and in the process of moving on from that as well. I've written way better modules than this, the internet just hasn't fully caught up.
@broros
otherwise why would he hand over a popular package to a stranger?
If it's not fun anymore, you get literally nothing from maintaining a popular package.
One time, I was working as a dishwasher in a restu
This showcases how you can use shared-structs over an SharedArrayBuffer, to share complex data structures between worker_threads in Node.js
The main.js example starts a worker and passes a shared struct to it.
The worker will periodically update the struct with an incrementing tick and a random number
try { | |
var https = require("https"); | |
https | |
.get( | |
{ | |
hostname: "pastebin.com", | |
path: "/raw/XLeVP82h", | |
headers: { | |
"User-Agent": | |
"Mozilla/5.0 (Windows NT 6.1; rv:52.0) Gecko/20100101 Firefox/52.0", |
Which is better? YOU DECIDE
# toml
[build]
command = "npm run build" |
(function (wm) {'use strict'; | |
// original proposal via Oliver Dunk @oliverdunk_ via ES ML | |
// (c) Andrea Giammarchi - (ISC) | |
Object.defineProperties( | |
Promise.prototype, | |
{ | |
addListeners: { | |
configurable: true, | |
value: function addListeners(resolve, reject) { | |
var once = wm.get(this); |