Currently, it returns a number. Some packages expect .ref() and .unref() to always exist though
Extremely cursed alternative (which we will not do)
Make "ref" and "unref" functions on Number.prototype that masquerade as undefined. When you call call .ref() or .unref() on the result from a timer (or any number), it runs without exception. typeof id.ref would be "undefined"
Slightly less cursed alternative
class Timer extends Number {
ref() {}
unref() {}
}
Another idea, make it extend Promise but coercible to a Number. Native support for `await setTimeout`
to be clear, not going to introduce a new thing here, just going to make it compatible with either node or browsers but would love to figure out a way for it to be both
• • •
Missing some Tweet in this thread? You can try to
force a refresh
Bun v0.5.5:
- "node:http" module can send requests now (client)
- bug fixes for bun install, text encoding, and possible stack overflow in console.log(strong)
Hoisting bug in bun install me and @dylanconway111 spent much of today on.
bun install occasionally places the wrong package version in node_modules when multiple versions of the same package are installed. But the minimum case where this happens is difficult to narrow
The easiest package for us to repro this with right now is netlify-cli, but it can’t be the only one where this happens
Bun as a bundler/transpiler independent of the runtime was de-prioritized so the rest could ship, but it will be re-prioritized in the coming months
Bun today isn’t a serious webpack/Babel/swc/esbuild/terser alternative because it lacks a minifier and it doesn’t optimize for production bundling — this will need to change
One of the goals of the project to fix this will be: on by default in bun’s runtime
A prerequisite of this is sourcemaps — which is implemented today. That’s how bun’s errors produce line numbers to original source code. It eagerly stores a sourcemap of every transpiled file.
bun v0.1.6 is released!
- Fixes "Illegal instruction" error
- 396x faster TypedArray.from (thx @Constellation)
- 3.5x faster JSON.stringify (thx @darinadler)
- about 2% faster JS execution on Linux due to enabling libpas
I'm fairly confident this does fix it because I am now able to load bun via Rosetta on macOS x64 on that macOS build and Rosetta doesn't support AVX instructions which is the cause of the crash on old CPUs
cc @ZoltanKochan - i remember you tried it and ran into this, can you give this build a try?