72 Matching Annotations
  1. Jan 2026
    1. Bun is a fast, incrementally adoptable all-in-one JavaScript, TypeScript & JSX toolkit. Use individual tools like bun test or bun install in Node.js projects, or adopt the complete stack with a fast JavaScript runtime, bundler, test runner, and package manager built in. Bun aims for 100% Node.js compatibility.

      Bun, #2025/12 bought by Anthropic for Claudecode, is a toolkit for js, typescript, jsx. you can use parts of it within node.js. Aims for full compatibility with node.js. Aims for means it doesn't I suppose

  2. Dec 2025
    1. Node.js is primarily used to build network programs such as web servers.[29] The most significant difference between Node.js and PHP is that most functions in PHP block until completion (commands execute only after previous commands finish), while Node.js functions are non-blocking (commands execute concurrently and use callbacks to signal completion or failure).[29]

      node.js differs from php in that it supports concurrent command execution.

  3. Apr 2024
  4. Nov 2023
  5. Jul 2023
  6. Mar 2023
    1. Streaming across worker threads

      ```js import { ReadableStream } from 'node:stream/web'; import { Worker } from 'node:worker_threads';

      const readable = new ReadableStream(getSomeSource());

      const worker = new Worker('/path/to/worker.js', { workerData: readable, transferList: [readable], }); ```

      ```js const { workerData: stream } = require('worker_threads');

      const reader = stream.getReader(); reader.read().then(console.log); ```

    2. Consuming web streams

      ```js import { arrayBuffer, blob, buffer, json, text, } from 'node:stream/consumers';

      const data1 = await arrayBuffer(getReadableStreamSomehow());

      const data2 = await blob(getReadableStreamSomehow());

      const data3 = await buffer(getReadableStreamSomehow());

      const data4 = await json(getReadableStreamSomehow());

      const data5 = await text(getReadableStreamSomehow()); ```

    3. Adapting to the Node.js Streams API

      ```js /* * For instance, given a ReadableStream object, the stream.Readable.fromWeb() method * will create an return a Node.js stream.Readable object that can be used to consume * the ReadableStream's data: / import { Readable } from 'node:stream';

      const readable = new ReadableStream(getSomeSource());

      const nodeReadable = Readable.fromWeb(readable);

      nodeReadable.on('data', console.log); ```

      ```js /* * The adaptation can also work the other way -- starting with a Node.js * stream.Readable and acquiring a web streams ReadableStream: / import { Readable } from 'node:stream';

      const readable = new Readable({ read(size) { reader.push(Buffer.from('hello')); } });

      const readableStream = Readable.toWeb(readable);

      await readableStream.read();

      ```

  7. Feb 2023
    1. Node.js

      js import { renderToPipeableStream } from "react-dom/server.node"; import React from "react"; import http from "http"; const App = () => ( <html> <body> <h1>Hello World</h1> <p>This is an example.</p> </body> </html> ); var didError = false; http .createServer(function (req, res) { const stream = renderToPipeableStream(<App />, { onShellReady() { res.statusCode = didError ? 500 : 200; res.setHeader("Content-type", "text/html"); res.setHeader("Cache-Control", "no-transform"); stream.pipe(res); }, onShellError(error) { res.statusCode = 500; res.send( '<!doctype html><p>Loading...</p><script src="clientrender.js"></script>', ); }, onAllReady() { }, onError(err) { didError = true; console.error(err); }, }); }) .listen(3000);

      Deno

      ```js import { renderToReadableStream } from "https://esm.run/react-dom/server"; import * as React from "https://esm.run/react";

      const App = () => ( <html> <body>

      Hello World

      This is an example.

      </body> </html> );

      const headers = { headers: { "Content-Type": "text/html", "Cache-Control": "no-transform", }, };

      Deno.serve( async (req) => { return new Response(await renderToReadableStream(<App />), headers); }, { port: 3000 }, ); ```

      Bun

      ```js import { renderToReadableStream } from "react-dom/server"; const headers = { headers: { "Content-Type": "text/html", }, };

      const App = () => ( <html> <body>

      Hello World

      This is an example.

      </body> </html> );

      Bun.serve({ port: 3000, async fetch(req) { return new Response(await renderToReadableStream(<App />), headers); }, }); ```

  8. Dec 2022
  9. Sep 2022
  10. Aug 2022
  11. Jun 2022
  12. May 2022
    1. To address this issue, and to make it easier for non-web browser environments to implement fetch in a consistent way, WinterCG is working on documenting a subset of the fetch standard that deals specifically with those different requirements and constraints.
  13. Jan 2022
  14. Dec 2021
  15. Nov 2021
  16. Oct 2021
  17. Jan 2021
    1. Buffers and TypedArrays

      Mozilla TypedArray document

      Uint8Array is a type of TypedArray

      and Buffer is an instance of Uint8Array

      Creating TypedArrays from Buffer with or without sharing same memory.

      Creating a Buffer from the TypedArrays with or without sharing the same memory

      In order to share memory we use

      1. Buffer.buffer, Buffer.byteOffset, Buffer.length / TypedArray.BYTES_PER_ELEMENT
      2. TypedArray.buffer, offset, length
  18. Apr 2020
  19. Dec 2019
  20. Sep 2019
  21. Jun 2019
  22. Nov 2018
  23. Oct 2018
  24. Sep 2018
    1. module.exports属性表示当前模块对外输出的接口,其他文件加载该模块,实际上就是读取module.exports变量。

      也就是说:

      1. require 获得的是 module.export 对象;
      2. export === modue.export 指向同一块内存;export 是一个快捷方式,覆盖就没有意义;
      3. module.export 可以覆盖,这取决与需要暴露什么对象或方法;覆盖后 export 无效,因为 第 1 条;
  25. Jun 2018
    1. Then we require() modules from our routes directory

      Routes are also a module. This 'module' is nothing more than a way to 'include' other file, so to speak in PHP terms. Its the ability to split code/functionality across multiple manageable files

  26. Apr 2018
  27. Nov 2017
  28. Jan 2016
  29. Jun 2015
  30. May 2015
  31. Jan 2014